@@ -35,21 +35,21 @@ |
||
35 | 35 | */ |
36 | 36 | class Capabilities implements ICapability { |
37 | 37 | |
38 | - /** |
|
39 | - * Capabilities constructor. |
|
40 | - * |
|
41 | - */ |
|
42 | - public function __construct() { |
|
43 | - } |
|
38 | + /** |
|
39 | + * Capabilities constructor. |
|
40 | + * |
|
41 | + */ |
|
42 | + public function __construct() { |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @inheritDoc |
|
47 | - */ |
|
48 | - public function getCapabilities() { |
|
49 | - return [ |
|
50 | - Application::APP_ID => [ |
|
51 | - 'enabled' => true, |
|
52 | - ], |
|
53 | - ]; |
|
54 | - } |
|
45 | + /** |
|
46 | + * @inheritDoc |
|
47 | + */ |
|
48 | + public function getCapabilities() { |
|
49 | + return [ |
|
50 | + Application::APP_ID => [ |
|
51 | + 'enabled' => true, |
|
52 | + ], |
|
53 | + ]; |
|
54 | + } |
|
55 | 55 | } |
@@ -34,91 +34,91 @@ |
||
34 | 34 | |
35 | 35 | class BuildCalendarSearchIndexBackgroundJob extends QueuedJob { |
36 | 36 | |
37 | - /** @var IDBConnection */ |
|
38 | - private $db; |
|
39 | - |
|
40 | - /** @var CalDavBackend */ |
|
41 | - private $calDavBackend; |
|
42 | - |
|
43 | - /** @var ILogger */ |
|
44 | - private $logger; |
|
45 | - |
|
46 | - /** @var IJobList */ |
|
47 | - private $jobList; |
|
48 | - |
|
49 | - /** @var ITimeFactory */ |
|
50 | - private $timeFactory; |
|
51 | - |
|
52 | - /** |
|
53 | - * @param IDBConnection $db |
|
54 | - * @param CalDavBackend $calDavBackend |
|
55 | - * @param ILogger $logger |
|
56 | - * @param IJobList $jobList |
|
57 | - * @param ITimeFactory $timeFactory |
|
58 | - */ |
|
59 | - public function __construct(IDBConnection $db, |
|
60 | - CalDavBackend $calDavBackend, |
|
61 | - ILogger $logger, |
|
62 | - IJobList $jobList, |
|
63 | - ITimeFactory $timeFactory) { |
|
64 | - $this->db = $db; |
|
65 | - $this->calDavBackend = $calDavBackend; |
|
66 | - $this->logger = $logger; |
|
67 | - $this->jobList = $jobList; |
|
68 | - $this->timeFactory = $timeFactory; |
|
69 | - } |
|
70 | - |
|
71 | - public function run($arguments) { |
|
72 | - $offset = (int) $arguments['offset']; |
|
73 | - $stopAt = (int) $arguments['stopAt']; |
|
74 | - |
|
75 | - $this->logger->info('Building calendar index (' . $offset .'/' . $stopAt . ')'); |
|
76 | - |
|
77 | - $startTime = $this->timeFactory->getTime(); |
|
78 | - while (($this->timeFactory->getTime() - $startTime) < 15) { |
|
79 | - $offset = $this->buildIndex($offset, $stopAt); |
|
80 | - if ($offset >= $stopAt) { |
|
81 | - break; |
|
82 | - } |
|
83 | - } |
|
84 | - |
|
85 | - if ($offset >= $stopAt) { |
|
86 | - $this->logger->info('Building calendar index done'); |
|
87 | - } else { |
|
88 | - $this->jobList->add(self::class, [ |
|
89 | - 'offset' => $offset, |
|
90 | - 'stopAt' => $stopAt |
|
91 | - ]); |
|
92 | - $this->logger->info('New building calendar index job scheduled with offset ' . $offset); |
|
93 | - } |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * @param int $offset |
|
98 | - * @param int $stopAt |
|
99 | - * @return int |
|
100 | - */ |
|
101 | - private function buildIndex(int $offset, int $stopAt): int { |
|
102 | - $query = $this->db->getQueryBuilder(); |
|
103 | - $query->select(['id', 'calendarid', 'uri', 'calendardata']) |
|
104 | - ->from('calendarobjects') |
|
105 | - ->where($query->expr()->lte('id', $query->createNamedParameter($stopAt))) |
|
106 | - ->andWhere($query->expr()->gt('id', $query->createNamedParameter($offset))) |
|
107 | - ->orderBy('id', 'ASC') |
|
108 | - ->setMaxResults(500); |
|
109 | - |
|
110 | - $result = $query->execute(); |
|
111 | - while ($row = $result->fetch(\PDO::FETCH_ASSOC)) { |
|
112 | - $offset = $row['id']; |
|
113 | - |
|
114 | - $calendarData = $row['calendardata']; |
|
115 | - if (is_resource($calendarData)) { |
|
116 | - $calendarData = stream_get_contents($calendarData); |
|
117 | - } |
|
118 | - |
|
119 | - $this->calDavBackend->updateProperties($row['calendarid'], $row['uri'], $calendarData); |
|
120 | - } |
|
121 | - |
|
122 | - return $offset; |
|
123 | - } |
|
37 | + /** @var IDBConnection */ |
|
38 | + private $db; |
|
39 | + |
|
40 | + /** @var CalDavBackend */ |
|
41 | + private $calDavBackend; |
|
42 | + |
|
43 | + /** @var ILogger */ |
|
44 | + private $logger; |
|
45 | + |
|
46 | + /** @var IJobList */ |
|
47 | + private $jobList; |
|
48 | + |
|
49 | + /** @var ITimeFactory */ |
|
50 | + private $timeFactory; |
|
51 | + |
|
52 | + /** |
|
53 | + * @param IDBConnection $db |
|
54 | + * @param CalDavBackend $calDavBackend |
|
55 | + * @param ILogger $logger |
|
56 | + * @param IJobList $jobList |
|
57 | + * @param ITimeFactory $timeFactory |
|
58 | + */ |
|
59 | + public function __construct(IDBConnection $db, |
|
60 | + CalDavBackend $calDavBackend, |
|
61 | + ILogger $logger, |
|
62 | + IJobList $jobList, |
|
63 | + ITimeFactory $timeFactory) { |
|
64 | + $this->db = $db; |
|
65 | + $this->calDavBackend = $calDavBackend; |
|
66 | + $this->logger = $logger; |
|
67 | + $this->jobList = $jobList; |
|
68 | + $this->timeFactory = $timeFactory; |
|
69 | + } |
|
70 | + |
|
71 | + public function run($arguments) { |
|
72 | + $offset = (int) $arguments['offset']; |
|
73 | + $stopAt = (int) $arguments['stopAt']; |
|
74 | + |
|
75 | + $this->logger->info('Building calendar index (' . $offset .'/' . $stopAt . ')'); |
|
76 | + |
|
77 | + $startTime = $this->timeFactory->getTime(); |
|
78 | + while (($this->timeFactory->getTime() - $startTime) < 15) { |
|
79 | + $offset = $this->buildIndex($offset, $stopAt); |
|
80 | + if ($offset >= $stopAt) { |
|
81 | + break; |
|
82 | + } |
|
83 | + } |
|
84 | + |
|
85 | + if ($offset >= $stopAt) { |
|
86 | + $this->logger->info('Building calendar index done'); |
|
87 | + } else { |
|
88 | + $this->jobList->add(self::class, [ |
|
89 | + 'offset' => $offset, |
|
90 | + 'stopAt' => $stopAt |
|
91 | + ]); |
|
92 | + $this->logger->info('New building calendar index job scheduled with offset ' . $offset); |
|
93 | + } |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * @param int $offset |
|
98 | + * @param int $stopAt |
|
99 | + * @return int |
|
100 | + */ |
|
101 | + private function buildIndex(int $offset, int $stopAt): int { |
|
102 | + $query = $this->db->getQueryBuilder(); |
|
103 | + $query->select(['id', 'calendarid', 'uri', 'calendardata']) |
|
104 | + ->from('calendarobjects') |
|
105 | + ->where($query->expr()->lte('id', $query->createNamedParameter($stopAt))) |
|
106 | + ->andWhere($query->expr()->gt('id', $query->createNamedParameter($offset))) |
|
107 | + ->orderBy('id', 'ASC') |
|
108 | + ->setMaxResults(500); |
|
109 | + |
|
110 | + $result = $query->execute(); |
|
111 | + while ($row = $result->fetch(\PDO::FETCH_ASSOC)) { |
|
112 | + $offset = $row['id']; |
|
113 | + |
|
114 | + $calendarData = $row['calendardata']; |
|
115 | + if (is_resource($calendarData)) { |
|
116 | + $calendarData = stream_get_contents($calendarData); |
|
117 | + } |
|
118 | + |
|
119 | + $this->calDavBackend->updateProperties($row['calendarid'], $row['uri'], $calendarData); |
|
120 | + } |
|
121 | + |
|
122 | + return $offset; |
|
123 | + } |
|
124 | 124 | } |
@@ -37,244 +37,244 @@ |
||
37 | 37 | use Psr\Log\LoggerInterface; |
38 | 38 | |
39 | 39 | class TempManager implements ITempManager { |
40 | - /** @var string[] Current temporary files and folders, used for cleanup */ |
|
41 | - protected $current = []; |
|
42 | - /** @var string i.e. /tmp on linux systems */ |
|
43 | - protected $tmpBaseDir; |
|
44 | - /** @var LoggerInterface */ |
|
45 | - protected $log; |
|
46 | - /** @var IConfig */ |
|
47 | - protected $config; |
|
48 | - /** @var IniGetWrapper */ |
|
49 | - protected $iniGetWrapper; |
|
40 | + /** @var string[] Current temporary files and folders, used for cleanup */ |
|
41 | + protected $current = []; |
|
42 | + /** @var string i.e. /tmp on linux systems */ |
|
43 | + protected $tmpBaseDir; |
|
44 | + /** @var LoggerInterface */ |
|
45 | + protected $log; |
|
46 | + /** @var IConfig */ |
|
47 | + protected $config; |
|
48 | + /** @var IniGetWrapper */ |
|
49 | + protected $iniGetWrapper; |
|
50 | 50 | |
51 | - /** Prefix */ |
|
52 | - public const TMP_PREFIX = 'oc_tmp_'; |
|
51 | + /** Prefix */ |
|
52 | + public const TMP_PREFIX = 'oc_tmp_'; |
|
53 | 53 | |
54 | - public function __construct(LoggerInterface $logger, IConfig $config, IniGetWrapper $iniGetWrapper) { |
|
55 | - $this->log = $logger; |
|
56 | - $this->config = $config; |
|
57 | - $this->iniGetWrapper = $iniGetWrapper; |
|
58 | - $this->tmpBaseDir = $this->getTempBaseDir(); |
|
59 | - } |
|
54 | + public function __construct(LoggerInterface $logger, IConfig $config, IniGetWrapper $iniGetWrapper) { |
|
55 | + $this->log = $logger; |
|
56 | + $this->config = $config; |
|
57 | + $this->iniGetWrapper = $iniGetWrapper; |
|
58 | + $this->tmpBaseDir = $this->getTempBaseDir(); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * Builds the filename with suffix and removes potential dangerous characters |
|
63 | - * such as directory separators. |
|
64 | - * |
|
65 | - * @param string $absolutePath Absolute path to the file / folder |
|
66 | - * @param string $postFix Postfix appended to the temporary file name, may be user controlled |
|
67 | - * @return string |
|
68 | - */ |
|
69 | - private function buildFileNameWithSuffix($absolutePath, $postFix = '') { |
|
70 | - if ($postFix !== '') { |
|
71 | - $postFix = '.' . ltrim($postFix, '.'); |
|
72 | - $postFix = str_replace(['\\', '/'], '', $postFix); |
|
73 | - $absolutePath .= '-'; |
|
74 | - } |
|
61 | + /** |
|
62 | + * Builds the filename with suffix and removes potential dangerous characters |
|
63 | + * such as directory separators. |
|
64 | + * |
|
65 | + * @param string $absolutePath Absolute path to the file / folder |
|
66 | + * @param string $postFix Postfix appended to the temporary file name, may be user controlled |
|
67 | + * @return string |
|
68 | + */ |
|
69 | + private function buildFileNameWithSuffix($absolutePath, $postFix = '') { |
|
70 | + if ($postFix !== '') { |
|
71 | + $postFix = '.' . ltrim($postFix, '.'); |
|
72 | + $postFix = str_replace(['\\', '/'], '', $postFix); |
|
73 | + $absolutePath .= '-'; |
|
74 | + } |
|
75 | 75 | |
76 | - return $absolutePath . $postFix; |
|
77 | - } |
|
76 | + return $absolutePath . $postFix; |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * Create a temporary file and return the path |
|
81 | - * |
|
82 | - * @param string $postFix Postfix appended to the temporary file name |
|
83 | - * @return string |
|
84 | - */ |
|
85 | - public function getTemporaryFile($postFix = '') { |
|
86 | - if (is_writable($this->tmpBaseDir)) { |
|
87 | - // To create an unique file and prevent the risk of race conditions |
|
88 | - // or duplicated temporary files by other means such as collisions |
|
89 | - // we need to create the file using `tempnam` and append a possible |
|
90 | - // postfix to it later |
|
91 | - $file = tempnam($this->tmpBaseDir, self::TMP_PREFIX); |
|
92 | - $this->current[] = $file; |
|
79 | + /** |
|
80 | + * Create a temporary file and return the path |
|
81 | + * |
|
82 | + * @param string $postFix Postfix appended to the temporary file name |
|
83 | + * @return string |
|
84 | + */ |
|
85 | + public function getTemporaryFile($postFix = '') { |
|
86 | + if (is_writable($this->tmpBaseDir)) { |
|
87 | + // To create an unique file and prevent the risk of race conditions |
|
88 | + // or duplicated temporary files by other means such as collisions |
|
89 | + // we need to create the file using `tempnam` and append a possible |
|
90 | + // postfix to it later |
|
91 | + $file = tempnam($this->tmpBaseDir, self::TMP_PREFIX); |
|
92 | + $this->current[] = $file; |
|
93 | 93 | |
94 | - // If a postfix got specified sanitize it and create a postfixed |
|
95 | - // temporary file |
|
96 | - if ($postFix !== '') { |
|
97 | - $fileNameWithPostfix = $this->buildFileNameWithSuffix($file, $postFix); |
|
98 | - touch($fileNameWithPostfix); |
|
99 | - chmod($fileNameWithPostfix, 0600); |
|
100 | - $this->current[] = $fileNameWithPostfix; |
|
101 | - return $fileNameWithPostfix; |
|
102 | - } |
|
94 | + // If a postfix got specified sanitize it and create a postfixed |
|
95 | + // temporary file |
|
96 | + if ($postFix !== '') { |
|
97 | + $fileNameWithPostfix = $this->buildFileNameWithSuffix($file, $postFix); |
|
98 | + touch($fileNameWithPostfix); |
|
99 | + chmod($fileNameWithPostfix, 0600); |
|
100 | + $this->current[] = $fileNameWithPostfix; |
|
101 | + return $fileNameWithPostfix; |
|
102 | + } |
|
103 | 103 | |
104 | - return $file; |
|
105 | - } else { |
|
106 | - $this->log->warning( |
|
107 | - 'Can not create a temporary file in directory {dir}. Check it exists and has correct permissions', |
|
108 | - [ |
|
109 | - 'dir' => $this->tmpBaseDir, |
|
110 | - ] |
|
111 | - ); |
|
112 | - return false; |
|
113 | - } |
|
114 | - } |
|
104 | + return $file; |
|
105 | + } else { |
|
106 | + $this->log->warning( |
|
107 | + 'Can not create a temporary file in directory {dir}. Check it exists and has correct permissions', |
|
108 | + [ |
|
109 | + 'dir' => $this->tmpBaseDir, |
|
110 | + ] |
|
111 | + ); |
|
112 | + return false; |
|
113 | + } |
|
114 | + } |
|
115 | 115 | |
116 | - /** |
|
117 | - * Create a temporary folder and return the path |
|
118 | - * |
|
119 | - * @param string $postFix Postfix appended to the temporary folder name |
|
120 | - * @return string |
|
121 | - */ |
|
122 | - public function getTemporaryFolder($postFix = '') { |
|
123 | - if (is_writable($this->tmpBaseDir)) { |
|
124 | - // To create an unique directory and prevent the risk of race conditions |
|
125 | - // or duplicated temporary files by other means such as collisions |
|
126 | - // we need to create the file using `tempnam` and append a possible |
|
127 | - // postfix to it later |
|
128 | - $uniqueFileName = tempnam($this->tmpBaseDir, self::TMP_PREFIX); |
|
129 | - $this->current[] = $uniqueFileName; |
|
116 | + /** |
|
117 | + * Create a temporary folder and return the path |
|
118 | + * |
|
119 | + * @param string $postFix Postfix appended to the temporary folder name |
|
120 | + * @return string |
|
121 | + */ |
|
122 | + public function getTemporaryFolder($postFix = '') { |
|
123 | + if (is_writable($this->tmpBaseDir)) { |
|
124 | + // To create an unique directory and prevent the risk of race conditions |
|
125 | + // or duplicated temporary files by other means such as collisions |
|
126 | + // we need to create the file using `tempnam` and append a possible |
|
127 | + // postfix to it later |
|
128 | + $uniqueFileName = tempnam($this->tmpBaseDir, self::TMP_PREFIX); |
|
129 | + $this->current[] = $uniqueFileName; |
|
130 | 130 | |
131 | - // Build a name without postfix |
|
132 | - $path = $this->buildFileNameWithSuffix($uniqueFileName . '-folder', $postFix); |
|
133 | - mkdir($path, 0700); |
|
134 | - $this->current[] = $path; |
|
131 | + // Build a name without postfix |
|
132 | + $path = $this->buildFileNameWithSuffix($uniqueFileName . '-folder', $postFix); |
|
133 | + mkdir($path, 0700); |
|
134 | + $this->current[] = $path; |
|
135 | 135 | |
136 | - return $path . '/'; |
|
137 | - } else { |
|
138 | - $this->log->warning( |
|
139 | - 'Can not create a temporary folder in directory {dir}. Check it exists and has correct permissions', |
|
140 | - [ |
|
141 | - 'dir' => $this->tmpBaseDir, |
|
142 | - ] |
|
143 | - ); |
|
144 | - return false; |
|
145 | - } |
|
146 | - } |
|
136 | + return $path . '/'; |
|
137 | + } else { |
|
138 | + $this->log->warning( |
|
139 | + 'Can not create a temporary folder in directory {dir}. Check it exists and has correct permissions', |
|
140 | + [ |
|
141 | + 'dir' => $this->tmpBaseDir, |
|
142 | + ] |
|
143 | + ); |
|
144 | + return false; |
|
145 | + } |
|
146 | + } |
|
147 | 147 | |
148 | - /** |
|
149 | - * Remove the temporary files and folders generated during this request |
|
150 | - */ |
|
151 | - public function clean() { |
|
152 | - $this->cleanFiles($this->current); |
|
153 | - } |
|
148 | + /** |
|
149 | + * Remove the temporary files and folders generated during this request |
|
150 | + */ |
|
151 | + public function clean() { |
|
152 | + $this->cleanFiles($this->current); |
|
153 | + } |
|
154 | 154 | |
155 | - /** |
|
156 | - * @param string[] $files |
|
157 | - */ |
|
158 | - protected function cleanFiles($files) { |
|
159 | - foreach ($files as $file) { |
|
160 | - if (file_exists($file)) { |
|
161 | - try { |
|
162 | - \OC_Helper::rmdirr($file); |
|
163 | - } catch (\UnexpectedValueException $ex) { |
|
164 | - $this->log->warning( |
|
165 | - "Error deleting temporary file/folder: {file} - Reason: {error}", |
|
166 | - [ |
|
167 | - 'file' => $file, |
|
168 | - 'error' => $ex->getMessage(), |
|
169 | - ] |
|
170 | - ); |
|
171 | - } |
|
172 | - } |
|
173 | - } |
|
174 | - } |
|
155 | + /** |
|
156 | + * @param string[] $files |
|
157 | + */ |
|
158 | + protected function cleanFiles($files) { |
|
159 | + foreach ($files as $file) { |
|
160 | + if (file_exists($file)) { |
|
161 | + try { |
|
162 | + \OC_Helper::rmdirr($file); |
|
163 | + } catch (\UnexpectedValueException $ex) { |
|
164 | + $this->log->warning( |
|
165 | + "Error deleting temporary file/folder: {file} - Reason: {error}", |
|
166 | + [ |
|
167 | + 'file' => $file, |
|
168 | + 'error' => $ex->getMessage(), |
|
169 | + ] |
|
170 | + ); |
|
171 | + } |
|
172 | + } |
|
173 | + } |
|
174 | + } |
|
175 | 175 | |
176 | - /** |
|
177 | - * Remove old temporary files and folders that were failed to be cleaned |
|
178 | - */ |
|
179 | - public function cleanOld() { |
|
180 | - $this->cleanFiles($this->getOldFiles()); |
|
181 | - } |
|
176 | + /** |
|
177 | + * Remove old temporary files and folders that were failed to be cleaned |
|
178 | + */ |
|
179 | + public function cleanOld() { |
|
180 | + $this->cleanFiles($this->getOldFiles()); |
|
181 | + } |
|
182 | 182 | |
183 | - /** |
|
184 | - * Get all temporary files and folders generated by oc older than an hour |
|
185 | - * |
|
186 | - * @return string[] |
|
187 | - */ |
|
188 | - protected function getOldFiles() { |
|
189 | - $cutOfTime = time() - 3600; |
|
190 | - $files = []; |
|
191 | - $dh = opendir($this->tmpBaseDir); |
|
192 | - if ($dh) { |
|
193 | - while (($file = readdir($dh)) !== false) { |
|
194 | - if (substr($file, 0, 7) === self::TMP_PREFIX) { |
|
195 | - $path = $this->tmpBaseDir . '/' . $file; |
|
196 | - $mtime = filemtime($path); |
|
197 | - if ($mtime < $cutOfTime) { |
|
198 | - $files[] = $path; |
|
199 | - } |
|
200 | - } |
|
201 | - } |
|
202 | - } |
|
203 | - return $files; |
|
204 | - } |
|
183 | + /** |
|
184 | + * Get all temporary files and folders generated by oc older than an hour |
|
185 | + * |
|
186 | + * @return string[] |
|
187 | + */ |
|
188 | + protected function getOldFiles() { |
|
189 | + $cutOfTime = time() - 3600; |
|
190 | + $files = []; |
|
191 | + $dh = opendir($this->tmpBaseDir); |
|
192 | + if ($dh) { |
|
193 | + while (($file = readdir($dh)) !== false) { |
|
194 | + if (substr($file, 0, 7) === self::TMP_PREFIX) { |
|
195 | + $path = $this->tmpBaseDir . '/' . $file; |
|
196 | + $mtime = filemtime($path); |
|
197 | + if ($mtime < $cutOfTime) { |
|
198 | + $files[] = $path; |
|
199 | + } |
|
200 | + } |
|
201 | + } |
|
202 | + } |
|
203 | + return $files; |
|
204 | + } |
|
205 | 205 | |
206 | - /** |
|
207 | - * Get the temporary base directory configured on the server |
|
208 | - * |
|
209 | - * @return string Path to the temporary directory or null |
|
210 | - * @throws \UnexpectedValueException |
|
211 | - */ |
|
212 | - public function getTempBaseDir() { |
|
213 | - if ($this->tmpBaseDir) { |
|
214 | - return $this->tmpBaseDir; |
|
215 | - } |
|
206 | + /** |
|
207 | + * Get the temporary base directory configured on the server |
|
208 | + * |
|
209 | + * @return string Path to the temporary directory or null |
|
210 | + * @throws \UnexpectedValueException |
|
211 | + */ |
|
212 | + public function getTempBaseDir() { |
|
213 | + if ($this->tmpBaseDir) { |
|
214 | + return $this->tmpBaseDir; |
|
215 | + } |
|
216 | 216 | |
217 | - $directories = []; |
|
218 | - if ($temp = $this->config->getSystemValue('tempdirectory', null)) { |
|
219 | - $directories[] = $temp; |
|
220 | - } |
|
221 | - if ($temp = $this->iniGetWrapper->get('upload_tmp_dir')) { |
|
222 | - $directories[] = $temp; |
|
223 | - } |
|
224 | - if ($temp = getenv('TMP')) { |
|
225 | - $directories[] = $temp; |
|
226 | - } |
|
227 | - if ($temp = getenv('TEMP')) { |
|
228 | - $directories[] = $temp; |
|
229 | - } |
|
230 | - if ($temp = getenv('TMPDIR')) { |
|
231 | - $directories[] = $temp; |
|
232 | - } |
|
233 | - if ($temp = sys_get_temp_dir()) { |
|
234 | - $directories[] = $temp; |
|
235 | - } |
|
217 | + $directories = []; |
|
218 | + if ($temp = $this->config->getSystemValue('tempdirectory', null)) { |
|
219 | + $directories[] = $temp; |
|
220 | + } |
|
221 | + if ($temp = $this->iniGetWrapper->get('upload_tmp_dir')) { |
|
222 | + $directories[] = $temp; |
|
223 | + } |
|
224 | + if ($temp = getenv('TMP')) { |
|
225 | + $directories[] = $temp; |
|
226 | + } |
|
227 | + if ($temp = getenv('TEMP')) { |
|
228 | + $directories[] = $temp; |
|
229 | + } |
|
230 | + if ($temp = getenv('TMPDIR')) { |
|
231 | + $directories[] = $temp; |
|
232 | + } |
|
233 | + if ($temp = sys_get_temp_dir()) { |
|
234 | + $directories[] = $temp; |
|
235 | + } |
|
236 | 236 | |
237 | - foreach ($directories as $dir) { |
|
238 | - if ($this->checkTemporaryDirectory($dir)) { |
|
239 | - return $dir; |
|
240 | - } |
|
241 | - } |
|
237 | + foreach ($directories as $dir) { |
|
238 | + if ($this->checkTemporaryDirectory($dir)) { |
|
239 | + return $dir; |
|
240 | + } |
|
241 | + } |
|
242 | 242 | |
243 | - $temp = tempnam(dirname(__FILE__), ''); |
|
244 | - if (file_exists($temp)) { |
|
245 | - unlink($temp); |
|
246 | - return dirname($temp); |
|
247 | - } |
|
248 | - throw new \UnexpectedValueException('Unable to detect system temporary directory'); |
|
249 | - } |
|
243 | + $temp = tempnam(dirname(__FILE__), ''); |
|
244 | + if (file_exists($temp)) { |
|
245 | + unlink($temp); |
|
246 | + return dirname($temp); |
|
247 | + } |
|
248 | + throw new \UnexpectedValueException('Unable to detect system temporary directory'); |
|
249 | + } |
|
250 | 250 | |
251 | - /** |
|
252 | - * Check if a temporary directory is ready for use |
|
253 | - * |
|
254 | - * @param mixed $directory |
|
255 | - * @return bool |
|
256 | - */ |
|
257 | - private function checkTemporaryDirectory($directory) { |
|
258 | - // suppress any possible errors caused by is_writable |
|
259 | - // checks missing or invalid path or characters, wrong permissions etc |
|
260 | - try { |
|
261 | - if (is_writable($directory)) { |
|
262 | - return true; |
|
263 | - } |
|
264 | - } catch (\Exception $e) { |
|
265 | - } |
|
266 | - $this->log->warning('Temporary directory {dir} is not present or writable', |
|
267 | - ['dir' => $directory] |
|
268 | - ); |
|
269 | - return false; |
|
270 | - } |
|
251 | + /** |
|
252 | + * Check if a temporary directory is ready for use |
|
253 | + * |
|
254 | + * @param mixed $directory |
|
255 | + * @return bool |
|
256 | + */ |
|
257 | + private function checkTemporaryDirectory($directory) { |
|
258 | + // suppress any possible errors caused by is_writable |
|
259 | + // checks missing or invalid path or characters, wrong permissions etc |
|
260 | + try { |
|
261 | + if (is_writable($directory)) { |
|
262 | + return true; |
|
263 | + } |
|
264 | + } catch (\Exception $e) { |
|
265 | + } |
|
266 | + $this->log->warning('Temporary directory {dir} is not present or writable', |
|
267 | + ['dir' => $directory] |
|
268 | + ); |
|
269 | + return false; |
|
270 | + } |
|
271 | 271 | |
272 | - /** |
|
273 | - * Override the temporary base directory |
|
274 | - * |
|
275 | - * @param string $directory |
|
276 | - */ |
|
277 | - public function overrideTempBaseDir($directory) { |
|
278 | - $this->tmpBaseDir = $directory; |
|
279 | - } |
|
272 | + /** |
|
273 | + * Override the temporary base directory |
|
274 | + * |
|
275 | + * @param string $directory |
|
276 | + */ |
|
277 | + public function overrideTempBaseDir($directory) { |
|
278 | + $this->tmpBaseDir = $directory; |
|
279 | + } |
|
280 | 280 | } |
@@ -36,56 +36,56 @@ |
||
36 | 36 | * @since 18.0.0 |
37 | 37 | */ |
38 | 38 | interface IRuleMatcher extends IFileCheck { |
39 | - /** |
|
40 | - * This method is left for backwards compatibility and easier porting of |
|
41 | - * apps. Please use 'getFlows' instead (and setOperation if you implement |
|
42 | - * an IComplexOperation). |
|
43 | - * |
|
44 | - * @since 18.0.0 |
|
45 | - * @deprecated 18.0.0 |
|
46 | - */ |
|
47 | - public function getMatchingOperations(string $class, bool $returnFirstMatchingOperationOnly = true): array; |
|
39 | + /** |
|
40 | + * This method is left for backwards compatibility and easier porting of |
|
41 | + * apps. Please use 'getFlows' instead (and setOperation if you implement |
|
42 | + * an IComplexOperation). |
|
43 | + * |
|
44 | + * @since 18.0.0 |
|
45 | + * @deprecated 18.0.0 |
|
46 | + */ |
|
47 | + public function getMatchingOperations(string $class, bool $returnFirstMatchingOperationOnly = true): array; |
|
48 | 48 | |
49 | - /** |
|
50 | - * @throws RuntimeException |
|
51 | - * @since 18.0.0 |
|
52 | - */ |
|
53 | - public function getFlows(bool $returnFirstMatchingOperationOnly = true): array; |
|
49 | + /** |
|
50 | + * @throws RuntimeException |
|
51 | + * @since 18.0.0 |
|
52 | + */ |
|
53 | + public function getFlows(bool $returnFirstMatchingOperationOnly = true): array; |
|
54 | 54 | |
55 | - /** |
|
56 | - * this method can only be called once and is typically called by the |
|
57 | - * Flow engine, unless for IComplexOperations. |
|
58 | - * |
|
59 | - * @throws RuntimeException |
|
60 | - * @since 18.0.0 |
|
61 | - */ |
|
62 | - public function setOperation(IOperation $operation): void; |
|
55 | + /** |
|
56 | + * this method can only be called once and is typically called by the |
|
57 | + * Flow engine, unless for IComplexOperations. |
|
58 | + * |
|
59 | + * @throws RuntimeException |
|
60 | + * @since 18.0.0 |
|
61 | + */ |
|
62 | + public function setOperation(IOperation $operation): void; |
|
63 | 63 | |
64 | - /** |
|
65 | - * this method can only be called once and is typically called by the |
|
66 | - * Flow engine, unless for IComplexOperations. |
|
67 | - * |
|
68 | - * @throws RuntimeException |
|
69 | - * @since 18.0.0 |
|
70 | - */ |
|
71 | - public function setEntity(IEntity $entity): void; |
|
64 | + /** |
|
65 | + * this method can only be called once and is typically called by the |
|
66 | + * Flow engine, unless for IComplexOperations. |
|
67 | + * |
|
68 | + * @throws RuntimeException |
|
69 | + * @since 18.0.0 |
|
70 | + */ |
|
71 | + public function setEntity(IEntity $entity): void; |
|
72 | 72 | |
73 | - /** |
|
74 | - * returns the entity which might provide more information, depending on |
|
75 | - * the interfaces it implements |
|
76 | - * |
|
77 | - * @return IEntity |
|
78 | - * @since 18.0.0 |
|
79 | - */ |
|
80 | - public function getEntity(): IEntity; |
|
73 | + /** |
|
74 | + * returns the entity which might provide more information, depending on |
|
75 | + * the interfaces it implements |
|
76 | + * |
|
77 | + * @return IEntity |
|
78 | + * @since 18.0.0 |
|
79 | + */ |
|
80 | + public function getEntity(): IEntity; |
|
81 | 81 | |
82 | - /** |
|
83 | - * this method can be called once to set the event name that is currently |
|
84 | - * being processed. The workflow engine takes care of this usually, only an |
|
85 | - * IComplexOperation might want to make use of it. |
|
86 | - * |
|
87 | - * @throws RuntimeException |
|
88 | - * @since 20.0.0 |
|
89 | - */ |
|
90 | - public function setEventName(string $eventName): void; |
|
82 | + /** |
|
83 | + * this method can be called once to set the event name that is currently |
|
84 | + * being processed. The workflow engine takes care of this usually, only an |
|
85 | + * IComplexOperation might want to make use of it. |
|
86 | + * |
|
87 | + * @throws RuntimeException |
|
88 | + * @since 20.0.0 |
|
89 | + */ |
|
90 | + public function setEventName(string $eventName): void; |
|
91 | 91 | } |
@@ -24,61 +24,61 @@ |
||
24 | 24 | namespace OCA\DAV\CalDAV\Activity\Setting; |
25 | 25 | |
26 | 26 | class Calendar extends CalDAVSetting { |
27 | - /** |
|
28 | - * @return string Lowercase a-z and underscore only identifier |
|
29 | - * @since 11.0.0 |
|
30 | - */ |
|
31 | - public function getIdentifier() { |
|
32 | - return 'calendar'; |
|
33 | - } |
|
27 | + /** |
|
28 | + * @return string Lowercase a-z and underscore only identifier |
|
29 | + * @since 11.0.0 |
|
30 | + */ |
|
31 | + public function getIdentifier() { |
|
32 | + return 'calendar'; |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * @return string A translated string |
|
37 | - * @since 11.0.0 |
|
38 | - */ |
|
39 | - public function getName() { |
|
40 | - return $this->l->t('A <strong>calendar</strong> was modified'); |
|
41 | - } |
|
35 | + /** |
|
36 | + * @return string A translated string |
|
37 | + * @since 11.0.0 |
|
38 | + */ |
|
39 | + public function getName() { |
|
40 | + return $this->l->t('A <strong>calendar</strong> was modified'); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @return int whether the filter should be rather on the top or bottom of |
|
45 | - * the admin section. The filters are arranged in ascending order of the |
|
46 | - * priority values. It is required to return a value between 0 and 100. |
|
47 | - * @since 11.0.0 |
|
48 | - */ |
|
49 | - public function getPriority() { |
|
50 | - return 50; |
|
51 | - } |
|
43 | + /** |
|
44 | + * @return int whether the filter should be rather on the top or bottom of |
|
45 | + * the admin section. The filters are arranged in ascending order of the |
|
46 | + * priority values. It is required to return a value between 0 and 100. |
|
47 | + * @since 11.0.0 |
|
48 | + */ |
|
49 | + public function getPriority() { |
|
50 | + return 50; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @return bool True when the option can be changed for the stream |
|
55 | - * @since 11.0.0 |
|
56 | - */ |
|
57 | - public function canChangeStream() { |
|
58 | - return true; |
|
59 | - } |
|
53 | + /** |
|
54 | + * @return bool True when the option can be changed for the stream |
|
55 | + * @since 11.0.0 |
|
56 | + */ |
|
57 | + public function canChangeStream() { |
|
58 | + return true; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @return bool True when the option can be changed for the stream |
|
63 | - * @since 11.0.0 |
|
64 | - */ |
|
65 | - public function isDefaultEnabledStream() { |
|
66 | - return true; |
|
67 | - } |
|
61 | + /** |
|
62 | + * @return bool True when the option can be changed for the stream |
|
63 | + * @since 11.0.0 |
|
64 | + */ |
|
65 | + public function isDefaultEnabledStream() { |
|
66 | + return true; |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @return bool True when the option can be changed for the mail |
|
71 | - * @since 11.0.0 |
|
72 | - */ |
|
73 | - public function canChangeMail() { |
|
74 | - return true; |
|
75 | - } |
|
69 | + /** |
|
70 | + * @return bool True when the option can be changed for the mail |
|
71 | + * @since 11.0.0 |
|
72 | + */ |
|
73 | + public function canChangeMail() { |
|
74 | + return true; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @return bool True when the option can be changed for the stream |
|
79 | - * @since 11.0.0 |
|
80 | - */ |
|
81 | - public function isDefaultEnabledMail() { |
|
82 | - return false; |
|
83 | - } |
|
77 | + /** |
|
78 | + * @return bool True when the option can be changed for the stream |
|
79 | + * @since 11.0.0 |
|
80 | + */ |
|
81 | + public function isDefaultEnabledMail() { |
|
82 | + return false; |
|
83 | + } |
|
84 | 84 | } |
@@ -24,61 +24,61 @@ |
||
24 | 24 | namespace OCA\DAV\CalDAV\Activity\Setting; |
25 | 25 | |
26 | 26 | class Event extends CalDAVSetting { |
27 | - /** |
|
28 | - * @return string Lowercase a-z and underscore only identifier |
|
29 | - * @since 11.0.0 |
|
30 | - */ |
|
31 | - public function getIdentifier() { |
|
32 | - return 'calendar_event'; |
|
33 | - } |
|
27 | + /** |
|
28 | + * @return string Lowercase a-z and underscore only identifier |
|
29 | + * @since 11.0.0 |
|
30 | + */ |
|
31 | + public function getIdentifier() { |
|
32 | + return 'calendar_event'; |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * @return string A translated string |
|
37 | - * @since 11.0.0 |
|
38 | - */ |
|
39 | - public function getName() { |
|
40 | - return $this->l->t('A calendar <strong>event</strong> was modified'); |
|
41 | - } |
|
35 | + /** |
|
36 | + * @return string A translated string |
|
37 | + * @since 11.0.0 |
|
38 | + */ |
|
39 | + public function getName() { |
|
40 | + return $this->l->t('A calendar <strong>event</strong> was modified'); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @return int whether the filter should be rather on the top or bottom of |
|
45 | - * the admin section. The filters are arranged in ascending order of the |
|
46 | - * priority values. It is required to return a value between 0 and 100. |
|
47 | - * @since 11.0.0 |
|
48 | - */ |
|
49 | - public function getPriority() { |
|
50 | - return 50; |
|
51 | - } |
|
43 | + /** |
|
44 | + * @return int whether the filter should be rather on the top or bottom of |
|
45 | + * the admin section. The filters are arranged in ascending order of the |
|
46 | + * priority values. It is required to return a value between 0 and 100. |
|
47 | + * @since 11.0.0 |
|
48 | + */ |
|
49 | + public function getPriority() { |
|
50 | + return 50; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @return bool True when the option can be changed for the stream |
|
55 | - * @since 11.0.0 |
|
56 | - */ |
|
57 | - public function canChangeStream() { |
|
58 | - return true; |
|
59 | - } |
|
53 | + /** |
|
54 | + * @return bool True when the option can be changed for the stream |
|
55 | + * @since 11.0.0 |
|
56 | + */ |
|
57 | + public function canChangeStream() { |
|
58 | + return true; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @return bool True when the option can be changed for the stream |
|
63 | - * @since 11.0.0 |
|
64 | - */ |
|
65 | - public function isDefaultEnabledStream() { |
|
66 | - return true; |
|
67 | - } |
|
61 | + /** |
|
62 | + * @return bool True when the option can be changed for the stream |
|
63 | + * @since 11.0.0 |
|
64 | + */ |
|
65 | + public function isDefaultEnabledStream() { |
|
66 | + return true; |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @return bool True when the option can be changed for the mail |
|
71 | - * @since 11.0.0 |
|
72 | - */ |
|
73 | - public function canChangeMail() { |
|
74 | - return true; |
|
75 | - } |
|
69 | + /** |
|
70 | + * @return bool True when the option can be changed for the mail |
|
71 | + * @since 11.0.0 |
|
72 | + */ |
|
73 | + public function canChangeMail() { |
|
74 | + return true; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @return bool True when the option can be changed for the stream |
|
79 | - * @since 11.0.0 |
|
80 | - */ |
|
81 | - public function isDefaultEnabledMail() { |
|
82 | - return false; |
|
83 | - } |
|
77 | + /** |
|
78 | + * @return bool True when the option can be changed for the stream |
|
79 | + * @since 11.0.0 |
|
80 | + */ |
|
81 | + public function isDefaultEnabledMail() { |
|
82 | + return false; |
|
83 | + } |
|
84 | 84 | } |
@@ -39,92 +39,92 @@ |
||
39 | 39 | * |
40 | 40 | */ |
41 | 41 | interface ISearchRequestSimpleQuery { |
42 | - public const COMPARE_TYPE_TEXT = 1; |
|
43 | - public const COMPARE_TYPE_KEYWORD = 2; |
|
44 | - public const COMPARE_TYPE_INT_EQ = 3; |
|
45 | - public const COMPARE_TYPE_INT_GTE = 4; |
|
46 | - public const COMPARE_TYPE_INT_GT = 5; |
|
47 | - public const COMPARE_TYPE_INT_LTE = 6; |
|
48 | - public const COMPARE_TYPE_INT_LT = 7; |
|
49 | - public const COMPARE_TYPE_BOOL = 8; |
|
50 | - public const COMPARE_TYPE_ARRAY = 9; |
|
51 | - public const COMPARE_TYPE_REGEX = 10; |
|
52 | - public const COMPARE_TYPE_WILDCARD = 11; |
|
42 | + public const COMPARE_TYPE_TEXT = 1; |
|
43 | + public const COMPARE_TYPE_KEYWORD = 2; |
|
44 | + public const COMPARE_TYPE_INT_EQ = 3; |
|
45 | + public const COMPARE_TYPE_INT_GTE = 4; |
|
46 | + public const COMPARE_TYPE_INT_GT = 5; |
|
47 | + public const COMPARE_TYPE_INT_LTE = 6; |
|
48 | + public const COMPARE_TYPE_INT_LT = 7; |
|
49 | + public const COMPARE_TYPE_BOOL = 8; |
|
50 | + public const COMPARE_TYPE_ARRAY = 9; |
|
51 | + public const COMPARE_TYPE_REGEX = 10; |
|
52 | + public const COMPARE_TYPE_WILDCARD = 11; |
|
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * Get the compare type of the query |
|
57 | - * |
|
58 | - * @return int |
|
59 | - * @since 17.0.0 |
|
60 | - */ |
|
61 | - public function getType(): int; |
|
55 | + /** |
|
56 | + * Get the compare type of the query |
|
57 | + * |
|
58 | + * @return int |
|
59 | + * @since 17.0.0 |
|
60 | + */ |
|
61 | + public function getType(): int; |
|
62 | 62 | |
63 | 63 | |
64 | - /** |
|
65 | - * Get the field to apply query |
|
66 | - * |
|
67 | - * @return string |
|
68 | - * @since 17.0.0 |
|
69 | - */ |
|
70 | - public function getField(): string; |
|
64 | + /** |
|
65 | + * Get the field to apply query |
|
66 | + * |
|
67 | + * @return string |
|
68 | + * @since 17.0.0 |
|
69 | + */ |
|
70 | + public function getField(): string; |
|
71 | 71 | |
72 | - /** |
|
73 | - * Set the field to apply query |
|
74 | - * |
|
75 | - * @param string $field |
|
76 | - * |
|
77 | - * @return ISearchRequestSimpleQuery |
|
78 | - * @since 17.0.0 |
|
79 | - */ |
|
80 | - public function setField(string $field): ISearchRequestSimpleQuery; |
|
72 | + /** |
|
73 | + * Set the field to apply query |
|
74 | + * |
|
75 | + * @param string $field |
|
76 | + * |
|
77 | + * @return ISearchRequestSimpleQuery |
|
78 | + * @since 17.0.0 |
|
79 | + */ |
|
80 | + public function setField(string $field): ISearchRequestSimpleQuery; |
|
81 | 81 | |
82 | 82 | |
83 | - /** |
|
84 | - * Get the all values to compare |
|
85 | - * |
|
86 | - * @return array |
|
87 | - * @since 17.0.0 |
|
88 | - */ |
|
89 | - public function getValues(): array; |
|
83 | + /** |
|
84 | + * Get the all values to compare |
|
85 | + * |
|
86 | + * @return array |
|
87 | + * @since 17.0.0 |
|
88 | + */ |
|
89 | + public function getValues(): array; |
|
90 | 90 | |
91 | - /** |
|
92 | - * Add value to compare (string) |
|
93 | - * |
|
94 | - * @param string $value |
|
95 | - * |
|
96 | - * @return ISearchRequestSimpleQuery |
|
97 | - * @since 17.0.0 |
|
98 | - */ |
|
99 | - public function addValue(string $value): ISearchRequestSimpleQuery; |
|
91 | + /** |
|
92 | + * Add value to compare (string) |
|
93 | + * |
|
94 | + * @param string $value |
|
95 | + * |
|
96 | + * @return ISearchRequestSimpleQuery |
|
97 | + * @since 17.0.0 |
|
98 | + */ |
|
99 | + public function addValue(string $value): ISearchRequestSimpleQuery; |
|
100 | 100 | |
101 | - /** |
|
102 | - * Add value to compare (int) |
|
103 | - * |
|
104 | - * @param int $value |
|
105 | - * |
|
106 | - * @return ISearchRequestSimpleQuery |
|
107 | - * @since 17.0.0 |
|
108 | - */ |
|
109 | - public function addValueInt(int $value): ISearchRequestSimpleQuery; |
|
101 | + /** |
|
102 | + * Add value to compare (int) |
|
103 | + * |
|
104 | + * @param int $value |
|
105 | + * |
|
106 | + * @return ISearchRequestSimpleQuery |
|
107 | + * @since 17.0.0 |
|
108 | + */ |
|
109 | + public function addValueInt(int $value): ISearchRequestSimpleQuery; |
|
110 | 110 | |
111 | - /** |
|
112 | - * Add value to compare (array) |
|
113 | - * |
|
114 | - * @param array $value |
|
115 | - * |
|
116 | - * @return ISearchRequestSimpleQuery |
|
117 | - * @since 17.0.0 |
|
118 | - */ |
|
119 | - public function addValueArray(array $value): ISearchRequestSimpleQuery; |
|
111 | + /** |
|
112 | + * Add value to compare (array) |
|
113 | + * |
|
114 | + * @param array $value |
|
115 | + * |
|
116 | + * @return ISearchRequestSimpleQuery |
|
117 | + * @since 17.0.0 |
|
118 | + */ |
|
119 | + public function addValueArray(array $value): ISearchRequestSimpleQuery; |
|
120 | 120 | |
121 | - /** |
|
122 | - * Add value to compare (bool) |
|
123 | - * |
|
124 | - * @param bool $value |
|
125 | - * |
|
126 | - * @return ISearchRequestSimpleQuery |
|
127 | - * @since 17.0.0 |
|
128 | - */ |
|
129 | - public function addValueBool(bool $value): ISearchRequestSimpleQuery; |
|
121 | + /** |
|
122 | + * Add value to compare (bool) |
|
123 | + * |
|
124 | + * @param bool $value |
|
125 | + * |
|
126 | + * @return ISearchRequestSimpleQuery |
|
127 | + * @since 17.0.0 |
|
128 | + */ |
|
129 | + public function addValueBool(bool $value): ISearchRequestSimpleQuery; |
|
130 | 130 | } |
@@ -41,92 +41,92 @@ |
||
41 | 41 | * |
42 | 42 | */ |
43 | 43 | interface IRunner { |
44 | - public const RESULT_TYPE_SUCCESS = 1; |
|
45 | - public const RESULT_TYPE_WARNING = 4; |
|
46 | - public const RESULT_TYPE_FAIL = 9; |
|
44 | + public const RESULT_TYPE_SUCCESS = 1; |
|
45 | + public const RESULT_TYPE_WARNING = 4; |
|
46 | + public const RESULT_TYPE_FAIL = 9; |
|
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * Info are displayed in the user interface when an admin execute the |
|
51 | - * ./occ fulltextsearch:index command. |
|
52 | - * |
|
53 | - * quick list of info that can be edited: |
|
54 | - * 'documentId', 'info', 'title', 'resultIndex', 'resultStatus', |
|
55 | - * 'content', 'documentCurrent', 'documentTotal', 'progressStatus', |
|
56 | - * 'errorCurrent', 'errorException', 'errorIndex'. |
|
57 | - * |
|
58 | - * List of all editable info can be find in the Command\Index.php of the |
|
59 | - * FullTextSearch app. |
|
60 | - * (look for a comment 'full list of info that can be edited') |
|
61 | - * |
|
62 | - * @since 15.0.0 |
|
63 | - * |
|
64 | - * @param string $info |
|
65 | - * @param string $value |
|
66 | - */ |
|
67 | - public function setInfo(string $info, string $value); |
|
49 | + /** |
|
50 | + * Info are displayed in the user interface when an admin execute the |
|
51 | + * ./occ fulltextsearch:index command. |
|
52 | + * |
|
53 | + * quick list of info that can be edited: |
|
54 | + * 'documentId', 'info', 'title', 'resultIndex', 'resultStatus', |
|
55 | + * 'content', 'documentCurrent', 'documentTotal', 'progressStatus', |
|
56 | + * 'errorCurrent', 'errorException', 'errorIndex'. |
|
57 | + * |
|
58 | + * List of all editable info can be find in the Command\Index.php of the |
|
59 | + * FullTextSearch app. |
|
60 | + * (look for a comment 'full list of info that can be edited') |
|
61 | + * |
|
62 | + * @since 15.0.0 |
|
63 | + * |
|
64 | + * @param string $info |
|
65 | + * @param string $value |
|
66 | + */ |
|
67 | + public function setInfo(string $info, string $value); |
|
68 | 68 | |
69 | 69 | |
70 | - /** |
|
71 | - * This method should be used when editing multiple info to avoid too many |
|
72 | - * refresh of the interface. |
|
73 | - * |
|
74 | - * @since 15.0.0 |
|
75 | - * |
|
76 | - * @param array $data |
|
77 | - */ |
|
78 | - public function setInfoArray(array $data); |
|
70 | + /** |
|
71 | + * This method should be used when editing multiple info to avoid too many |
|
72 | + * refresh of the interface. |
|
73 | + * |
|
74 | + * @since 15.0.0 |
|
75 | + * |
|
76 | + * @param array $data |
|
77 | + */ |
|
78 | + public function setInfoArray(array $data); |
|
79 | 79 | |
80 | 80 | |
81 | - /** |
|
82 | - * Method used to update the current Action when an index is running. |
|
83 | - * |
|
84 | - * This method should be used instead of manually update the 'action' using |
|
85 | - * setInfo()/setInfoArray() as it is also used to keep the process alive, |
|
86 | - * manage the input, and some statistics of the load of the process. |
|
87 | - * |
|
88 | - * $action is a string with no space |
|
89 | - * $force should be set to true if the action is heavy while being executed |
|
90 | - * multiple times |
|
91 | - * |
|
92 | - * @since 15.0.0 |
|
93 | - * |
|
94 | - * @param string $action |
|
95 | - * @param bool $force |
|
96 | - * |
|
97 | - * @return string |
|
98 | - * @throws \Exception |
|
99 | - */ |
|
100 | - public function updateAction(string $action = '', bool $force = false): string; |
|
81 | + /** |
|
82 | + * Method used to update the current Action when an index is running. |
|
83 | + * |
|
84 | + * This method should be used instead of manually update the 'action' using |
|
85 | + * setInfo()/setInfoArray() as it is also used to keep the process alive, |
|
86 | + * manage the input, and some statistics of the load of the process. |
|
87 | + * |
|
88 | + * $action is a string with no space |
|
89 | + * $force should be set to true if the action is heavy while being executed |
|
90 | + * multiple times |
|
91 | + * |
|
92 | + * @since 15.0.0 |
|
93 | + * |
|
94 | + * @param string $action |
|
95 | + * @param bool $force |
|
96 | + * |
|
97 | + * @return string |
|
98 | + * @throws \Exception |
|
99 | + */ |
|
100 | + public function updateAction(string $action = '', bool $force = false): string; |
|
101 | 101 | |
102 | 102 | |
103 | - /** |
|
104 | - * Call this method in a Search Platform or Content Provider if there is an |
|
105 | - * issue while generating a document or while indexing the current document. |
|
106 | - * This is used to store and display errors in the UI during an index to help |
|
107 | - * admin to keep track of errors. |
|
108 | - * |
|
109 | - * @since 15.0.0 |
|
110 | - * |
|
111 | - * @param IIndex $index |
|
112 | - * @param string $message |
|
113 | - * @param string $class |
|
114 | - * @param int $sev |
|
115 | - */ |
|
116 | - public function newIndexError(IIndex $index, string $message, string $class = '', int $sev = 3); |
|
103 | + /** |
|
104 | + * Call this method in a Search Platform or Content Provider if there is an |
|
105 | + * issue while generating a document or while indexing the current document. |
|
106 | + * This is used to store and display errors in the UI during an index to help |
|
107 | + * admin to keep track of errors. |
|
108 | + * |
|
109 | + * @since 15.0.0 |
|
110 | + * |
|
111 | + * @param IIndex $index |
|
112 | + * @param string $message |
|
113 | + * @param string $class |
|
114 | + * @param int $sev |
|
115 | + */ |
|
116 | + public function newIndexError(IIndex $index, string $message, string $class = '', int $sev = 3); |
|
117 | 117 | |
118 | 118 | |
119 | - /** |
|
120 | - * Call this method only in a Search Platform after an index of a document. |
|
121 | - * This is used to store and display results (good or bad) in the UI during |
|
122 | - * an index to help admin to keep track of fail and successful indexes. |
|
123 | - * |
|
124 | - * @since 15.0.0 |
|
125 | - * |
|
126 | - * @param IIndex $index |
|
127 | - * @param string $message |
|
128 | - * @param string $status |
|
129 | - * @param int $type |
|
130 | - */ |
|
131 | - public function newIndexResult(IIndex $index, string $message, string $status, int $type); |
|
119 | + /** |
|
120 | + * Call this method only in a Search Platform after an index of a document. |
|
121 | + * This is used to store and display results (good or bad) in the UI during |
|
122 | + * an index to help admin to keep track of fail and successful indexes. |
|
123 | + * |
|
124 | + * @since 15.0.0 |
|
125 | + * |
|
126 | + * @param IIndex $index |
|
127 | + * @param string $message |
|
128 | + * @param string $status |
|
129 | + * @param int $type |
|
130 | + */ |
|
131 | + public function newIndexResult(IIndex $index, string $message, string $status, int $type); |
|
132 | 132 | } |
@@ -42,585 +42,585 @@ |
||
42 | 42 | * @since 15.0.0 |
43 | 43 | */ |
44 | 44 | interface IIndexDocument { |
45 | - public const NOT_ENCODED = 0; |
|
46 | - public const ENCODED_BASE64 = 1; |
|
47 | - |
|
48 | - |
|
49 | - |
|
50 | - /** |
|
51 | - * Returns the Id of the original document. |
|
52 | - * |
|
53 | - * @since 15.0.0 |
|
54 | - * |
|
55 | - * @return string |
|
56 | - */ |
|
57 | - public function getId(): string; |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * Returns the Id of the provider. |
|
62 | - * |
|
63 | - * @since 15.0.0 |
|
64 | - * |
|
65 | - * @return string |
|
66 | - */ |
|
67 | - public function getProviderId(): string; |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * Set the Index related to the IIndexDocument. |
|
72 | - * |
|
73 | - * @see IIndex |
|
74 | - * |
|
75 | - * @since 15.0.0 |
|
76 | - * |
|
77 | - * @param IIndex $index |
|
78 | - * |
|
79 | - * @return IIndexDocument |
|
80 | - */ |
|
81 | - public function setIndex(IIndex $index): IIndexDocument; |
|
82 | - |
|
83 | - /** |
|
84 | - * Get the Index. |
|
85 | - * |
|
86 | - * @since 15.0.0 |
|
87 | - * |
|
88 | - * @return IIndex |
|
89 | - */ |
|
90 | - public function getIndex(): IIndex; |
|
91 | - |
|
92 | - /** |
|
93 | - * return if Index is defined. |
|
94 | - * |
|
95 | - * @since 16.0.0 |
|
96 | - * |
|
97 | - * @return bool |
|
98 | - */ |
|
99 | - public function hasIndex(): bool; |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - * Set the modified time of the original document. |
|
104 | - * |
|
105 | - * @since 15.0.0 |
|
106 | - * |
|
107 | - * @param int $modifiedTime |
|
108 | - * |
|
109 | - * @return IIndexDocument |
|
110 | - */ |
|
111 | - public function setModifiedTime(int $modifiedTime): IIndexDocument; |
|
112 | - |
|
113 | - /** |
|
114 | - * Get the modified time of the original document. |
|
115 | - * |
|
116 | - * @since 15.0.0 |
|
117 | - * |
|
118 | - * @return int |
|
119 | - */ |
|
120 | - public function getModifiedTime(): int; |
|
121 | - |
|
122 | - /** |
|
123 | - * Check if the original document of the IIndexDocument is older than $time. |
|
124 | - * |
|
125 | - * @since 15.0.0 |
|
126 | - * |
|
127 | - * @param int $time |
|
128 | - * |
|
129 | - * @return bool |
|
130 | - */ |
|
131 | - public function isOlderThan(int $time): bool; |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * Set the read rights of the original document using a IDocumentAccess. |
|
136 | - * |
|
137 | - * @see IDocumentAccess |
|
138 | - * |
|
139 | - * @since 15.0.0 |
|
140 | - * |
|
141 | - * @param IDocumentAccess $access |
|
142 | - * |
|
143 | - * @return $this |
|
144 | - */ |
|
145 | - public function setAccess(IDocumentAccess $access): IIndexDocument; |
|
146 | - |
|
147 | - /** |
|
148 | - * Get the IDocumentAccess related to the original document. |
|
149 | - * |
|
150 | - * @since 15.0.0 |
|
151 | - * |
|
152 | - * @return IDocumentAccess |
|
153 | - */ |
|
154 | - public function getAccess(): IDocumentAccess; |
|
155 | - |
|
156 | - |
|
157 | - /** |
|
158 | - * Add a tag to the list. |
|
159 | - * |
|
160 | - * @since 15.0.0 |
|
161 | - * |
|
162 | - * @param string $tag |
|
163 | - * |
|
164 | - * @return IIndexDocument |
|
165 | - */ |
|
166 | - public function addTag(string $tag): IIndexDocument; |
|
167 | - |
|
168 | - /** |
|
169 | - * Set the list of tags assigned to the original document. |
|
170 | - * |
|
171 | - * @since 15.0.0 |
|
172 | - * |
|
173 | - * @param array $tags |
|
174 | - * |
|
175 | - * @return IIndexDocument |
|
176 | - */ |
|
177 | - public function setTags(array $tags): IIndexDocument; |
|
178 | - |
|
179 | - /** |
|
180 | - * Get the list of tags assigned to the original document. |
|
181 | - * |
|
182 | - * @since 15.0.0 |
|
183 | - * |
|
184 | - * @return array |
|
185 | - */ |
|
186 | - public function getTags(): array; |
|
187 | - |
|
188 | - |
|
189 | - /** |
|
190 | - * Add a meta tag to the list. |
|
191 | - * |
|
192 | - * @since 15.0.0 |
|
193 | - * |
|
194 | - * @param string $tag |
|
195 | - * |
|
196 | - * @return IIndexDocument |
|
197 | - */ |
|
198 | - public function addMetaTag(string $tag): IIndexDocument; |
|
199 | - |
|
200 | - /** |
|
201 | - * Set the list of meta tags assigned to the original document. |
|
202 | - * |
|
203 | - * @since 15.0.0 |
|
204 | - * |
|
205 | - * @param array $tags |
|
206 | - * |
|
207 | - * @return IIndexDocument |
|
208 | - */ |
|
209 | - public function setMetaTags(array $tags): IIndexDocument; |
|
210 | - |
|
211 | - /** |
|
212 | - * Get the list of meta tags assigned to the original document. |
|
213 | - * |
|
214 | - * @since 15.0.0 |
|
215 | - * |
|
216 | - * @return array |
|
217 | - */ |
|
218 | - public function getMetaTags(): array; |
|
219 | - |
|
220 | - |
|
221 | - /** |
|
222 | - * Add a sub tag to the list. |
|
223 | - * |
|
224 | - * @since 15.0.0 |
|
225 | - * |
|
226 | - * @param string $sub |
|
227 | - * @param string $tag |
|
228 | - * |
|
229 | - * @return IIndexDocument |
|
230 | - */ |
|
231 | - public function addSubTag(string $sub, string $tag): IIndexDocument; |
|
232 | - |
|
233 | - /** |
|
234 | - * Set the list of sub tags assigned to the original document. |
|
235 | - * |
|
236 | - * @since 15.0.0 |
|
237 | - * |
|
238 | - * @param array $tags |
|
239 | - * |
|
240 | - * @return IIndexDocument |
|
241 | - */ |
|
242 | - public function setSubTags(array $tags): IIndexDocument; |
|
243 | - |
|
244 | - /** |
|
245 | - * Get the list of sub tags assigned to the original document. |
|
246 | - * If $formatted is true, the result will be formatted in a one |
|
247 | - * dimensional array. |
|
248 | - * |
|
249 | - * @since 15.0.0 |
|
250 | - * |
|
251 | - * @param bool $formatted |
|
252 | - * |
|
253 | - * @return array |
|
254 | - */ |
|
255 | - public function getSubTags(bool $formatted = false): array; |
|
256 | - |
|
257 | - |
|
258 | - /** |
|
259 | - * Set the source of the original document. |
|
260 | - * |
|
261 | - * @since 15.0.0 |
|
262 | - * |
|
263 | - * @param string $source |
|
264 | - * |
|
265 | - * @return IIndexDocument |
|
266 | - */ |
|
267 | - public function setSource(string $source): IIndexDocument; |
|
268 | - |
|
269 | - /** |
|
270 | - * Get the source of the original document. |
|
271 | - * |
|
272 | - * @since 15.0.0 |
|
273 | - * |
|
274 | - * @return string |
|
275 | - */ |
|
276 | - public function getSource(): string; |
|
277 | - |
|
278 | - |
|
279 | - /** |
|
280 | - * Set the title of the original document. |
|
281 | - * |
|
282 | - * @since 15.0.0 |
|
283 | - * |
|
284 | - * @param string $title |
|
285 | - * |
|
286 | - * @return IIndexDocument |
|
287 | - */ |
|
288 | - public function setTitle(string $title): IIndexDocument; |
|
289 | - |
|
290 | - /** |
|
291 | - * Get the title of the original document. |
|
292 | - * |
|
293 | - * @since 15.0.0 |
|
294 | - * |
|
295 | - * @return string |
|
296 | - */ |
|
297 | - public function getTitle(): string; |
|
298 | - |
|
299 | - |
|
300 | - /** |
|
301 | - * Set the content of the document. |
|
302 | - * $encoded can be NOT_ENCODED or ENCODED_BASE64 if the content is raw or |
|
303 | - * encoded in base64. |
|
304 | - * |
|
305 | - * @since 15.0.0 |
|
306 | - * |
|
307 | - * @param string $content |
|
308 | - * @param int $encoded |
|
309 | - * |
|
310 | - * @return IIndexDocument |
|
311 | - */ |
|
312 | - public function setContent(string $content, int $encoded = 0): IIndexDocument; |
|
313 | - |
|
314 | - /** |
|
315 | - * Get the content of the original document. |
|
316 | - * |
|
317 | - * @since 15.0.0 |
|
318 | - * |
|
319 | - * @return string |
|
320 | - */ |
|
321 | - public function getContent(): string; |
|
322 | - |
|
323 | - /** |
|
324 | - * Returns the type of the encoding on the content. |
|
325 | - * |
|
326 | - * @since 15.0.0 |
|
327 | - * |
|
328 | - * @return int |
|
329 | - */ |
|
330 | - public function isContentEncoded(): int; |
|
331 | - |
|
332 | - /** |
|
333 | - * Return the size of the content. |
|
334 | - * |
|
335 | - * @since 15.0.0 |
|
336 | - * |
|
337 | - * @return int |
|
338 | - */ |
|
339 | - public function getContentSize(): int; |
|
340 | - |
|
341 | - |
|
342 | - /** |
|
343 | - * Generate an hash, based on the content of the original document. |
|
344 | - * |
|
345 | - * @since 15.0.0 |
|
346 | - * |
|
347 | - * @return IIndexDocument |
|
348 | - */ |
|
349 | - public function initHash(): IIndexDocument; |
|
350 | - |
|
351 | - /** |
|
352 | - * Set the hash of the original document. |
|
353 | - * |
|
354 | - * @since 15.0.0 |
|
355 | - * |
|
356 | - * @param string $hash |
|
357 | - * |
|
358 | - * @return IIndexDocument |
|
359 | - */ |
|
360 | - public function setHash(string $hash): IIndexDocument; |
|
361 | - |
|
362 | - /** |
|
363 | - * Get the hash of the original document. |
|
364 | - * |
|
365 | - * @since 15.0.0 |
|
366 | - * |
|
367 | - * @return string |
|
368 | - */ |
|
369 | - public function getHash(): string; |
|
370 | - |
|
371 | - |
|
372 | - /** |
|
373 | - * Add a part, identified by a string, and its content. |
|
374 | - * |
|
375 | - * It is strongly advised to use alphanumerical chars with no space in the |
|
376 | - * $part string. |
|
377 | - * |
|
378 | - * @since 15.0.0 |
|
379 | - * |
|
380 | - * @param string $part |
|
381 | - * @param string $content |
|
382 | - * |
|
383 | - * @return IIndexDocument |
|
384 | - */ |
|
385 | - public function addPart(string $part, string $content): IIndexDocument; |
|
386 | - |
|
387 | - /** |
|
388 | - * Set all parts and their content. |
|
389 | - * |
|
390 | - * @since 15.0.0 |
|
391 | - * |
|
392 | - * @param array $parts |
|
393 | - * |
|
394 | - * @return IIndexDocument |
|
395 | - */ |
|
396 | - public function setParts(array $parts): IIndexDocument; |
|
397 | - |
|
398 | - /** |
|
399 | - * Get all parts of the IIndexDocument. |
|
400 | - * |
|
401 | - * @since 15.0.0 |
|
402 | - * |
|
403 | - * @return array |
|
404 | - */ |
|
405 | - public function getParts(): array; |
|
406 | - |
|
407 | - |
|
408 | - /** |
|
409 | - * Add a link, usable by the frontend. |
|
410 | - * |
|
411 | - * @since 15.0.0 |
|
412 | - * |
|
413 | - * @param string $link |
|
414 | - * |
|
415 | - * @return IIndexDocument |
|
416 | - */ |
|
417 | - public function setLink(string $link): IIndexDocument; |
|
418 | - |
|
419 | - /** |
|
420 | - * Get the link. |
|
421 | - * |
|
422 | - * @since 15.0.0 |
|
423 | - * |
|
424 | - * @return string |
|
425 | - */ |
|
426 | - public function getLink(): string; |
|
427 | - |
|
428 | - |
|
429 | - /** |
|
430 | - * Set more information that couldn't be set using other method. |
|
431 | - * |
|
432 | - * @since 15.0.0 |
|
433 | - * |
|
434 | - * @param array $more |
|
435 | - * |
|
436 | - * @return IIndexDocument |
|
437 | - */ |
|
438 | - public function setMore(array $more): IIndexDocument; |
|
439 | - |
|
440 | - /** |
|
441 | - * Get more information. |
|
442 | - * |
|
443 | - * @since 15.0.0 |
|
444 | - * |
|
445 | - * @return array |
|
446 | - */ |
|
447 | - public function getMore(): array; |
|
448 | - |
|
449 | - |
|
450 | - /** |
|
451 | - * Add some excerpt of the content of the original document, usually based |
|
452 | - * on the search request. |
|
453 | - * |
|
454 | - * @since 16.0.0 |
|
455 | - * |
|
456 | - * @param string $source |
|
457 | - * @param string $excerpt |
|
458 | - * |
|
459 | - * @return IIndexDocument |
|
460 | - */ |
|
461 | - public function addExcerpt(string $source, string $excerpt): IIndexDocument; |
|
462 | - |
|
463 | - /** |
|
464 | - * Set all excerpts of the content of the original document. |
|
465 | - * |
|
466 | - * @since 16.0.0 |
|
467 | - * |
|
468 | - * @param array $excerpts |
|
469 | - * |
|
470 | - * @return IIndexDocument |
|
471 | - */ |
|
472 | - public function setExcerpts(array $excerpts): IIndexDocument; |
|
473 | - |
|
474 | - /** |
|
475 | - * Get all excerpts of the content of the original document. |
|
476 | - * |
|
477 | - * @since 15.0.0 |
|
478 | - * |
|
479 | - * @return array |
|
480 | - */ |
|
481 | - public function getExcerpts(): array; |
|
482 | - |
|
483 | - |
|
484 | - /** |
|
485 | - * Set the score to the result assigned to this document during a search |
|
486 | - * request. |
|
487 | - * |
|
488 | - * @since 15.0.0 |
|
489 | - * |
|
490 | - * @param string $score |
|
491 | - * |
|
492 | - * @return IIndexDocument |
|
493 | - */ |
|
494 | - public function setScore(string $score): IIndexDocument; |
|
495 | - |
|
496 | - /** |
|
497 | - * Get the score. |
|
498 | - * |
|
499 | - * @since 15.0.0 |
|
500 | - * |
|
501 | - * @return string |
|
502 | - */ |
|
503 | - public function getScore(): string; |
|
504 | - |
|
505 | - |
|
506 | - /** |
|
507 | - * Set some information about the original document that will be available |
|
508 | - * to the front-end when displaying search result. (as string) |
|
509 | - * Because this information will not be indexed, this method can also be |
|
510 | - * used to manage some data while filling the IIndexDocument before its |
|
511 | - * indexing. |
|
512 | - * |
|
513 | - * @since 15.0.0 |
|
514 | - * |
|
515 | - * @param string $info |
|
516 | - * @param string $value |
|
517 | - * |
|
518 | - * @return IIndexDocument |
|
519 | - */ |
|
520 | - public function setInfo(string $info, string $value): IIndexDocument; |
|
521 | - |
|
522 | - /** |
|
523 | - * Get an information about a document. (string) |
|
524 | - * |
|
525 | - * @since 15.0.0 |
|
526 | - * |
|
527 | - * @param string $info |
|
528 | - * @param string $default |
|
529 | - * |
|
530 | - * @return string |
|
531 | - */ |
|
532 | - public function getInfo(string $info, string $default = ''): string; |
|
533 | - |
|
534 | - /** |
|
535 | - * Set some information about the original document that will be available |
|
536 | - * to the front-end when displaying search result. (as array) |
|
537 | - * Because this information will not be indexed, this method can also be |
|
538 | - * used to manage some data while filling the IIndexDocument before its |
|
539 | - * indexing. |
|
540 | - * |
|
541 | - * @since 15.0.0 |
|
542 | - * |
|
543 | - * @param string $info |
|
544 | - * @param array $value |
|
545 | - * |
|
546 | - * @return IIndexDocument |
|
547 | - */ |
|
548 | - public function setInfoArray(string $info, array $value): IIndexDocument; |
|
549 | - |
|
550 | - /** |
|
551 | - * Get an information about a document. (array) |
|
552 | - * |
|
553 | - * @since 15.0.0 |
|
554 | - * |
|
555 | - * @param string $info |
|
556 | - * @param array $default |
|
557 | - * |
|
558 | - * @return array |
|
559 | - */ |
|
560 | - public function getInfoArray(string $info, array $default = []): array; |
|
561 | - |
|
562 | - /** |
|
563 | - * Set some information about the original document that will be available |
|
564 | - * to the front-end when displaying search result. (as int) |
|
565 | - * Because this information will not be indexed, this method can also be |
|
566 | - * used to manage some data while filling the IIndexDocument before its |
|
567 | - * indexing. |
|
568 | - * |
|
569 | - * @since 15.0.0 |
|
570 | - * |
|
571 | - * @param string $info |
|
572 | - * @param int $value |
|
573 | - * |
|
574 | - * @return IIndexDocument |
|
575 | - */ |
|
576 | - public function setInfoInt(string $info, int $value): IIndexDocument; |
|
577 | - |
|
578 | - /** |
|
579 | - * Get an information about a document. (int) |
|
580 | - * |
|
581 | - * @since 15.0.0 |
|
582 | - * |
|
583 | - * @param string $info |
|
584 | - * @param int $default |
|
585 | - * |
|
586 | - * @return int |
|
587 | - */ |
|
588 | - public function getInfoInt(string $info, int $default = 0): int; |
|
589 | - |
|
590 | - /** |
|
591 | - * Set some information about the original document that will be available |
|
592 | - * to the front-end when displaying search result. (as bool) |
|
593 | - * Because this information will not be indexed, this method can also be |
|
594 | - * used to manage some data while filling the IIndexDocument before its |
|
595 | - * indexing. |
|
596 | - * |
|
597 | - * @since 15.0.0 |
|
598 | - * |
|
599 | - * @param string $info |
|
600 | - * @param bool $value |
|
601 | - * |
|
602 | - * @return IIndexDocument |
|
603 | - */ |
|
604 | - public function setInfoBool(string $info, bool $value): IIndexDocument; |
|
605 | - |
|
606 | - /** |
|
607 | - * Get an information about a document. (bool) |
|
608 | - * |
|
609 | - * @since 15.0.0 |
|
610 | - * |
|
611 | - * @param string $info |
|
612 | - * @param bool $default |
|
613 | - * |
|
614 | - * @return bool |
|
615 | - */ |
|
616 | - public function getInfoBool(string $info, bool $default = false): bool; |
|
617 | - |
|
618 | - /** |
|
619 | - * Get all info. |
|
620 | - * |
|
621 | - * @since 15.0.0 |
|
622 | - * |
|
623 | - * @return array |
|
624 | - */ |
|
625 | - public function getInfoAll(): array; |
|
45 | + public const NOT_ENCODED = 0; |
|
46 | + public const ENCODED_BASE64 = 1; |
|
47 | + |
|
48 | + |
|
49 | + |
|
50 | + /** |
|
51 | + * Returns the Id of the original document. |
|
52 | + * |
|
53 | + * @since 15.0.0 |
|
54 | + * |
|
55 | + * @return string |
|
56 | + */ |
|
57 | + public function getId(): string; |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * Returns the Id of the provider. |
|
62 | + * |
|
63 | + * @since 15.0.0 |
|
64 | + * |
|
65 | + * @return string |
|
66 | + */ |
|
67 | + public function getProviderId(): string; |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * Set the Index related to the IIndexDocument. |
|
72 | + * |
|
73 | + * @see IIndex |
|
74 | + * |
|
75 | + * @since 15.0.0 |
|
76 | + * |
|
77 | + * @param IIndex $index |
|
78 | + * |
|
79 | + * @return IIndexDocument |
|
80 | + */ |
|
81 | + public function setIndex(IIndex $index): IIndexDocument; |
|
82 | + |
|
83 | + /** |
|
84 | + * Get the Index. |
|
85 | + * |
|
86 | + * @since 15.0.0 |
|
87 | + * |
|
88 | + * @return IIndex |
|
89 | + */ |
|
90 | + public function getIndex(): IIndex; |
|
91 | + |
|
92 | + /** |
|
93 | + * return if Index is defined. |
|
94 | + * |
|
95 | + * @since 16.0.0 |
|
96 | + * |
|
97 | + * @return bool |
|
98 | + */ |
|
99 | + public function hasIndex(): bool; |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + * Set the modified time of the original document. |
|
104 | + * |
|
105 | + * @since 15.0.0 |
|
106 | + * |
|
107 | + * @param int $modifiedTime |
|
108 | + * |
|
109 | + * @return IIndexDocument |
|
110 | + */ |
|
111 | + public function setModifiedTime(int $modifiedTime): IIndexDocument; |
|
112 | + |
|
113 | + /** |
|
114 | + * Get the modified time of the original document. |
|
115 | + * |
|
116 | + * @since 15.0.0 |
|
117 | + * |
|
118 | + * @return int |
|
119 | + */ |
|
120 | + public function getModifiedTime(): int; |
|
121 | + |
|
122 | + /** |
|
123 | + * Check if the original document of the IIndexDocument is older than $time. |
|
124 | + * |
|
125 | + * @since 15.0.0 |
|
126 | + * |
|
127 | + * @param int $time |
|
128 | + * |
|
129 | + * @return bool |
|
130 | + */ |
|
131 | + public function isOlderThan(int $time): bool; |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * Set the read rights of the original document using a IDocumentAccess. |
|
136 | + * |
|
137 | + * @see IDocumentAccess |
|
138 | + * |
|
139 | + * @since 15.0.0 |
|
140 | + * |
|
141 | + * @param IDocumentAccess $access |
|
142 | + * |
|
143 | + * @return $this |
|
144 | + */ |
|
145 | + public function setAccess(IDocumentAccess $access): IIndexDocument; |
|
146 | + |
|
147 | + /** |
|
148 | + * Get the IDocumentAccess related to the original document. |
|
149 | + * |
|
150 | + * @since 15.0.0 |
|
151 | + * |
|
152 | + * @return IDocumentAccess |
|
153 | + */ |
|
154 | + public function getAccess(): IDocumentAccess; |
|
155 | + |
|
156 | + |
|
157 | + /** |
|
158 | + * Add a tag to the list. |
|
159 | + * |
|
160 | + * @since 15.0.0 |
|
161 | + * |
|
162 | + * @param string $tag |
|
163 | + * |
|
164 | + * @return IIndexDocument |
|
165 | + */ |
|
166 | + public function addTag(string $tag): IIndexDocument; |
|
167 | + |
|
168 | + /** |
|
169 | + * Set the list of tags assigned to the original document. |
|
170 | + * |
|
171 | + * @since 15.0.0 |
|
172 | + * |
|
173 | + * @param array $tags |
|
174 | + * |
|
175 | + * @return IIndexDocument |
|
176 | + */ |
|
177 | + public function setTags(array $tags): IIndexDocument; |
|
178 | + |
|
179 | + /** |
|
180 | + * Get the list of tags assigned to the original document. |
|
181 | + * |
|
182 | + * @since 15.0.0 |
|
183 | + * |
|
184 | + * @return array |
|
185 | + */ |
|
186 | + public function getTags(): array; |
|
187 | + |
|
188 | + |
|
189 | + /** |
|
190 | + * Add a meta tag to the list. |
|
191 | + * |
|
192 | + * @since 15.0.0 |
|
193 | + * |
|
194 | + * @param string $tag |
|
195 | + * |
|
196 | + * @return IIndexDocument |
|
197 | + */ |
|
198 | + public function addMetaTag(string $tag): IIndexDocument; |
|
199 | + |
|
200 | + /** |
|
201 | + * Set the list of meta tags assigned to the original document. |
|
202 | + * |
|
203 | + * @since 15.0.0 |
|
204 | + * |
|
205 | + * @param array $tags |
|
206 | + * |
|
207 | + * @return IIndexDocument |
|
208 | + */ |
|
209 | + public function setMetaTags(array $tags): IIndexDocument; |
|
210 | + |
|
211 | + /** |
|
212 | + * Get the list of meta tags assigned to the original document. |
|
213 | + * |
|
214 | + * @since 15.0.0 |
|
215 | + * |
|
216 | + * @return array |
|
217 | + */ |
|
218 | + public function getMetaTags(): array; |
|
219 | + |
|
220 | + |
|
221 | + /** |
|
222 | + * Add a sub tag to the list. |
|
223 | + * |
|
224 | + * @since 15.0.0 |
|
225 | + * |
|
226 | + * @param string $sub |
|
227 | + * @param string $tag |
|
228 | + * |
|
229 | + * @return IIndexDocument |
|
230 | + */ |
|
231 | + public function addSubTag(string $sub, string $tag): IIndexDocument; |
|
232 | + |
|
233 | + /** |
|
234 | + * Set the list of sub tags assigned to the original document. |
|
235 | + * |
|
236 | + * @since 15.0.0 |
|
237 | + * |
|
238 | + * @param array $tags |
|
239 | + * |
|
240 | + * @return IIndexDocument |
|
241 | + */ |
|
242 | + public function setSubTags(array $tags): IIndexDocument; |
|
243 | + |
|
244 | + /** |
|
245 | + * Get the list of sub tags assigned to the original document. |
|
246 | + * If $formatted is true, the result will be formatted in a one |
|
247 | + * dimensional array. |
|
248 | + * |
|
249 | + * @since 15.0.0 |
|
250 | + * |
|
251 | + * @param bool $formatted |
|
252 | + * |
|
253 | + * @return array |
|
254 | + */ |
|
255 | + public function getSubTags(bool $formatted = false): array; |
|
256 | + |
|
257 | + |
|
258 | + /** |
|
259 | + * Set the source of the original document. |
|
260 | + * |
|
261 | + * @since 15.0.0 |
|
262 | + * |
|
263 | + * @param string $source |
|
264 | + * |
|
265 | + * @return IIndexDocument |
|
266 | + */ |
|
267 | + public function setSource(string $source): IIndexDocument; |
|
268 | + |
|
269 | + /** |
|
270 | + * Get the source of the original document. |
|
271 | + * |
|
272 | + * @since 15.0.0 |
|
273 | + * |
|
274 | + * @return string |
|
275 | + */ |
|
276 | + public function getSource(): string; |
|
277 | + |
|
278 | + |
|
279 | + /** |
|
280 | + * Set the title of the original document. |
|
281 | + * |
|
282 | + * @since 15.0.0 |
|
283 | + * |
|
284 | + * @param string $title |
|
285 | + * |
|
286 | + * @return IIndexDocument |
|
287 | + */ |
|
288 | + public function setTitle(string $title): IIndexDocument; |
|
289 | + |
|
290 | + /** |
|
291 | + * Get the title of the original document. |
|
292 | + * |
|
293 | + * @since 15.0.0 |
|
294 | + * |
|
295 | + * @return string |
|
296 | + */ |
|
297 | + public function getTitle(): string; |
|
298 | + |
|
299 | + |
|
300 | + /** |
|
301 | + * Set the content of the document. |
|
302 | + * $encoded can be NOT_ENCODED or ENCODED_BASE64 if the content is raw or |
|
303 | + * encoded in base64. |
|
304 | + * |
|
305 | + * @since 15.0.0 |
|
306 | + * |
|
307 | + * @param string $content |
|
308 | + * @param int $encoded |
|
309 | + * |
|
310 | + * @return IIndexDocument |
|
311 | + */ |
|
312 | + public function setContent(string $content, int $encoded = 0): IIndexDocument; |
|
313 | + |
|
314 | + /** |
|
315 | + * Get the content of the original document. |
|
316 | + * |
|
317 | + * @since 15.0.0 |
|
318 | + * |
|
319 | + * @return string |
|
320 | + */ |
|
321 | + public function getContent(): string; |
|
322 | + |
|
323 | + /** |
|
324 | + * Returns the type of the encoding on the content. |
|
325 | + * |
|
326 | + * @since 15.0.0 |
|
327 | + * |
|
328 | + * @return int |
|
329 | + */ |
|
330 | + public function isContentEncoded(): int; |
|
331 | + |
|
332 | + /** |
|
333 | + * Return the size of the content. |
|
334 | + * |
|
335 | + * @since 15.0.0 |
|
336 | + * |
|
337 | + * @return int |
|
338 | + */ |
|
339 | + public function getContentSize(): int; |
|
340 | + |
|
341 | + |
|
342 | + /** |
|
343 | + * Generate an hash, based on the content of the original document. |
|
344 | + * |
|
345 | + * @since 15.0.0 |
|
346 | + * |
|
347 | + * @return IIndexDocument |
|
348 | + */ |
|
349 | + public function initHash(): IIndexDocument; |
|
350 | + |
|
351 | + /** |
|
352 | + * Set the hash of the original document. |
|
353 | + * |
|
354 | + * @since 15.0.0 |
|
355 | + * |
|
356 | + * @param string $hash |
|
357 | + * |
|
358 | + * @return IIndexDocument |
|
359 | + */ |
|
360 | + public function setHash(string $hash): IIndexDocument; |
|
361 | + |
|
362 | + /** |
|
363 | + * Get the hash of the original document. |
|
364 | + * |
|
365 | + * @since 15.0.0 |
|
366 | + * |
|
367 | + * @return string |
|
368 | + */ |
|
369 | + public function getHash(): string; |
|
370 | + |
|
371 | + |
|
372 | + /** |
|
373 | + * Add a part, identified by a string, and its content. |
|
374 | + * |
|
375 | + * It is strongly advised to use alphanumerical chars with no space in the |
|
376 | + * $part string. |
|
377 | + * |
|
378 | + * @since 15.0.0 |
|
379 | + * |
|
380 | + * @param string $part |
|
381 | + * @param string $content |
|
382 | + * |
|
383 | + * @return IIndexDocument |
|
384 | + */ |
|
385 | + public function addPart(string $part, string $content): IIndexDocument; |
|
386 | + |
|
387 | + /** |
|
388 | + * Set all parts and their content. |
|
389 | + * |
|
390 | + * @since 15.0.0 |
|
391 | + * |
|
392 | + * @param array $parts |
|
393 | + * |
|
394 | + * @return IIndexDocument |
|
395 | + */ |
|
396 | + public function setParts(array $parts): IIndexDocument; |
|
397 | + |
|
398 | + /** |
|
399 | + * Get all parts of the IIndexDocument. |
|
400 | + * |
|
401 | + * @since 15.0.0 |
|
402 | + * |
|
403 | + * @return array |
|
404 | + */ |
|
405 | + public function getParts(): array; |
|
406 | + |
|
407 | + |
|
408 | + /** |
|
409 | + * Add a link, usable by the frontend. |
|
410 | + * |
|
411 | + * @since 15.0.0 |
|
412 | + * |
|
413 | + * @param string $link |
|
414 | + * |
|
415 | + * @return IIndexDocument |
|
416 | + */ |
|
417 | + public function setLink(string $link): IIndexDocument; |
|
418 | + |
|
419 | + /** |
|
420 | + * Get the link. |
|
421 | + * |
|
422 | + * @since 15.0.0 |
|
423 | + * |
|
424 | + * @return string |
|
425 | + */ |
|
426 | + public function getLink(): string; |
|
427 | + |
|
428 | + |
|
429 | + /** |
|
430 | + * Set more information that couldn't be set using other method. |
|
431 | + * |
|
432 | + * @since 15.0.0 |
|
433 | + * |
|
434 | + * @param array $more |
|
435 | + * |
|
436 | + * @return IIndexDocument |
|
437 | + */ |
|
438 | + public function setMore(array $more): IIndexDocument; |
|
439 | + |
|
440 | + /** |
|
441 | + * Get more information. |
|
442 | + * |
|
443 | + * @since 15.0.0 |
|
444 | + * |
|
445 | + * @return array |
|
446 | + */ |
|
447 | + public function getMore(): array; |
|
448 | + |
|
449 | + |
|
450 | + /** |
|
451 | + * Add some excerpt of the content of the original document, usually based |
|
452 | + * on the search request. |
|
453 | + * |
|
454 | + * @since 16.0.0 |
|
455 | + * |
|
456 | + * @param string $source |
|
457 | + * @param string $excerpt |
|
458 | + * |
|
459 | + * @return IIndexDocument |
|
460 | + */ |
|
461 | + public function addExcerpt(string $source, string $excerpt): IIndexDocument; |
|
462 | + |
|
463 | + /** |
|
464 | + * Set all excerpts of the content of the original document. |
|
465 | + * |
|
466 | + * @since 16.0.0 |
|
467 | + * |
|
468 | + * @param array $excerpts |
|
469 | + * |
|
470 | + * @return IIndexDocument |
|
471 | + */ |
|
472 | + public function setExcerpts(array $excerpts): IIndexDocument; |
|
473 | + |
|
474 | + /** |
|
475 | + * Get all excerpts of the content of the original document. |
|
476 | + * |
|
477 | + * @since 15.0.0 |
|
478 | + * |
|
479 | + * @return array |
|
480 | + */ |
|
481 | + public function getExcerpts(): array; |
|
482 | + |
|
483 | + |
|
484 | + /** |
|
485 | + * Set the score to the result assigned to this document during a search |
|
486 | + * request. |
|
487 | + * |
|
488 | + * @since 15.0.0 |
|
489 | + * |
|
490 | + * @param string $score |
|
491 | + * |
|
492 | + * @return IIndexDocument |
|
493 | + */ |
|
494 | + public function setScore(string $score): IIndexDocument; |
|
495 | + |
|
496 | + /** |
|
497 | + * Get the score. |
|
498 | + * |
|
499 | + * @since 15.0.0 |
|
500 | + * |
|
501 | + * @return string |
|
502 | + */ |
|
503 | + public function getScore(): string; |
|
504 | + |
|
505 | + |
|
506 | + /** |
|
507 | + * Set some information about the original document that will be available |
|
508 | + * to the front-end when displaying search result. (as string) |
|
509 | + * Because this information will not be indexed, this method can also be |
|
510 | + * used to manage some data while filling the IIndexDocument before its |
|
511 | + * indexing. |
|
512 | + * |
|
513 | + * @since 15.0.0 |
|
514 | + * |
|
515 | + * @param string $info |
|
516 | + * @param string $value |
|
517 | + * |
|
518 | + * @return IIndexDocument |
|
519 | + */ |
|
520 | + public function setInfo(string $info, string $value): IIndexDocument; |
|
521 | + |
|
522 | + /** |
|
523 | + * Get an information about a document. (string) |
|
524 | + * |
|
525 | + * @since 15.0.0 |
|
526 | + * |
|
527 | + * @param string $info |
|
528 | + * @param string $default |
|
529 | + * |
|
530 | + * @return string |
|
531 | + */ |
|
532 | + public function getInfo(string $info, string $default = ''): string; |
|
533 | + |
|
534 | + /** |
|
535 | + * Set some information about the original document that will be available |
|
536 | + * to the front-end when displaying search result. (as array) |
|
537 | + * Because this information will not be indexed, this method can also be |
|
538 | + * used to manage some data while filling the IIndexDocument before its |
|
539 | + * indexing. |
|
540 | + * |
|
541 | + * @since 15.0.0 |
|
542 | + * |
|
543 | + * @param string $info |
|
544 | + * @param array $value |
|
545 | + * |
|
546 | + * @return IIndexDocument |
|
547 | + */ |
|
548 | + public function setInfoArray(string $info, array $value): IIndexDocument; |
|
549 | + |
|
550 | + /** |
|
551 | + * Get an information about a document. (array) |
|
552 | + * |
|
553 | + * @since 15.0.0 |
|
554 | + * |
|
555 | + * @param string $info |
|
556 | + * @param array $default |
|
557 | + * |
|
558 | + * @return array |
|
559 | + */ |
|
560 | + public function getInfoArray(string $info, array $default = []): array; |
|
561 | + |
|
562 | + /** |
|
563 | + * Set some information about the original document that will be available |
|
564 | + * to the front-end when displaying search result. (as int) |
|
565 | + * Because this information will not be indexed, this method can also be |
|
566 | + * used to manage some data while filling the IIndexDocument before its |
|
567 | + * indexing. |
|
568 | + * |
|
569 | + * @since 15.0.0 |
|
570 | + * |
|
571 | + * @param string $info |
|
572 | + * @param int $value |
|
573 | + * |
|
574 | + * @return IIndexDocument |
|
575 | + */ |
|
576 | + public function setInfoInt(string $info, int $value): IIndexDocument; |
|
577 | + |
|
578 | + /** |
|
579 | + * Get an information about a document. (int) |
|
580 | + * |
|
581 | + * @since 15.0.0 |
|
582 | + * |
|
583 | + * @param string $info |
|
584 | + * @param int $default |
|
585 | + * |
|
586 | + * @return int |
|
587 | + */ |
|
588 | + public function getInfoInt(string $info, int $default = 0): int; |
|
589 | + |
|
590 | + /** |
|
591 | + * Set some information about the original document that will be available |
|
592 | + * to the front-end when displaying search result. (as bool) |
|
593 | + * Because this information will not be indexed, this method can also be |
|
594 | + * used to manage some data while filling the IIndexDocument before its |
|
595 | + * indexing. |
|
596 | + * |
|
597 | + * @since 15.0.0 |
|
598 | + * |
|
599 | + * @param string $info |
|
600 | + * @param bool $value |
|
601 | + * |
|
602 | + * @return IIndexDocument |
|
603 | + */ |
|
604 | + public function setInfoBool(string $info, bool $value): IIndexDocument; |
|
605 | + |
|
606 | + /** |
|
607 | + * Get an information about a document. (bool) |
|
608 | + * |
|
609 | + * @since 15.0.0 |
|
610 | + * |
|
611 | + * @param string $info |
|
612 | + * @param bool $default |
|
613 | + * |
|
614 | + * @return bool |
|
615 | + */ |
|
616 | + public function getInfoBool(string $info, bool $default = false): bool; |
|
617 | + |
|
618 | + /** |
|
619 | + * Get all info. |
|
620 | + * |
|
621 | + * @since 15.0.0 |
|
622 | + * |
|
623 | + * @return array |
|
624 | + */ |
|
625 | + public function getInfoAll(): array; |
|
626 | 626 | } |