@@ -24,397 +24,397 @@ |
||
24 | 24 | |
25 | 25 | class tx_crawler_view_process_list { |
26 | 26 | |
27 | - /** |
|
28 | - * @var string template path |
|
29 | - */ |
|
30 | - protected $template = 'EXT:crawler/template/process/list.php'; |
|
31 | - |
|
32 | - /** |
|
33 | - * @var string icon path |
|
34 | - */ |
|
35 | - protected $iconPath; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var string Holds the path to start a cli process via command line |
|
39 | - */ |
|
40 | - protected $cliPath; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var int Holds the total number of items pending in the queue to be processed |
|
44 | - */ |
|
45 | - protected $totalItemCount; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var boolean Holds the enable state of the crawler |
|
49 | - */ |
|
50 | - protected $isCrawlerEnabled; |
|
51 | - |
|
52 | - /** |
|
53 | - * @var int Holds the number of active processes |
|
54 | - */ |
|
55 | - protected $activeProcessCount; |
|
56 | - |
|
57 | - /** |
|
58 | - * @var int Holds the number of maximum active processes |
|
59 | - */ |
|
60 | - protected $maxActiveProcessCount; |
|
61 | - |
|
62 | - /** |
|
63 | - * @var string Holds the mode state, can be simple or detail |
|
64 | - */ |
|
65 | - protected $mode; |
|
66 | - |
|
67 | - /** |
|
68 | - * @var int Holds the current page id |
|
69 | - */ |
|
70 | - protected $pageId; |
|
71 | - |
|
72 | - /** |
|
73 | - * @var int $totalItemCount number of total item |
|
74 | - */ |
|
75 | - protected $totalUnprocessedItemCount; |
|
76 | - |
|
77 | - /** |
|
78 | - * @var int Holds the number of assigned unprocessed items |
|
79 | - */ |
|
80 | - protected $assignedUnprocessedItemCount; |
|
81 | - |
|
82 | - /** |
|
83 | - * @return int |
|
84 | - */ |
|
85 | - public function getAssignedUnprocessedItemCount() { |
|
86 | - return $this->assignedUnprocessedItemCount; |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * @return int |
|
91 | - */ |
|
92 | - public function getTotalUnprocessedItemCount() { |
|
93 | - return $this->totalUnprocessedItemCount; |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * @param int $assignedUnprocessedItemCount |
|
98 | - */ |
|
99 | - public function setAssignedUnprocessedItemCount($assignedUnprocessedItemCount) { |
|
100 | - $this->assignedUnprocessedItemCount = $assignedUnprocessedItemCount; |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * @param int $totalUnprocessedItemCount |
|
105 | - */ |
|
106 | - public function setTotalUnprocessedItemCount($totalUnprocessedItemCount) { |
|
107 | - $this->totalUnprocessedItemCount = $totalUnprocessedItemCount; |
|
108 | - } |
|
109 | - |
|
110 | - /** |
|
111 | - * Set the page id |
|
112 | - * |
|
113 | - * @param int $pageId page id |
|
114 | - */ |
|
115 | - public function setPageId($pageId) { |
|
116 | - $this->pageId = $pageId; |
|
117 | - } |
|
118 | - |
|
119 | - /** |
|
120 | - * Get the page id |
|
121 | - * |
|
122 | - * @return int page id |
|
123 | - */ |
|
124 | - public function getPageId() { |
|
125 | - return $this->pageId; |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * @return string |
|
130 | - */ |
|
131 | - public function getMode() { |
|
132 | - return $this->mode; |
|
133 | - } |
|
134 | - |
|
135 | - /** |
|
136 | - * @param string $mode |
|
137 | - */ |
|
138 | - public function setMode($mode) { |
|
139 | - $this->mode = $mode; |
|
140 | - } |
|
141 | - |
|
142 | - |
|
143 | - /** |
|
144 | - * @return int |
|
145 | - */ |
|
146 | - public function getMaxActiveProcessCount() { |
|
147 | - return $this->maxActiveProcessCount; |
|
148 | - } |
|
149 | - |
|
150 | - /** |
|
151 | - * @param int $maxActiveProcessCount |
|
152 | - */ |
|
153 | - public function setMaxActiveProcessCount($maxActiveProcessCount) { |
|
154 | - $this->maxActiveProcessCount = $maxActiveProcessCount; |
|
155 | - } |
|
156 | - |
|
157 | - |
|
158 | - /** |
|
159 | - * @return int |
|
160 | - */ |
|
161 | - public function getActiveProcessCount() { |
|
162 | - return $this->activeProcessCount; |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * @param int $activeProcessCount |
|
167 | - */ |
|
168 | - public function setActiveProcessCount($activeProcessCount) { |
|
169 | - $this->activeProcessCount = $activeProcessCount; |
|
170 | - } |
|
171 | - |
|
172 | - /** |
|
173 | - * @return boolean |
|
174 | - */ |
|
175 | - public function getIsCrawlerEnabled() { |
|
176 | - return $this->isCrawlerEnabled; |
|
177 | - } |
|
178 | - |
|
179 | - /** |
|
180 | - * @param boolean $isCrawlerEnabled |
|
181 | - */ |
|
182 | - public function setIsCrawlerEnabled($isCrawlerEnabled) { |
|
183 | - $this->isCrawlerEnabled = $isCrawlerEnabled; |
|
184 | - } |
|
185 | - |
|
186 | - |
|
187 | - /** |
|
188 | - * Returns the path to start a cli process from the shell |
|
189 | - * @return string |
|
190 | - */ |
|
191 | - public function getCliPath() { |
|
192 | - return $this->cliPath; |
|
193 | - } |
|
194 | - |
|
195 | - /** |
|
196 | - * @param string $cliPath |
|
197 | - */ |
|
198 | - public function setCliPath($cliPath) { |
|
199 | - $this->cliPath = $cliPath; |
|
200 | - } |
|
201 | - |
|
202 | - |
|
203 | - /** |
|
204 | - * @return int |
|
205 | - */ |
|
206 | - public function getTotalItemCount() { |
|
207 | - return $this->totalItemCount; |
|
208 | - } |
|
209 | - |
|
210 | - /** |
|
211 | - * @param int $totalItemCount |
|
212 | - */ |
|
213 | - public function setTotalItemCount($totalItemCount) { |
|
214 | - $this->totalItemCount = $totalItemCount; |
|
215 | - } |
|
216 | - |
|
217 | - /** |
|
218 | - * Method to set the path to the icon from outside |
|
219 | - * |
|
220 | - * @param string $iconPath |
|
221 | - */ |
|
222 | - public function setIconPath($iconPath) { |
|
223 | - $this->iconPath = $iconPath; |
|
224 | - } |
|
225 | - |
|
226 | - /** |
|
227 | - * Method to read the configured icon path |
|
228 | - * |
|
229 | - * @return string |
|
230 | - */ |
|
231 | - protected function getIconPath() { |
|
232 | - return $this->iconPath; |
|
233 | - } |
|
234 | - |
|
235 | - /** |
|
236 | - * Method to set a collection of process objects to be displayed in |
|
237 | - * the list view. |
|
238 | - * |
|
239 | - * @param tx_crawler_domain_process_collection $processCollection |
|
240 | - */ |
|
241 | - public function setProcessCollection($processCollection) { |
|
242 | - $this->processCollection = $processCollection; |
|
243 | - } |
|
244 | - |
|
245 | - /** |
|
246 | - * Returns a collection of processObjects. |
|
247 | - * |
|
248 | - * @return tx_crawler_domain_process_collection |
|
249 | - */ |
|
250 | - protected function getProcessCollection() { |
|
251 | - return $this->processCollection; |
|
252 | - } |
|
253 | - |
|
254 | - /** |
|
255 | - * Formats a timestamp as date |
|
256 | - * |
|
257 | - * @param int $timestamp |
|
258 | - * @return string |
|
259 | - */ |
|
260 | - protected function asDate($timestamp) { |
|
261 | - if ($timestamp > 0) { |
|
262 | - return date($this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:time.detailed'), $timestamp); |
|
263 | - } else { |
|
264 | - return ''; |
|
265 | - } |
|
266 | - } |
|
267 | - |
|
268 | - /** |
|
269 | - * Converts seconds into minutes |
|
270 | - * |
|
271 | - * @param int $seconds |
|
272 | - * @return double |
|
273 | - */ |
|
274 | - protected function asMinutes($seconds) { |
|
275 | - return round($seconds / 60); |
|
276 | - } |
|
277 | - |
|
278 | - /** |
|
279 | - * Returns the state icon for the current job |
|
280 | - * |
|
281 | - * @param string $state |
|
282 | - * @return string icon |
|
283 | - */ |
|
284 | - protected function getIconForState($state) { |
|
285 | - switch($state) { |
|
286 | - case 'running': |
|
287 | - $icon = 'bullet_orange'; |
|
288 | - $title = $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.process.running'); |
|
289 | - break; |
|
290 | - case 'completed': |
|
291 | - $icon = 'bullet_green'; |
|
292 | - $title = $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.process.success'); |
|
293 | - break; |
|
294 | - case 'cancelled': |
|
295 | - $icon = 'bullet_red'; |
|
296 | - $title = $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.process.cancelled'); |
|
297 | - break; |
|
298 | - } |
|
299 | - |
|
300 | - return $this->getIcon($icon, $title); |
|
301 | - } |
|
302 | - |
|
303 | - /** |
|
304 | - * Returns a tag for the refresh icon |
|
305 | - * |
|
306 | - * @return string |
|
307 | - */ |
|
308 | - protected function getRefreshIcon() { |
|
309 | - return $this->getIcon('arrow_refresh'); |
|
310 | - } |
|
311 | - |
|
312 | - /** |
|
313 | - * Returns a tag for the refresh icon |
|
314 | - * |
|
315 | - * @return string |
|
316 | - */ |
|
317 | - protected function getRefreshLink() { |
|
318 | - return '<input onclick="window.location=\'' . \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_info') . '&SET[crawlaction]=multiprocess&id=' . $this->pageId . '\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\'' . $this->getIconPath() . 'arrow_refresh.png' . '\'); background-repeat: no-repeat;" value="' . $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.refresh') . '" />'; |
|
319 | - } |
|
320 | - |
|
321 | - /** |
|
322 | - * Returns an icon to stop all processes |
|
323 | - * |
|
324 | - * @return string html tag for stop icon |
|
325 | - */ |
|
326 | - protected function getStopIcon() { |
|
327 | - return $this->getIcon('stop'); |
|
328 | - } |
|
329 | - |
|
330 | - /** |
|
331 | - * Returns a link for the panel to enable or disable the crawler |
|
332 | - * |
|
333 | - * @return string |
|
334 | - */ |
|
335 | - protected function getEnableDisableLink() { |
|
336 | - if ($this->getIsCrawlerEnabled()) { |
|
337 | - return '<input onclick="window.location+=\'&action=stopCrawling\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\'' . $this->getIconPath() . 'control_stop_blue.png' . '\'); background-repeat: no-repeat;" value="' . $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.disablecrawling') . '" />'; |
|
338 | - } else { |
|
339 | - return '<input onclick="window.location+=\'&action=resumeCrawling\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\'' . $this->getIconPath() . 'control_play.png' . '\'); background-repeat: no-repeat;" value="' . $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.enablecrawling') . '" />'; |
|
340 | - } |
|
341 | - } |
|
342 | - |
|
343 | - /** |
|
344 | - * Get mode link |
|
345 | - * |
|
346 | - * @param void |
|
347 | - * @return string a-tag |
|
348 | - */ |
|
349 | - protected function getModeLink() { |
|
350 | - if ($this->getMode() == 'detail') { |
|
351 | - return '<input onclick="window.location+=\'&SET[processListMode]=simple\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\'' . $this->getIconPath() . 'arrow_in.png' . '\'); background-repeat: no-repeat;" value="' . $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.show.running') . '" />'; |
|
352 | - } elseif ($this->getMode() == 'simple') { |
|
353 | - return '<input onclick="window.location+=\'&SET[processListMode]=detail\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\'' . $this->getIconPath() . 'arrow_out.png' . '\'); background-repeat: no-repeat;" value="' . $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.show.all') . '" />'; |
|
354 | - } |
|
355 | - } |
|
356 | - |
|
357 | - /** |
|
358 | - * Get add link |
|
359 | - * |
|
360 | - * @param void |
|
361 | - * @return string a-tag |
|
362 | - */ |
|
363 | - protected function getAddLink() { |
|
364 | - if ($this->getActiveProcessCount() < $this->getMaxActiveProcessCount() && $this->getIsCrawlerEnabled()) { |
|
365 | - return '<input onclick="window.location+=\'&action=addProcess\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\'' . $this->getIconPath() . 'add.png' . '\'); background-repeat: no-repeat;" value="' . $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.process.add') . '" />'; |
|
366 | - } else { |
|
367 | - return ''; |
|
368 | - } |
|
369 | - } |
|
370 | - |
|
371 | - /** |
|
372 | - * Returns the icon to add new crawler processes |
|
373 | - * |
|
374 | - * @return string html tag for image to add new processes |
|
375 | - */ |
|
376 | - protected function getAddIcon() { |
|
377 | - return $this->getIcon('add'); |
|
378 | - } |
|
379 | - |
|
380 | - /** |
|
381 | - * Returns an imagetag for an icon |
|
382 | - * |
|
383 | - * @param string $icon |
|
384 | - * @return string html tag for icon |
|
385 | - */ |
|
386 | - protected function getIcon($icon, $title='') { |
|
387 | - if (!empty($title)) { |
|
388 | - $title = ' title="'.$title.'"'; |
|
389 | - } |
|
390 | - return '<img src="'.$this->getIconPath().$icon.'.png" ' . $title . ' />'; |
|
391 | - } |
|
392 | - |
|
393 | - /** |
|
394 | - * Method to render the view. |
|
395 | - * |
|
396 | - * @return string html content |
|
397 | - */ |
|
398 | - public function render() { |
|
399 | - ob_start(); |
|
400 | - $this->template = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($this->template); |
|
401 | - include($this->template); |
|
402 | - $content = ob_get_contents(); |
|
403 | - ob_end_clean(); |
|
404 | - return $content; |
|
405 | - } |
|
406 | - |
|
407 | - /** |
|
408 | - * retrieve locallanglabel from environment |
|
409 | - * just a wrapper should be done in a cleaner way |
|
410 | - * later on |
|
411 | - * |
|
412 | - * @param string $label |
|
413 | - * @return string |
|
414 | - */ |
|
415 | - protected function getLLLabel($label) { |
|
416 | - return $GLOBALS['LANG']->sL($label); |
|
417 | - } |
|
27 | + /** |
|
28 | + * @var string template path |
|
29 | + */ |
|
30 | + protected $template = 'EXT:crawler/template/process/list.php'; |
|
31 | + |
|
32 | + /** |
|
33 | + * @var string icon path |
|
34 | + */ |
|
35 | + protected $iconPath; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var string Holds the path to start a cli process via command line |
|
39 | + */ |
|
40 | + protected $cliPath; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var int Holds the total number of items pending in the queue to be processed |
|
44 | + */ |
|
45 | + protected $totalItemCount; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var boolean Holds the enable state of the crawler |
|
49 | + */ |
|
50 | + protected $isCrawlerEnabled; |
|
51 | + |
|
52 | + /** |
|
53 | + * @var int Holds the number of active processes |
|
54 | + */ |
|
55 | + protected $activeProcessCount; |
|
56 | + |
|
57 | + /** |
|
58 | + * @var int Holds the number of maximum active processes |
|
59 | + */ |
|
60 | + protected $maxActiveProcessCount; |
|
61 | + |
|
62 | + /** |
|
63 | + * @var string Holds the mode state, can be simple or detail |
|
64 | + */ |
|
65 | + protected $mode; |
|
66 | + |
|
67 | + /** |
|
68 | + * @var int Holds the current page id |
|
69 | + */ |
|
70 | + protected $pageId; |
|
71 | + |
|
72 | + /** |
|
73 | + * @var int $totalItemCount number of total item |
|
74 | + */ |
|
75 | + protected $totalUnprocessedItemCount; |
|
76 | + |
|
77 | + /** |
|
78 | + * @var int Holds the number of assigned unprocessed items |
|
79 | + */ |
|
80 | + protected $assignedUnprocessedItemCount; |
|
81 | + |
|
82 | + /** |
|
83 | + * @return int |
|
84 | + */ |
|
85 | + public function getAssignedUnprocessedItemCount() { |
|
86 | + return $this->assignedUnprocessedItemCount; |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * @return int |
|
91 | + */ |
|
92 | + public function getTotalUnprocessedItemCount() { |
|
93 | + return $this->totalUnprocessedItemCount; |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * @param int $assignedUnprocessedItemCount |
|
98 | + */ |
|
99 | + public function setAssignedUnprocessedItemCount($assignedUnprocessedItemCount) { |
|
100 | + $this->assignedUnprocessedItemCount = $assignedUnprocessedItemCount; |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * @param int $totalUnprocessedItemCount |
|
105 | + */ |
|
106 | + public function setTotalUnprocessedItemCount($totalUnprocessedItemCount) { |
|
107 | + $this->totalUnprocessedItemCount = $totalUnprocessedItemCount; |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * Set the page id |
|
112 | + * |
|
113 | + * @param int $pageId page id |
|
114 | + */ |
|
115 | + public function setPageId($pageId) { |
|
116 | + $this->pageId = $pageId; |
|
117 | + } |
|
118 | + |
|
119 | + /** |
|
120 | + * Get the page id |
|
121 | + * |
|
122 | + * @return int page id |
|
123 | + */ |
|
124 | + public function getPageId() { |
|
125 | + return $this->pageId; |
|
126 | + } |
|
127 | + |
|
128 | + /** |
|
129 | + * @return string |
|
130 | + */ |
|
131 | + public function getMode() { |
|
132 | + return $this->mode; |
|
133 | + } |
|
134 | + |
|
135 | + /** |
|
136 | + * @param string $mode |
|
137 | + */ |
|
138 | + public function setMode($mode) { |
|
139 | + $this->mode = $mode; |
|
140 | + } |
|
141 | + |
|
142 | + |
|
143 | + /** |
|
144 | + * @return int |
|
145 | + */ |
|
146 | + public function getMaxActiveProcessCount() { |
|
147 | + return $this->maxActiveProcessCount; |
|
148 | + } |
|
149 | + |
|
150 | + /** |
|
151 | + * @param int $maxActiveProcessCount |
|
152 | + */ |
|
153 | + public function setMaxActiveProcessCount($maxActiveProcessCount) { |
|
154 | + $this->maxActiveProcessCount = $maxActiveProcessCount; |
|
155 | + } |
|
156 | + |
|
157 | + |
|
158 | + /** |
|
159 | + * @return int |
|
160 | + */ |
|
161 | + public function getActiveProcessCount() { |
|
162 | + return $this->activeProcessCount; |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * @param int $activeProcessCount |
|
167 | + */ |
|
168 | + public function setActiveProcessCount($activeProcessCount) { |
|
169 | + $this->activeProcessCount = $activeProcessCount; |
|
170 | + } |
|
171 | + |
|
172 | + /** |
|
173 | + * @return boolean |
|
174 | + */ |
|
175 | + public function getIsCrawlerEnabled() { |
|
176 | + return $this->isCrawlerEnabled; |
|
177 | + } |
|
178 | + |
|
179 | + /** |
|
180 | + * @param boolean $isCrawlerEnabled |
|
181 | + */ |
|
182 | + public function setIsCrawlerEnabled($isCrawlerEnabled) { |
|
183 | + $this->isCrawlerEnabled = $isCrawlerEnabled; |
|
184 | + } |
|
185 | + |
|
186 | + |
|
187 | + /** |
|
188 | + * Returns the path to start a cli process from the shell |
|
189 | + * @return string |
|
190 | + */ |
|
191 | + public function getCliPath() { |
|
192 | + return $this->cliPath; |
|
193 | + } |
|
194 | + |
|
195 | + /** |
|
196 | + * @param string $cliPath |
|
197 | + */ |
|
198 | + public function setCliPath($cliPath) { |
|
199 | + $this->cliPath = $cliPath; |
|
200 | + } |
|
201 | + |
|
202 | + |
|
203 | + /** |
|
204 | + * @return int |
|
205 | + */ |
|
206 | + public function getTotalItemCount() { |
|
207 | + return $this->totalItemCount; |
|
208 | + } |
|
209 | + |
|
210 | + /** |
|
211 | + * @param int $totalItemCount |
|
212 | + */ |
|
213 | + public function setTotalItemCount($totalItemCount) { |
|
214 | + $this->totalItemCount = $totalItemCount; |
|
215 | + } |
|
216 | + |
|
217 | + /** |
|
218 | + * Method to set the path to the icon from outside |
|
219 | + * |
|
220 | + * @param string $iconPath |
|
221 | + */ |
|
222 | + public function setIconPath($iconPath) { |
|
223 | + $this->iconPath = $iconPath; |
|
224 | + } |
|
225 | + |
|
226 | + /** |
|
227 | + * Method to read the configured icon path |
|
228 | + * |
|
229 | + * @return string |
|
230 | + */ |
|
231 | + protected function getIconPath() { |
|
232 | + return $this->iconPath; |
|
233 | + } |
|
234 | + |
|
235 | + /** |
|
236 | + * Method to set a collection of process objects to be displayed in |
|
237 | + * the list view. |
|
238 | + * |
|
239 | + * @param tx_crawler_domain_process_collection $processCollection |
|
240 | + */ |
|
241 | + public function setProcessCollection($processCollection) { |
|
242 | + $this->processCollection = $processCollection; |
|
243 | + } |
|
244 | + |
|
245 | + /** |
|
246 | + * Returns a collection of processObjects. |
|
247 | + * |
|
248 | + * @return tx_crawler_domain_process_collection |
|
249 | + */ |
|
250 | + protected function getProcessCollection() { |
|
251 | + return $this->processCollection; |
|
252 | + } |
|
253 | + |
|
254 | + /** |
|
255 | + * Formats a timestamp as date |
|
256 | + * |
|
257 | + * @param int $timestamp |
|
258 | + * @return string |
|
259 | + */ |
|
260 | + protected function asDate($timestamp) { |
|
261 | + if ($timestamp > 0) { |
|
262 | + return date($this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:time.detailed'), $timestamp); |
|
263 | + } else { |
|
264 | + return ''; |
|
265 | + } |
|
266 | + } |
|
267 | + |
|
268 | + /** |
|
269 | + * Converts seconds into minutes |
|
270 | + * |
|
271 | + * @param int $seconds |
|
272 | + * @return double |
|
273 | + */ |
|
274 | + protected function asMinutes($seconds) { |
|
275 | + return round($seconds / 60); |
|
276 | + } |
|
277 | + |
|
278 | + /** |
|
279 | + * Returns the state icon for the current job |
|
280 | + * |
|
281 | + * @param string $state |
|
282 | + * @return string icon |
|
283 | + */ |
|
284 | + protected function getIconForState($state) { |
|
285 | + switch($state) { |
|
286 | + case 'running': |
|
287 | + $icon = 'bullet_orange'; |
|
288 | + $title = $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.process.running'); |
|
289 | + break; |
|
290 | + case 'completed': |
|
291 | + $icon = 'bullet_green'; |
|
292 | + $title = $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.process.success'); |
|
293 | + break; |
|
294 | + case 'cancelled': |
|
295 | + $icon = 'bullet_red'; |
|
296 | + $title = $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.process.cancelled'); |
|
297 | + break; |
|
298 | + } |
|
299 | + |
|
300 | + return $this->getIcon($icon, $title); |
|
301 | + } |
|
302 | + |
|
303 | + /** |
|
304 | + * Returns a tag for the refresh icon |
|
305 | + * |
|
306 | + * @return string |
|
307 | + */ |
|
308 | + protected function getRefreshIcon() { |
|
309 | + return $this->getIcon('arrow_refresh'); |
|
310 | + } |
|
311 | + |
|
312 | + /** |
|
313 | + * Returns a tag for the refresh icon |
|
314 | + * |
|
315 | + * @return string |
|
316 | + */ |
|
317 | + protected function getRefreshLink() { |
|
318 | + return '<input onclick="window.location=\'' . \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_info') . '&SET[crawlaction]=multiprocess&id=' . $this->pageId . '\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\'' . $this->getIconPath() . 'arrow_refresh.png' . '\'); background-repeat: no-repeat;" value="' . $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.refresh') . '" />'; |
|
319 | + } |
|
320 | + |
|
321 | + /** |
|
322 | + * Returns an icon to stop all processes |
|
323 | + * |
|
324 | + * @return string html tag for stop icon |
|
325 | + */ |
|
326 | + protected function getStopIcon() { |
|
327 | + return $this->getIcon('stop'); |
|
328 | + } |
|
329 | + |
|
330 | + /** |
|
331 | + * Returns a link for the panel to enable or disable the crawler |
|
332 | + * |
|
333 | + * @return string |
|
334 | + */ |
|
335 | + protected function getEnableDisableLink() { |
|
336 | + if ($this->getIsCrawlerEnabled()) { |
|
337 | + return '<input onclick="window.location+=\'&action=stopCrawling\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\'' . $this->getIconPath() . 'control_stop_blue.png' . '\'); background-repeat: no-repeat;" value="' . $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.disablecrawling') . '" />'; |
|
338 | + } else { |
|
339 | + return '<input onclick="window.location+=\'&action=resumeCrawling\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\'' . $this->getIconPath() . 'control_play.png' . '\'); background-repeat: no-repeat;" value="' . $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.enablecrawling') . '" />'; |
|
340 | + } |
|
341 | + } |
|
342 | + |
|
343 | + /** |
|
344 | + * Get mode link |
|
345 | + * |
|
346 | + * @param void |
|
347 | + * @return string a-tag |
|
348 | + */ |
|
349 | + protected function getModeLink() { |
|
350 | + if ($this->getMode() == 'detail') { |
|
351 | + return '<input onclick="window.location+=\'&SET[processListMode]=simple\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\'' . $this->getIconPath() . 'arrow_in.png' . '\'); background-repeat: no-repeat;" value="' . $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.show.running') . '" />'; |
|
352 | + } elseif ($this->getMode() == 'simple') { |
|
353 | + return '<input onclick="window.location+=\'&SET[processListMode]=detail\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\'' . $this->getIconPath() . 'arrow_out.png' . '\'); background-repeat: no-repeat;" value="' . $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.show.all') . '" />'; |
|
354 | + } |
|
355 | + } |
|
356 | + |
|
357 | + /** |
|
358 | + * Get add link |
|
359 | + * |
|
360 | + * @param void |
|
361 | + * @return string a-tag |
|
362 | + */ |
|
363 | + protected function getAddLink() { |
|
364 | + if ($this->getActiveProcessCount() < $this->getMaxActiveProcessCount() && $this->getIsCrawlerEnabled()) { |
|
365 | + return '<input onclick="window.location+=\'&action=addProcess\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\'' . $this->getIconPath() . 'add.png' . '\'); background-repeat: no-repeat;" value="' . $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.process.add') . '" />'; |
|
366 | + } else { |
|
367 | + return ''; |
|
368 | + } |
|
369 | + } |
|
370 | + |
|
371 | + /** |
|
372 | + * Returns the icon to add new crawler processes |
|
373 | + * |
|
374 | + * @return string html tag for image to add new processes |
|
375 | + */ |
|
376 | + protected function getAddIcon() { |
|
377 | + return $this->getIcon('add'); |
|
378 | + } |
|
379 | + |
|
380 | + /** |
|
381 | + * Returns an imagetag for an icon |
|
382 | + * |
|
383 | + * @param string $icon |
|
384 | + * @return string html tag for icon |
|
385 | + */ |
|
386 | + protected function getIcon($icon, $title='') { |
|
387 | + if (!empty($title)) { |
|
388 | + $title = ' title="'.$title.'"'; |
|
389 | + } |
|
390 | + return '<img src="'.$this->getIconPath().$icon.'.png" ' . $title . ' />'; |
|
391 | + } |
|
392 | + |
|
393 | + /** |
|
394 | + * Method to render the view. |
|
395 | + * |
|
396 | + * @return string html content |
|
397 | + */ |
|
398 | + public function render() { |
|
399 | + ob_start(); |
|
400 | + $this->template = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($this->template); |
|
401 | + include($this->template); |
|
402 | + $content = ob_get_contents(); |
|
403 | + ob_end_clean(); |
|
404 | + return $content; |
|
405 | + } |
|
406 | + |
|
407 | + /** |
|
408 | + * retrieve locallanglabel from environment |
|
409 | + * just a wrapper should be done in a cleaner way |
|
410 | + * later on |
|
411 | + * |
|
412 | + * @param string $label |
|
413 | + * @return string |
|
414 | + */ |
|
415 | + protected function getLLLabel($label) { |
|
416 | + return $GLOBALS['LANG']->sL($label); |
|
417 | + } |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | ?> |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @return string icon |
283 | 283 | */ |
284 | 284 | protected function getIconForState($state) { |
285 | - switch($state) { |
|
285 | + switch ($state) { |
|
286 | 286 | case 'running': |
287 | 287 | $icon = 'bullet_orange'; |
288 | 288 | $title = $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.process.running'); |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * @return string |
316 | 316 | */ |
317 | 317 | protected function getRefreshLink() { |
318 | - return '<input onclick="window.location=\'' . \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_info') . '&SET[crawlaction]=multiprocess&id=' . $this->pageId . '\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\'' . $this->getIconPath() . 'arrow_refresh.png' . '\'); background-repeat: no-repeat;" value="' . $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.refresh') . '" />'; |
|
318 | + return '<input onclick="window.location=\''.\TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_info').'&SET[crawlaction]=multiprocess&id='.$this->pageId.'\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\''.$this->getIconPath().'arrow_refresh.png'.'\'); background-repeat: no-repeat;" value="'.$this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.refresh').'" />'; |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | /** |
@@ -334,9 +334,9 @@ discard block |
||
334 | 334 | */ |
335 | 335 | protected function getEnableDisableLink() { |
336 | 336 | if ($this->getIsCrawlerEnabled()) { |
337 | - return '<input onclick="window.location+=\'&action=stopCrawling\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\'' . $this->getIconPath() . 'control_stop_blue.png' . '\'); background-repeat: no-repeat;" value="' . $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.disablecrawling') . '" />'; |
|
337 | + return '<input onclick="window.location+=\'&action=stopCrawling\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\''.$this->getIconPath().'control_stop_blue.png'.'\'); background-repeat: no-repeat;" value="'.$this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.disablecrawling').'" />'; |
|
338 | 338 | } else { |
339 | - return '<input onclick="window.location+=\'&action=resumeCrawling\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\'' . $this->getIconPath() . 'control_play.png' . '\'); background-repeat: no-repeat;" value="' . $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.enablecrawling') . '" />'; |
|
339 | + return '<input onclick="window.location+=\'&action=resumeCrawling\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\''.$this->getIconPath().'control_play.png'.'\'); background-repeat: no-repeat;" value="'.$this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.enablecrawling').'" />'; |
|
340 | 340 | } |
341 | 341 | } |
342 | 342 | |
@@ -348,9 +348,9 @@ discard block |
||
348 | 348 | */ |
349 | 349 | protected function getModeLink() { |
350 | 350 | if ($this->getMode() == 'detail') { |
351 | - return '<input onclick="window.location+=\'&SET[processListMode]=simple\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\'' . $this->getIconPath() . 'arrow_in.png' . '\'); background-repeat: no-repeat;" value="' . $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.show.running') . '" />'; |
|
351 | + return '<input onclick="window.location+=\'&SET[processListMode]=simple\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\''.$this->getIconPath().'arrow_in.png'.'\'); background-repeat: no-repeat;" value="'.$this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.show.running').'" />'; |
|
352 | 352 | } elseif ($this->getMode() == 'simple') { |
353 | - return '<input onclick="window.location+=\'&SET[processListMode]=detail\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\'' . $this->getIconPath() . 'arrow_out.png' . '\'); background-repeat: no-repeat;" value="' . $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.show.all') . '" />'; |
|
353 | + return '<input onclick="window.location+=\'&SET[processListMode]=detail\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\''.$this->getIconPath().'arrow_out.png'.'\'); background-repeat: no-repeat;" value="'.$this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.show.all').'" />'; |
|
354 | 354 | } |
355 | 355 | } |
356 | 356 | |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | */ |
363 | 363 | protected function getAddLink() { |
364 | 364 | if ($this->getActiveProcessCount() < $this->getMaxActiveProcessCount() && $this->getIsCrawlerEnabled()) { |
365 | - return '<input onclick="window.location+=\'&action=addProcess\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\'' . $this->getIconPath() . 'add.png' . '\'); background-repeat: no-repeat;" value="' . $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.process.add') . '" />'; |
|
365 | + return '<input onclick="window.location+=\'&action=addProcess\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\''.$this->getIconPath().'add.png'.'\'); background-repeat: no-repeat;" value="'.$this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.process.add').'" />'; |
|
366 | 366 | } else { |
367 | 367 | return ''; |
368 | 368 | } |
@@ -383,11 +383,11 @@ discard block |
||
383 | 383 | * @param string $icon |
384 | 384 | * @return string html tag for icon |
385 | 385 | */ |
386 | - protected function getIcon($icon, $title='') { |
|
386 | + protected function getIcon($icon, $title = '') { |
|
387 | 387 | if (!empty($title)) { |
388 | 388 | $title = ' title="'.$title.'"'; |
389 | 389 | } |
390 | - return '<img src="'.$this->getIconPath().$icon.'.png" ' . $title . ' />'; |
|
390 | + return '<img src="'.$this->getIconPath().$icon.'.png" '.$title.' />'; |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | /** |