Completed
Pull Request — master (#93)
by Janis
04:18
created
lib/Constants/OcrConstants.php 1 patch
Indentation   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -13,118 +13,118 @@
 block discarded – undo
13 13
 
14 14
 abstract class OcrConstants {
15 15
 
16
-    /**
17
-     * The pending status.
18
-     * 
19
-     * @var string
20
-     */
21
-    const STATUS_PENDING = 'PENDING';
22
-
23
-    /**
24
-     * The processed status.
25
-     * 
26
-     * @var string
27
-     */
28
-    const STATUS_PROCESSED = 'PROCESSED';
29
-
30
-    /**
31
-     * The failed status.
32
-     * 
33
-     * @var string
34
-     */
35
-    const STATUS_FAILED = 'FAILED';
36
-
37
-    /**
38
-     * Supported MIME types for OCR processing.
39
-     * 
40
-     * @var array
41
-     */
42
-    const ALLOWED_MIME_TYPES = [
43
-            'application/pdf',
44
-            'image/png',
45
-            'image/jpeg',
46
-            'image/tiff',
47
-            'image/jp2',
48
-            'image/jpm',
49
-            'image/jpx',
50
-            'image/webp',
51
-            'image/gif'
52
-    ];
53
-
54
-    /**
55
-     * The correct MIME type for a PDF file.
56
-     * 
57
-     * @var string
58
-     */
59
-    const MIME_TYPE_PDF = 'application/pdf';
60
-
61
-    /**
62
-     * The type of a job (OCRmyPDF).
63
-     * 
64
-     * @var integer
65
-     */
66
-    const OCRmyPDF = 1;
67
-
68
-    /**
69
-     * The type of a job (Tesseract).
70
-     * 
71
-     * @var integer
72
-     */
73
-    const TESSERACT = 0;
74
-
75
-    /**
76
-     * The name of the message queue that waits for now jobs.
77
-     * 
78
-     * @var string
79
-     */
80
-    const REDIS_NEW_JOBS_QUEUE = 'incoming';
81
-
82
-    /**
83
-     * The name of the message queue that waits for finished jobs.
84
-     * 
85
-     * @var string
86
-     */
87
-    const REDIS_FINISHED_JOBS_QUEUE = 'finished';
88
-
89
-    /**
90
-     * The name of the languages config key.
91
-     * 
92
-     * @var string
93
-     */
94
-    const LANGUAGES_CONFIG_KEY = 'languages';
95
-
96
-    /**
97
-     * The name of the redis host config key.
98
-     * 
99
-     * @var string
100
-     */
101
-    const REDIS_CONFIG_KEY_HOST = 'redisHost';
102
-
103
-    /**
104
-     * The name of the redis port config key.
105
-     * 
106
-     * @var string
107
-     */
108
-    const REDIS_CONFIG_KEY_PORT = 'redisPort';
109
-
110
-    /**
111
-     * The name of the redis db config key.
112
-     * 
113
-     * @var string
114
-     */
115
-    const REDIS_CONFIG_KEY_DB = 'redisDb';
116
-
117
-    /**
118
-     * The prefix for the redis key.
119
-     * 
120
-     * @var string
121
-     */
122
-    const REDIS_KEY_PREFIX = 'ocr:';
123
-
124
-    /**
125
-     * The prefix for the tempfiles that are created.
126
-     * 
127
-     * @var string
128
-     */
129
-    const TEMPFILE_PREFIX = 'ocr_';
16
+	/**
17
+	 * The pending status.
18
+	 * 
19
+	 * @var string
20
+	 */
21
+	const STATUS_PENDING = 'PENDING';
22
+
23
+	/**
24
+	 * The processed status.
25
+	 * 
26
+	 * @var string
27
+	 */
28
+	const STATUS_PROCESSED = 'PROCESSED';
29
+
30
+	/**
31
+	 * The failed status.
32
+	 * 
33
+	 * @var string
34
+	 */
35
+	const STATUS_FAILED = 'FAILED';
36
+
37
+	/**
38
+	 * Supported MIME types for OCR processing.
39
+	 * 
40
+	 * @var array
41
+	 */
42
+	const ALLOWED_MIME_TYPES = [
43
+			'application/pdf',
44
+			'image/png',
45
+			'image/jpeg',
46
+			'image/tiff',
47
+			'image/jp2',
48
+			'image/jpm',
49
+			'image/jpx',
50
+			'image/webp',
51
+			'image/gif'
52
+	];
53
+
54
+	/**
55
+	 * The correct MIME type for a PDF file.
56
+	 * 
57
+	 * @var string
58
+	 */
59
+	const MIME_TYPE_PDF = 'application/pdf';
60
+
61
+	/**
62
+	 * The type of a job (OCRmyPDF).
63
+	 * 
64
+	 * @var integer
65
+	 */
66
+	const OCRmyPDF = 1;
67
+
68
+	/**
69
+	 * The type of a job (Tesseract).
70
+	 * 
71
+	 * @var integer
72
+	 */
73
+	const TESSERACT = 0;
74
+
75
+	/**
76
+	 * The name of the message queue that waits for now jobs.
77
+	 * 
78
+	 * @var string
79
+	 */
80
+	const REDIS_NEW_JOBS_QUEUE = 'incoming';
81
+
82
+	/**
83
+	 * The name of the message queue that waits for finished jobs.
84
+	 * 
85
+	 * @var string
86
+	 */
87
+	const REDIS_FINISHED_JOBS_QUEUE = 'finished';
88
+
89
+	/**
90
+	 * The name of the languages config key.
91
+	 * 
92
+	 * @var string
93
+	 */
94
+	const LANGUAGES_CONFIG_KEY = 'languages';
95
+
96
+	/**
97
+	 * The name of the redis host config key.
98
+	 * 
99
+	 * @var string
100
+	 */
101
+	const REDIS_CONFIG_KEY_HOST = 'redisHost';
102
+
103
+	/**
104
+	 * The name of the redis port config key.
105
+	 * 
106
+	 * @var string
107
+	 */
108
+	const REDIS_CONFIG_KEY_PORT = 'redisPort';
109
+
110
+	/**
111
+	 * The name of the redis db config key.
112
+	 * 
113
+	 * @var string
114
+	 */
115
+	const REDIS_CONFIG_KEY_DB = 'redisDb';
116
+
117
+	/**
118
+	 * The prefix for the redis key.
119
+	 * 
120
+	 * @var string
121
+	 */
122
+	const REDIS_KEY_PREFIX = 'ocr:';
123
+
124
+	/**
125
+	 * The prefix for the tempfiles that are created.
126
+	 * 
127
+	 * @var string
128
+	 */
129
+	const TEMPFILE_PREFIX = 'ocr_';
130 130
 }
131 131
\ No newline at end of file
Please login to merge, or discard this patch.
lib/Settings/Admin.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -18,51 +18,51 @@
 block discarded – undo
18 18
 
19 19
 class Admin implements ISettings {
20 20
 
21
-    /** @var IConfig */
22
-    private $config;
21
+	/** @var IConfig */
22
+	private $config;
23 23
 
24
-    /**
25
-     *
26
-     * @param IConfig $config            
27
-     */
28
-    public function __construct(IConfig $config) {
29
-        $this->config = $config;
30
-    }
24
+	/**
25
+	 *
26
+	 * @param IConfig $config            
27
+	 */
28
+	public function __construct(IConfig $config) {
29
+		$this->config = $config;
30
+	}
31 31
 
32
-    /**
33
-     *
34
-     * @return TemplateResponse
35
-     */
36
-    public function getForm() {
37
-        return new TemplateResponse('ocr', 'settings-admin', 
38
-                [
39
-                        OcrConstants::LANGUAGES_CONFIG_KEY => $this->config->getAppValue('ocr', 
40
-                                OcrConstants::LANGUAGES_CONFIG_KEY),
41
-                        OcrConstants::REDIS_CONFIG_KEY_HOST => $this->config->getAppValue('ocr', 
42
-                                OcrConstants::REDIS_CONFIG_KEY_HOST),
43
-                        OcrConstants::REDIS_CONFIG_KEY_PORT => $this->config->getAppValue('ocr', 
44
-                                OcrConstants::REDIS_CONFIG_KEY_PORT),
45
-                        OcrConstants::REDIS_CONFIG_KEY_DB => $this->config->getAppValue('ocr', 
46
-                                OcrConstants::REDIS_CONFIG_KEY_DB)
47
-                ], 'blank');
48
-    }
32
+	/**
33
+	 *
34
+	 * @return TemplateResponse
35
+	 */
36
+	public function getForm() {
37
+		return new TemplateResponse('ocr', 'settings-admin', 
38
+				[
39
+						OcrConstants::LANGUAGES_CONFIG_KEY => $this->config->getAppValue('ocr', 
40
+								OcrConstants::LANGUAGES_CONFIG_KEY),
41
+						OcrConstants::REDIS_CONFIG_KEY_HOST => $this->config->getAppValue('ocr', 
42
+								OcrConstants::REDIS_CONFIG_KEY_HOST),
43
+						OcrConstants::REDIS_CONFIG_KEY_PORT => $this->config->getAppValue('ocr', 
44
+								OcrConstants::REDIS_CONFIG_KEY_PORT),
45
+						OcrConstants::REDIS_CONFIG_KEY_DB => $this->config->getAppValue('ocr', 
46
+								OcrConstants::REDIS_CONFIG_KEY_DB)
47
+				], 'blank');
48
+	}
49 49
 
50
-    /**
51
-     *
52
-     * @return string the section ID, e.g. 'sharing'
53
-     */
54
-    public function getSection() {
55
-        return 'ocr';
56
-    }
50
+	/**
51
+	 *
52
+	 * @return string the section ID, e.g. 'sharing'
53
+	 */
54
+	public function getSection() {
55
+		return 'ocr';
56
+	}
57 57
 
58
-    /**
59
-     *
60
-     * @return int whether the form should be rather on the top or bottom of
61
-     *         the admin section. The forms are arranged in ascending order of the
62
-     *         priority values. It is required to return a value between 0 and 100.
63
-     *         keep the server setting at the top, right after "server settings"
64
-     */
65
-    public function getPriority() {
66
-        return 0;
67
-    }
58
+	/**
59
+	 *
60
+	 * @return int whether the form should be rather on the top or bottom of
61
+	 *         the admin section. The forms are arranged in ascending order of the
62
+	 *         priority values. It is required to return a value between 0 and 100.
63
+	 *         keep the server setting at the top, right after "server settings"
64
+	 */
65
+	public function getPriority() {
66
+		return 0;
67
+	}
68 68
 }
69 69
\ No newline at end of file
Please login to merge, or discard this patch.
lib/Settings/Section.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -16,50 +16,50 @@
 block discarded – undo
16 16
 
17 17
 class Section implements IIconSection {
18 18
 
19
-    /** @var IL10N */
20
-    private $l;
19
+	/** @var IL10N */
20
+	private $l;
21 21
 
22
-    /**
23
-     *
24
-     * @param IL10N $l            
25
-     */
26
-    public function __construct(IL10N $l) {
27
-        $this->l = $l;
28
-    }
22
+	/**
23
+	 *
24
+	 * @param IL10N $l            
25
+	 */
26
+	public function __construct(IL10N $l) {
27
+		$this->l = $l;
28
+	}
29 29
 
30
-    /**
31
-     *
32
-     * {@inheritdoc}
33
-     *
34
-     */
35
-    public function getID() {
36
-        return 'ocr';
37
-    }
30
+	/**
31
+	 *
32
+	 * {@inheritdoc}
33
+	 *
34
+	 */
35
+	public function getID() {
36
+		return 'ocr';
37
+	}
38 38
 
39
-    /**
40
-     *
41
-     * {@inheritdoc}
42
-     *
43
-     */
44
-    public function getName() {
45
-        return $this->l->t('OCR');
46
-    }
39
+	/**
40
+	 *
41
+	 * {@inheritdoc}
42
+	 *
43
+	 */
44
+	public function getName() {
45
+		return $this->l->t('OCR');
46
+	}
47 47
 
48
-    /**
49
-     *
50
-     * {@inheritdoc}
51
-     *
52
-     */
53
-    public function getPriority() {
54
-        return 75;
55
-    }
48
+	/**
49
+	 *
50
+	 * {@inheritdoc}
51
+	 *
52
+	 */
53
+	public function getPriority() {
54
+		return 75;
55
+	}
56 56
 
57
-    /**
58
-     *
59
-     * {@inheritdoc}
60
-     *
61
-     */
62
-    public function getIcon() {
63
-        return '/apps/ocr/img/icon/ocr.svg';
64
-    }
57
+	/**
58
+	 *
59
+	 * {@inheritdoc}
60
+	 *
61
+	 */
62
+	public function getIcon() {
63
+		return '/apps/ocr/img/icon/ocr.svg';
64
+	}
65 65
 }
66 66
\ No newline at end of file
Please login to merge, or discard this patch.
lib/Service/AppConfigService.php 1 patch
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -17,93 +17,93 @@
 block discarded – undo
17 17
 
18 18
 class AppConfigService {
19 19
 
20
-    /**
21
-     *
22
-     * @var string
23
-     */
24
-    private $appName = 'ocr';
20
+	/**
21
+	 *
22
+	 * @var string
23
+	 */
24
+	private $appName = 'ocr';
25 25
 
26
-    /**
27
-     *
28
-     * @var IConfig
29
-     */
30
-    private $config;
26
+	/**
27
+	 *
28
+	 * @var IConfig
29
+	 */
30
+	private $config;
31 31
 
32
-    /**
33
-     *
34
-     * @var IL10N
35
-     */
36
-    private $l10n;
32
+	/**
33
+	 *
34
+	 * @var IL10N
35
+	 */
36
+	private $l10n;
37 37
 
38
-    /**
39
-     * Constructor
40
-     * 
41
-     * @param IConfig $config            
42
-     * @param IL10N $l10n            
43
-     */
44
-    public function __construct(IConfig $config, IL10N $l10n) {
45
-        $this->config = $config;
46
-        $this->l10n = $l10n;
47
-    }
38
+	/**
39
+	 * Constructor
40
+	 * 
41
+	 * @param IConfig $config            
42
+	 * @param IL10N $l10n            
43
+	 */
44
+	public function __construct(IConfig $config, IL10N $l10n) {
45
+		$this->config = $config;
46
+		$this->l10n = $l10n;
47
+	}
48 48
 
49
-    /**
50
-     * Get a value by key
51
-     * 
52
-     * @param string $key            
53
-     * @return string
54
-     */
55
-    public function getAppValue($key) {
56
-        return $this->config->getAppValue($this->appName, $key);
57
-    }
49
+	/**
50
+	 * Get a value by key
51
+	 * 
52
+	 * @param string $key            
53
+	 * @return string
54
+	 */
55
+	public function getAppValue($key) {
56
+		return $this->config->getAppValue($this->appName, $key);
57
+	}
58 58
 
59
-    /**
60
-     * Evaluate if all redis related settings are set.
61
-     * 
62
-     * @return boolean
63
-     */
64
-    public function evaluateRedisSettings() {
65
-        if ($this->config->getAppValue($this->appName, OcrConstants::REDIS_CONFIG_KEY_HOST) !== '' &&
66
-                 $this->config->getAppValue($this->appName, OcrConstants::REDIS_CONFIG_KEY_PORT) !== '' &&
67
-                 $this->config->getAppValue($this->appName, OcrConstants::REDIS_CONFIG_KEY_DB) !== '') {
68
-            return true;
69
-        } else {
70
-            return false;
71
-        }
72
-    }
59
+	/**
60
+	 * Evaluate if all redis related settings are set.
61
+	 * 
62
+	 * @return boolean
63
+	 */
64
+	public function evaluateRedisSettings() {
65
+		if ($this->config->getAppValue($this->appName, OcrConstants::REDIS_CONFIG_KEY_HOST) !== '' &&
66
+				 $this->config->getAppValue($this->appName, OcrConstants::REDIS_CONFIG_KEY_PORT) !== '' &&
67
+				 $this->config->getAppValue($this->appName, OcrConstants::REDIS_CONFIG_KEY_DB) !== '') {
68
+			return true;
69
+		} else {
70
+			return false;
71
+		}
72
+	}
73 73
 
74
-    /**
75
-     * Set a value by key
76
-     * TODO: switch case and too much if statements
77
-     * @param string $key            
78
-     * @param string $value            
79
-     * @return string
80
-     */
81
-    public function setAppValue($key, $value) {
82
-        if ($key === OcrConstants::LANGUAGES_CONFIG_KEY) {
83
-            if (!preg_match('/^(([a-z]{3,4}|[a-z]{3,4}\-[a-z]{3,4});)*([a-z]{3,4}|[a-z]{3,4}\-[a-z]{3,4})$/', $value)) {
84
-                throw new NotFoundException($this->l10n->t('The languages are not specified in the correct format.'));
85
-            }
86
-        }
87
-        if ($key === OcrConstants::REDIS_CONFIG_KEY_HOST) {
88
-            if (!preg_match(
89
-                    '/(^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$)/', 
90
-                    $value)) {
91
-                throw new NotFoundException($this->l10n->t('The redis host is not specified in the correct format.'));
92
-            }
93
-        }
94
-        if ($key === OcrConstants::REDIS_CONFIG_KEY_PORT) {
95
-            $value = intval($value);
96
-            if (!($value > 0 && $value < 65535)) {
97
-                throw new NotFoundException(
98
-                        $this->l10n->t('The redis port number is not specified in the correct format.'));
99
-            }
100
-        }
101
-        if ($key === OcrConstants::REDIS_CONFIG_KEY_DB) {
102
-            $value = intval($value);
103
-            if (!($value >= 0)) {
104
-                throw new NotFoundException($this->l10n->t('The redis db is not specified in the correct format.'));
105
-            }
106
-        }
107
-        return $this->config->setAppValue($this->appName, $key, $value);
108
-    }
74
+	/**
75
+	 * Set a value by key
76
+	 * TODO: switch case and too much if statements
77
+	 * @param string $key            
78
+	 * @param string $value            
79
+	 * @return string
80
+	 */
81
+	public function setAppValue($key, $value) {
82
+		if ($key === OcrConstants::LANGUAGES_CONFIG_KEY) {
83
+			if (!preg_match('/^(([a-z]{3,4}|[a-z]{3,4}\-[a-z]{3,4});)*([a-z]{3,4}|[a-z]{3,4}\-[a-z]{3,4})$/', $value)) {
84
+				throw new NotFoundException($this->l10n->t('The languages are not specified in the correct format.'));
85
+			}
86
+		}
87
+		if ($key === OcrConstants::REDIS_CONFIG_KEY_HOST) {
88
+			if (!preg_match(
89
+					'/(^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$)/', 
90
+					$value)) {
91
+				throw new NotFoundException($this->l10n->t('The redis host is not specified in the correct format.'));
92
+			}
93
+		}
94
+		if ($key === OcrConstants::REDIS_CONFIG_KEY_PORT) {
95
+			$value = intval($value);
96
+			if (!($value > 0 && $value < 65535)) {
97
+				throw new NotFoundException(
98
+						$this->l10n->t('The redis port number is not specified in the correct format.'));
99
+			}
100
+		}
101
+		if ($key === OcrConstants::REDIS_CONFIG_KEY_DB) {
102
+			$value = intval($value);
103
+			if (!($value >= 0)) {
104
+				throw new NotFoundException($this->l10n->t('The redis db is not specified in the correct format.'));
105
+			}
106
+		}
107
+		return $this->config->setAppValue($this->appName, $key, $value);
108
+	}
109 109
 }
110 110
\ No newline at end of file
Please login to merge, or discard this patch.