@@ -18,8 +18,8 @@ |
||
18 | 18 | * it's instantiated in there |
19 | 19 | */ |
20 | 20 | return [ |
21 | - 'routes' => [ |
|
21 | + 'routes' => [ |
|
22 | 22 | ['name' => 'ocr#process', 'url' => '/process', 'verb' => 'GET'], |
23 | 23 | ['name' => 'ocr#languages', 'url' => '/languages', 'verb' => 'GET'], |
24 | - ] |
|
24 | + ] |
|
25 | 25 | ]; |
26 | 26 | \ No newline at end of file |
@@ -46,11 +46,11 @@ discard block |
||
46 | 46 | $this->service = $service; |
47 | 47 | } |
48 | 48 | |
49 | - /** |
|
50 | - * @NoAdminRequired |
|
51 | - * |
|
52 | - * @return Template |
|
53 | - */ |
|
49 | + /** |
|
50 | + * @NoAdminRequired |
|
51 | + * |
|
52 | + * @return Template |
|
53 | + */ |
|
54 | 54 | public function displayPanel() { |
55 | 55 | $tmpl = new Template('ocr', 'settings-personal'); |
56 | 56 | return $tmpl; |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function getAll() { |
65 | 65 | return $this->handleNotFound(function () { |
66 | - return $this->service->getAllForPersonal($this->userId); |
|
66 | + return $this->service->getAllForPersonal($this->userId); |
|
67 | 67 | }); |
68 | 68 | } |
69 | 69 |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * @return \OCP\AppFramework\Http\DataResponse |
63 | 63 | */ |
64 | 64 | public function getAll() { |
65 | - return $this->handleNotFound(function () { |
|
65 | + return $this->handleNotFound(function() { |
|
66 | 66 | return $this->service->getAllForPersonal($this->userId); |
67 | 67 | }); |
68 | 68 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @return \OCP\AppFramework\Http\DataResponse |
74 | 74 | */ |
75 | 75 | public function deleteStatus($id) { |
76 | - return $this->handleNotFound(function () use ($id) { |
|
76 | + return $this->handleNotFound(function() use ($id) { |
|
77 | 77 | return $this->service->deleteStatus($id, $this->userId); |
78 | 78 | }); |
79 | 79 | } |
@@ -41,16 +41,16 @@ |
||
41 | 41 | return $this->findEntity($sql, [$id]); |
42 | 42 | } |
43 | 43 | |
44 | - /** |
|
45 | - * Finds all user specific status entities |
|
46 | - * |
|
47 | - * @param $userId |
|
48 | - * @return OcrStatus[] |
|
49 | - */ |
|
50 | - public function findAll($userId) { |
|
51 | - $sql = 'SELECT * FROM *PREFIX*ocr_status WHERE user_id = ?'; |
|
52 | - return $this->findEntities($sql, [$userId]); |
|
53 | - } |
|
44 | + /** |
|
45 | + * Finds all user specific status entities |
|
46 | + * |
|
47 | + * @param $userId |
|
48 | + * @return OcrStatus[] |
|
49 | + */ |
|
50 | + public function findAll($userId) { |
|
51 | + $sql = 'SELECT * FROM *PREFIX*ocr_status WHERE user_id = ?'; |
|
52 | + return $this->findEntities($sql, [$userId]); |
|
53 | + } |
|
54 | 54 | |
55 | 55 | /** |
56 | 56 | * Finds all status PROCESSED entities for a given userid |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
75 | - * TODO: in the future this function could be used to give an admin information |
|
75 | + * TODO: in the future this function could be used to give an admin information |
|
76 | 76 | * Counts the messages in the message queue. |
77 | - * |
|
77 | + * |
|
78 | 78 | * @return mixed |
79 | 79 | */ |
80 | 80 | public function countMessages() { |
@@ -87,13 +87,13 @@ discard block |
||
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
90 | - /** |
|
91 | - * TODO: in the future this function could be used to give an admin information |
|
92 | - * Counts the at this point processed files |
|
93 | - * |
|
94 | - * @return mixed |
|
95 | - */ |
|
96 | - public function countActiveProcesses() { |
|
90 | + /** |
|
91 | + * TODO: in the future this function could be used to give an admin information |
|
92 | + * Counts the at this point processed files |
|
93 | + * |
|
94 | + * @return mixed |
|
95 | + */ |
|
96 | + public function countActiveProcesses() { |
|
97 | 97 | try { |
98 | 98 | $stats = msg_stat_queue($this->statusqueue); |
99 | 99 | $this->logger->debug('Current active processing count: ' . json_encode($stats['msg_qnum']), ['app' => 'ocr']); |
@@ -44,7 +44,7 @@ |
||
44 | 44 | */ |
45 | 45 | public function run(IOutput $output) { |
46 | 46 | $output->startProgress(1); |
47 | - if ($this->connection->tableExists('ocr_status')){ |
|
47 | + if ($this->connection->tableExists('ocr_status')) { |
|
48 | 48 | $this->connection->dropTable('ocr_status'); |
49 | 49 | } |
50 | 50 | $output->advance(1, "Drop old database table: ocr_status"); |
@@ -128,7 +128,7 @@ |
||
128 | 128 | * Registers the Personal Settings Page for deletion of status objects and such things. |
129 | 129 | * @codeCoverageIgnore |
130 | 130 | */ |
131 | - public function registerPersonal(){ |
|
131 | + public function registerPersonal() { |
|
132 | 132 | \OCP\App::registerPersonal($this->getContainer()->getAppName(), 'personal'); |
133 | 133 | } |
134 | 134 |
@@ -73,13 +73,13 @@ |
||
73 | 73 | /** |
74 | 74 | * OcrStatus constructor. |
75 | 75 | * |
76 | - * @param null $status |
|
77 | - * @param null $source |
|
78 | - * @param null $target |
|
76 | + * @param string $status |
|
77 | + * @param string $source |
|
78 | + * @param string $target |
|
79 | 79 | * @param null $tempFile |
80 | - * @param null $type |
|
80 | + * @param string $type |
|
81 | 81 | * @param null $userId |
82 | - * @param null $errorDisplayed |
|
82 | + * @param boolean $errorDisplayed |
|
83 | 83 | */ |
84 | 84 | public function __construct($status = null, $source = null, $target = null, $tempFile = null, $type = null, $userId = null, $errorDisplayed = null) { |
85 | 85 | $this->setStatus($status); |
@@ -91,24 +91,24 @@ |
||
91 | 91 | $this->setErrorDisplayed($errorDisplayed); |
92 | 92 | } |
93 | 93 | |
94 | - /** |
|
95 | - * Specify data which should be serialized to JSON |
|
96 | - * @link http://php.net/manual/en/jsonserializable.jsonserialize.php |
|
97 | - * @return mixed data which can be serialized by <b>json_encode</b>, |
|
98 | - * which is a value of any type other than a resource. |
|
99 | - * @since 5.4.0 |
|
100 | - */ |
|
101 | - function jsonSerialize() |
|
102 | - { |
|
103 | - return [ |
|
104 | - 'id' => $this->id, |
|
105 | - 'status' => $this->status, |
|
106 | - 'source' => $this->source, |
|
107 | - 'target' => $this->target, |
|
108 | - 'tempFile' => $this->tempFile, |
|
109 | - 'type' => $this->type, |
|
110 | - 'userId' => $this->userId, |
|
111 | - 'errorDisplayed' => $this->errorDisplayed |
|
112 | - ]; |
|
113 | - } |
|
94 | + /** |
|
95 | + * Specify data which should be serialized to JSON |
|
96 | + * @link http://php.net/manual/en/jsonserializable.jsonserialize.php |
|
97 | + * @return mixed data which can be serialized by <b>json_encode</b>, |
|
98 | + * which is a value of any type other than a resource. |
|
99 | + * @since 5.4.0 |
|
100 | + */ |
|
101 | + function jsonSerialize() |
|
102 | + { |
|
103 | + return [ |
|
104 | + 'id' => $this->id, |
|
105 | + 'status' => $this->status, |
|
106 | + 'source' => $this->source, |
|
107 | + 'target' => $this->target, |
|
108 | + 'tempFile' => $this->tempFile, |
|
109 | + 'type' => $this->type, |
|
110 | + 'userId' => $this->userId, |
|
111 | + 'errorDisplayed' => $this->errorDisplayed |
|
112 | + ]; |
|
113 | + } |
|
114 | 114 | } |
115 | 115 | \ No newline at end of file |
@@ -252,6 +252,7 @@ discard block |
||
252 | 252 | * The PersonalSettingsController will have the opportunity to delete ocr status objects. |
253 | 253 | * |
254 | 254 | * @param $statusId |
255 | + * @param string $userId |
|
255 | 256 | * @return OcrStatus |
256 | 257 | */ |
257 | 258 | public function deleteStatus($statusId, $userId) { |
@@ -281,7 +282,7 @@ discard block |
||
281 | 282 | /** |
282 | 283 | * Gets all status objects for a specific user in order to list them on the personal settings page. |
283 | 284 | * |
284 | - * @param $userId |
|
285 | + * @param string $userId |
|
285 | 286 | * @return array |
286 | 287 | */ |
287 | 288 | public function getAllForPersonal($userId) { |
@@ -429,7 +430,7 @@ discard block |
||
429 | 430 | |
430 | 431 | /** |
431 | 432 | * @param File $fileInfo |
432 | - * @return bool |
|
433 | + * @return boolean|null |
|
433 | 434 | */ |
434 | 435 | private function checkSharedWithInitiator($fileInfo) { |
435 | 436 | try { |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | try { |
213 | 213 | // TODO: release lock |
214 | 214 | |
215 | - // returns user specific processed files |
|
215 | + // returns user specific processed files |
|
216 | 216 | $processed = $this->handleProcessed(); |
217 | 217 | |
218 | 218 | $pending = $this->statusMapper->findAllPending($this->userId); |
@@ -263,18 +263,18 @@ discard block |
||
263 | 263 | $status = $this->statusMapper->delete($status); |
264 | 264 | } |
265 | 265 | $status->setTarget($this->removeFileExtension($status)); |
266 | - $status->setSource(null); |
|
267 | - $status->setTempFile(null); |
|
268 | - $status->setType(null); |
|
269 | - $status->setErrorDisplayed(null); |
|
266 | + $status->setSource(null); |
|
267 | + $status->setTempFile(null); |
|
268 | + $status->setType(null); |
|
269 | + $status->setErrorDisplayed(null); |
|
270 | 270 | return $status; |
271 | 271 | } catch (Exception $e) { |
272 | - if ($e instanceof DoesNotExistException) { |
|
273 | - $ex = new NotFoundException($this->l10n->t('Cannot delete. Wrong id.')); |
|
274 | - $this->handleException($ex); |
|
275 | - } else { |
|
276 | - $this->handleException($e); |
|
277 | - } |
|
272 | + if ($e instanceof DoesNotExistException) { |
|
273 | + $ex = new NotFoundException($this->l10n->t('Cannot delete. Wrong id.')); |
|
274 | + $this->handleException($ex); |
|
275 | + } else { |
|
276 | + $this->handleException($e); |
|
277 | + } |
|
278 | 278 | } |
279 | 279 | } |
280 | 280 | |
@@ -285,9 +285,9 @@ discard block |
||
285 | 285 | * @return array |
286 | 286 | */ |
287 | 287 | public function getAllForPersonal($userId) { |
288 | - try { |
|
289 | - $status = $this->statusMapper->findAll($userId); |
|
290 | - $statusNew = array(); |
|
288 | + try { |
|
289 | + $status = $this->statusMapper->findAll($userId); |
|
290 | + $statusNew = array(); |
|
291 | 291 | for ($x = 0; $x < count($status); $x++) { |
292 | 292 | $newName = $this->removeFileExtension($status[$x]); |
293 | 293 | $status[$x]->setTarget($newName); |
@@ -297,11 +297,11 @@ discard block |
||
297 | 297 | $status[$x]->setErrorDisplayed(null); |
298 | 298 | array_push($statusNew, $status[$x]); |
299 | 299 | } |
300 | - return $statusNew; |
|
301 | - } catch (Exception $e) { |
|
302 | - $this->handleException($e); |
|
303 | - } |
|
304 | - } |
|
300 | + return $statusNew; |
|
301 | + } catch (Exception $e) { |
|
302 | + $this->handleException($e); |
|
303 | + } |
|
304 | + } |
|
305 | 305 | |
306 | 306 | /** |
307 | 307 | * Returns a not existing file name for pdf or image processing |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | $source = $fInfo->getPath(); |
170 | 170 | if ($this->checkSharedWithInitiator($fInfo)) { |
171 | 171 | // Shared Item |
172 | - $source = str_replace('home::','',$fInfo->getStoragename()) . '/' . $source; |
|
172 | + $source = str_replace('home::', '', $fInfo->getStoragename()) . '/' . $source; |
|
173 | 173 | $target = $this->buildTargetForShared($fInfo); |
174 | 174 | } else { |
175 | 175 | // Not Shared |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | */ |
314 | 314 | protected function buildTargetForShared(File $fileInfo) { |
315 | 315 | try { |
316 | - $share = $this->shareMapper->find($fileInfo->getFileid(), $this->userId, str_replace('home::','',$fileInfo->getStoragename())); |
|
316 | + $share = $this->shareMapper->find($fileInfo->getFileid(), $this->userId, str_replace('home::', '', $fileInfo->getStoragename())); |
|
317 | 317 | |
318 | 318 | // get rid of the .png or .pdf and so on |
319 | 319 | $fileName = substr($share->getFileTarget(), 0, -4); // '/thedom.png' => '/thedom' || '/Test/thedom.png' => '/Test/thedom' |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | $filePath = str_replace('files', '', $filePath); // 'files/Test/' => '/Test/' || 'files/' => '/' |
363 | 363 | |
364 | 364 | // remove the last slash |
365 | - $filePath = substr_replace($filePath,'',strrpos($filePath,'/'),strlen('/')); // '/Test/' => '/Test' || '/' => '' |
|
365 | + $filePath = substr_replace($filePath, '', strrpos($filePath, '/'), strlen('/')); // '/Test/' => '/Test' || '/' => '' |
|
366 | 366 | |
367 | 367 | // replace the first slash |
368 | 368 | $pos = strpos($filePath, '/'); |
@@ -433,8 +433,8 @@ discard block |
||
433 | 433 | */ |
434 | 434 | private function checkSharedWithInitiator($fileInfo) { |
435 | 435 | try { |
436 | - $owner = str_replace('home::','',$fileInfo->getStoragename()); |
|
437 | - if ($this->userId === $owner){ |
|
436 | + $owner = str_replace('home::', '', $fileInfo->getStoragename()); |
|
437 | + if ($this->userId === $owner) { |
|
438 | 438 | // user is owner (no shared file) |
439 | 439 | return false; |
440 | 440 | } else { |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | */ |
489 | 489 | private function removeFileExtension($status) { |
490 | 490 | try { |
491 | - return substr($status->getTarget(), 0, strrpos($status->getTarget(),'_OCR')); |
|
491 | + return substr($status->getTarget(), 0, strrpos($status->getTarget(), '_OCR')); |
|
492 | 492 | } catch (Exception $e) { |
493 | 493 | $this->handleException($e); |
494 | 494 | } |