@@ -27,126 +27,126 @@ discard block |
||
27 | 27 | * Class tx_crawler_modfunc1 |
28 | 28 | */ |
29 | 29 | class tx_crawler_modfunc1 extends \TYPO3\CMS\Backend\Module\AbstractFunctionModule { |
30 | - // Internal, dynamic: |
|
31 | - var $duplicateTrack = array(); |
|
32 | - var $submitCrawlUrls = FALSE; |
|
33 | - var $downloadCrawlUrls = FALSE; |
|
34 | - |
|
35 | - var $scheduledTime = 0; |
|
36 | - var $reqMinute = 0; |
|
37 | - |
|
38 | - /** |
|
39 | - * @var array holds the selection of configuration from the configuration selector box |
|
40 | - */ |
|
41 | - var $incomingConfigurationSelection = array(); |
|
42 | - |
|
43 | - /** |
|
44 | - * @var tx_crawler_lib |
|
45 | - */ |
|
46 | - var $crawlerObj; |
|
47 | - |
|
48 | - var $CSVaccu = array(); |
|
49 | - |
|
50 | - /** |
|
51 | - * If true the user requested a CSV export of the queue |
|
52 | - * |
|
53 | - * @var boolean |
|
54 | - */ |
|
55 | - var $CSVExport = FALSE; |
|
56 | - |
|
57 | - var $downloadUrls = array(); |
|
58 | - |
|
59 | - /** |
|
60 | - * Holds the configuration from ext_conf_template loaded by loadExtensionSettings() |
|
61 | - * |
|
62 | - * @var array |
|
63 | - */ |
|
64 | - protected $extensionSettings = array(); |
|
65 | - |
|
66 | - /** |
|
67 | - * Indicate that an flash message with an error is present. |
|
68 | - * |
|
69 | - * @var boolean |
|
70 | - */ |
|
71 | - protected $isErrorDetected = false; |
|
72 | - |
|
73 | - /** |
|
74 | - * the constructor |
|
75 | - */ |
|
76 | - public function __construct() { |
|
77 | - $this->processManager = new tx_crawler_domain_process_manager(); |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * Additions to the function menu array |
|
82 | - * |
|
83 | - * @return array Menu array |
|
84 | - */ |
|
85 | - function modMenu() { |
|
86 | - global $LANG; |
|
87 | - |
|
88 | - return array ( |
|
89 | - 'depth' => array( |
|
90 | - 0 => $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.depth_0'), |
|
91 | - 1 => $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.depth_1'), |
|
92 | - 2 => $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.depth_2'), |
|
93 | - 3 => $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.depth_3'), |
|
94 | - 4 => $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.depth_4'), |
|
95 | - 99 => $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.depth_infi'), |
|
96 | - ), |
|
97 | - 'crawlaction' => array( |
|
98 | - 'start' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.start'), |
|
99 | - 'log' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.log'), |
|
100 | - 'multiprocess' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.multiprocess') |
|
101 | - ), |
|
102 | - 'log_resultLog' => '', |
|
103 | - 'log_feVars' => '', |
|
104 | - 'processListMode' => '', |
|
105 | - 'log_display' => array( |
|
106 | - 'all' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.all'), |
|
107 | - 'pending' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.pending'), |
|
108 | - 'finished' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.finished') |
|
109 | - ), |
|
110 | - 'itemsPerPage' => array( |
|
111 | - '5' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.itemsPerPage.5'), |
|
112 | - '10' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.itemsPerPage.10'), |
|
113 | - '50' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.itemsPerPage.50'), |
|
114 | - '0' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.itemsPerPage.0') |
|
115 | - ) |
|
116 | - ); |
|
117 | - } |
|
118 | - |
|
119 | - /** |
|
120 | - * Load extension settings |
|
121 | - * |
|
122 | - * @param void |
|
123 | - * @return void |
|
124 | - */ |
|
125 | - protected function loadExtensionSettings() { |
|
126 | - $this->extensionSettings = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['crawler']); |
|
127 | - } |
|
128 | - |
|
129 | - /** |
|
130 | - * Main function |
|
131 | - * |
|
132 | - * @return string HTML output |
|
133 | - */ |
|
134 | - function main() { |
|
135 | - global $LANG, $BACK_PATH; |
|
136 | - |
|
137 | - $this->incLocalLang(); |
|
138 | - |
|
139 | - $this->loadExtensionSettings(); |
|
140 | - if (empty($this->pObj->MOD_SETTINGS['processListMode'])) { |
|
141 | - $this->pObj->MOD_SETTINGS['processListMode'] = 'simple'; |
|
142 | - } |
|
30 | + // Internal, dynamic: |
|
31 | + var $duplicateTrack = array(); |
|
32 | + var $submitCrawlUrls = FALSE; |
|
33 | + var $downloadCrawlUrls = FALSE; |
|
34 | + |
|
35 | + var $scheduledTime = 0; |
|
36 | + var $reqMinute = 0; |
|
37 | + |
|
38 | + /** |
|
39 | + * @var array holds the selection of configuration from the configuration selector box |
|
40 | + */ |
|
41 | + var $incomingConfigurationSelection = array(); |
|
42 | + |
|
43 | + /** |
|
44 | + * @var tx_crawler_lib |
|
45 | + */ |
|
46 | + var $crawlerObj; |
|
47 | + |
|
48 | + var $CSVaccu = array(); |
|
49 | + |
|
50 | + /** |
|
51 | + * If true the user requested a CSV export of the queue |
|
52 | + * |
|
53 | + * @var boolean |
|
54 | + */ |
|
55 | + var $CSVExport = FALSE; |
|
56 | + |
|
57 | + var $downloadUrls = array(); |
|
58 | + |
|
59 | + /** |
|
60 | + * Holds the configuration from ext_conf_template loaded by loadExtensionSettings() |
|
61 | + * |
|
62 | + * @var array |
|
63 | + */ |
|
64 | + protected $extensionSettings = array(); |
|
65 | + |
|
66 | + /** |
|
67 | + * Indicate that an flash message with an error is present. |
|
68 | + * |
|
69 | + * @var boolean |
|
70 | + */ |
|
71 | + protected $isErrorDetected = false; |
|
72 | + |
|
73 | + /** |
|
74 | + * the constructor |
|
75 | + */ |
|
76 | + public function __construct() { |
|
77 | + $this->processManager = new tx_crawler_domain_process_manager(); |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * Additions to the function menu array |
|
82 | + * |
|
83 | + * @return array Menu array |
|
84 | + */ |
|
85 | + function modMenu() { |
|
86 | + global $LANG; |
|
87 | + |
|
88 | + return array ( |
|
89 | + 'depth' => array( |
|
90 | + 0 => $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.depth_0'), |
|
91 | + 1 => $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.depth_1'), |
|
92 | + 2 => $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.depth_2'), |
|
93 | + 3 => $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.depth_3'), |
|
94 | + 4 => $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.depth_4'), |
|
95 | + 99 => $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.depth_infi'), |
|
96 | + ), |
|
97 | + 'crawlaction' => array( |
|
98 | + 'start' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.start'), |
|
99 | + 'log' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.log'), |
|
100 | + 'multiprocess' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.multiprocess') |
|
101 | + ), |
|
102 | + 'log_resultLog' => '', |
|
103 | + 'log_feVars' => '', |
|
104 | + 'processListMode' => '', |
|
105 | + 'log_display' => array( |
|
106 | + 'all' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.all'), |
|
107 | + 'pending' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.pending'), |
|
108 | + 'finished' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.finished') |
|
109 | + ), |
|
110 | + 'itemsPerPage' => array( |
|
111 | + '5' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.itemsPerPage.5'), |
|
112 | + '10' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.itemsPerPage.10'), |
|
113 | + '50' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.itemsPerPage.50'), |
|
114 | + '0' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.itemsPerPage.0') |
|
115 | + ) |
|
116 | + ); |
|
117 | + } |
|
118 | + |
|
119 | + /** |
|
120 | + * Load extension settings |
|
121 | + * |
|
122 | + * @param void |
|
123 | + * @return void |
|
124 | + */ |
|
125 | + protected function loadExtensionSettings() { |
|
126 | + $this->extensionSettings = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['crawler']); |
|
127 | + } |
|
128 | + |
|
129 | + /** |
|
130 | + * Main function |
|
131 | + * |
|
132 | + * @return string HTML output |
|
133 | + */ |
|
134 | + function main() { |
|
135 | + global $LANG, $BACK_PATH; |
|
136 | + |
|
137 | + $this->incLocalLang(); |
|
138 | + |
|
139 | + $this->loadExtensionSettings(); |
|
140 | + if (empty($this->pObj->MOD_SETTINGS['processListMode'])) { |
|
141 | + $this->pObj->MOD_SETTINGS['processListMode'] = 'simple'; |
|
142 | + } |
|
143 | 143 | |
144 | - // Set CSS styles specific for this document: |
|
145 | - $this->pObj->content = str_replace('/*###POSTCSSMARKER###*/',' |
|
144 | + // Set CSS styles specific for this document: |
|
145 | + $this->pObj->content = str_replace('/*###POSTCSSMARKER###*/',' |
|
146 | 146 | TABLE.c-list TR TD { white-space: nowrap; vertical-align: top; } |
147 | 147 | ',$this->pObj->content); |
148 | 148 | |
149 | - $this->pObj->content .= '<style type="text/css"><!-- |
|
149 | + $this->pObj->content .= '<style type="text/css"><!-- |
|
150 | 150 | table.url-table, |
151 | 151 | table.param-expanded, |
152 | 152 | table.crawlerlog { |
@@ -164,16 +164,16 @@ discard block |
||
164 | 164 | <link rel="stylesheet" type="text/css" href="'.$BACK_PATH.'../typo3conf/ext/crawler/template/res.css" /> |
165 | 165 | '; |
166 | 166 | |
167 | - // Type function menu: |
|
168 | - $h_func = \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu( |
|
169 | - $this->pObj->id, |
|
170 | - 'SET[crawlaction]', |
|
171 | - $this->pObj->MOD_SETTINGS['crawlaction'], |
|
172 | - $this->pObj->MOD_MENU['crawlaction'], |
|
173 | - 'index.php' |
|
174 | - ); |
|
167 | + // Type function menu: |
|
168 | + $h_func = \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu( |
|
169 | + $this->pObj->id, |
|
170 | + 'SET[crawlaction]', |
|
171 | + $this->pObj->MOD_SETTINGS['crawlaction'], |
|
172 | + $this->pObj->MOD_MENU['crawlaction'], |
|
173 | + 'index.php' |
|
174 | + ); |
|
175 | 175 | |
176 | - /* |
|
176 | + /* |
|
177 | 177 | // Showing depth-menu in certain cases: |
178 | 178 | if ($this->pObj->MOD_SETTINGS['crawlaction']!=='cli' && $this->pObj->MOD_SETTINGS['crawlaction']!== 'multiprocess' && ($this->pObj->MOD_SETTINGS['crawlaction']!=='log' || $this->pObj->id)) { |
179 | 179 | $h_func .= \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu( |
@@ -186,63 +186,63 @@ discard block |
||
186 | 186 | } |
187 | 187 | */ |
188 | 188 | |
189 | - // Additional menus for the log type: |
|
190 | - if ($this->pObj->MOD_SETTINGS['crawlaction']==='log') { |
|
191 | - $h_func .= \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu( |
|
192 | - $this->pObj->id, |
|
193 | - 'SET[depth]', |
|
194 | - $this->pObj->MOD_SETTINGS['depth'], |
|
195 | - $this->pObj->MOD_MENU['depth'], |
|
196 | - 'index.php' |
|
197 | - ); |
|
189 | + // Additional menus for the log type: |
|
190 | + if ($this->pObj->MOD_SETTINGS['crawlaction']==='log') { |
|
191 | + $h_func .= \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu( |
|
192 | + $this->pObj->id, |
|
193 | + 'SET[depth]', |
|
194 | + $this->pObj->MOD_SETTINGS['depth'], |
|
195 | + $this->pObj->MOD_MENU['depth'], |
|
196 | + 'index.php' |
|
197 | + ); |
|
198 | + |
|
199 | + $quiPart = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('qid_details') ? '&qid_details=' . intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('qid_details')) : ''; |
|
200 | + |
|
201 | + $setId = intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('setID')); |
|
202 | + |
|
203 | + $h_func.= '<hr/>'. |
|
204 | + $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.display').': '.\TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu($this->pObj->id,'SET[log_display]',$this->pObj->MOD_SETTINGS['log_display'],$this->pObj->MOD_MENU['log_display'],'index.php','&setID='.$setId) . ' - ' . |
|
205 | + $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.showresultlog').': '.\TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->pObj->id,'SET[log_resultLog]',$this->pObj->MOD_SETTINGS['log_resultLog'],'index.php','&setID='.$setId . $quiPart) . ' - ' . |
|
206 | + $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.showfevars').': '.\TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->pObj->id,'SET[log_feVars]',$this->pObj->MOD_SETTINGS['log_feVars'],'index.php','&setID='.$setId . $quiPart) . ' - ' . |
|
207 | + $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.itemsPerPage').': ' . |
|
208 | + \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu( |
|
209 | + $this->pObj->id, |
|
210 | + 'SET[itemsPerPage]', |
|
211 | + $this->pObj->MOD_SETTINGS['itemsPerPage'], |
|
212 | + $this->pObj->MOD_MENU['itemsPerPage'], |
|
213 | + 'index.php' |
|
214 | + ); |
|
215 | + } |
|
198 | 216 | |
199 | - $quiPart = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('qid_details') ? '&qid_details=' . intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('qid_details')) : ''; |
|
200 | - |
|
201 | - $setId = intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('setID')); |
|
202 | - |
|
203 | - $h_func.= '<hr/>'. |
|
204 | - $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.display').': '.\TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu($this->pObj->id,'SET[log_display]',$this->pObj->MOD_SETTINGS['log_display'],$this->pObj->MOD_MENU['log_display'],'index.php','&setID='.$setId) . ' - ' . |
|
205 | - $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.showresultlog').': '.\TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->pObj->id,'SET[log_resultLog]',$this->pObj->MOD_SETTINGS['log_resultLog'],'index.php','&setID='.$setId . $quiPart) . ' - ' . |
|
206 | - $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.showfevars').': '.\TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->pObj->id,'SET[log_feVars]',$this->pObj->MOD_SETTINGS['log_feVars'],'index.php','&setID='.$setId . $quiPart) . ' - ' . |
|
207 | - $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.itemsPerPage').': ' . |
|
208 | - \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu( |
|
209 | - $this->pObj->id, |
|
210 | - 'SET[itemsPerPage]', |
|
211 | - $this->pObj->MOD_SETTINGS['itemsPerPage'], |
|
212 | - $this->pObj->MOD_MENU['itemsPerPage'], |
|
213 | - 'index.php' |
|
214 | - ); |
|
215 | - } |
|
217 | + $theOutput= $this->pObj->doc->spacer(5); |
|
218 | + $theOutput.= $this->pObj->doc->section($LANG->getLL('title'), $h_func, 0, 1); |
|
216 | 219 | |
217 | - $theOutput= $this->pObj->doc->spacer(5); |
|
218 | - $theOutput.= $this->pObj->doc->section($LANG->getLL('title'), $h_func, 0, 1); |
|
219 | - |
|
220 | - // Branch based on type: |
|
221 | - switch ((string)$this->pObj->MOD_SETTINGS['crawlaction']) { |
|
222 | - case 'start': |
|
223 | - if (empty($this->pObj->id)) { |
|
224 | - $this->addErrorMessage($GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.noPageSelected')); |
|
225 | - } else { |
|
226 | - $theOutput .= $this->pObj->doc->section('', $this->drawURLs(), 0, 1); |
|
227 | - } |
|
228 | - break; |
|
229 | - case 'log': |
|
230 | - if (empty($this->pObj->id)) { |
|
231 | - $this->addErrorMessage($GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.noPageSelected')); |
|
232 | - } else { |
|
233 | - $theOutput .= $this->pObj->doc->section('', $this->drawLog(), 0, 1); |
|
234 | - } |
|
235 | - break; |
|
236 | - case 'cli': |
|
237 | - $theOutput .= $this->pObj->doc->section('', $this->drawCLIstatus(), 0, 1); |
|
238 | - break; |
|
239 | - case 'multiprocess': |
|
240 | - $theOutput .= $this->pObj->doc->section('', $this->drawProcessOverviewAction(), 0, 1); |
|
241 | - break; |
|
242 | - } |
|
220 | + // Branch based on type: |
|
221 | + switch ((string)$this->pObj->MOD_SETTINGS['crawlaction']) { |
|
222 | + case 'start': |
|
223 | + if (empty($this->pObj->id)) { |
|
224 | + $this->addErrorMessage($GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.noPageSelected')); |
|
225 | + } else { |
|
226 | + $theOutput .= $this->pObj->doc->section('', $this->drawURLs(), 0, 1); |
|
227 | + } |
|
228 | + break; |
|
229 | + case 'log': |
|
230 | + if (empty($this->pObj->id)) { |
|
231 | + $this->addErrorMessage($GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.noPageSelected')); |
|
232 | + } else { |
|
233 | + $theOutput .= $this->pObj->doc->section('', $this->drawLog(), 0, 1); |
|
234 | + } |
|
235 | + break; |
|
236 | + case 'cli': |
|
237 | + $theOutput .= $this->pObj->doc->section('', $this->drawCLIstatus(), 0, 1); |
|
238 | + break; |
|
239 | + case 'multiprocess': |
|
240 | + $theOutput .= $this->pObj->doc->section('', $this->drawProcessOverviewAction(), 0, 1); |
|
241 | + break; |
|
242 | + } |
|
243 | 243 | |
244 | - return $theOutput; |
|
245 | - } |
|
244 | + return $theOutput; |
|
245 | + } |
|
246 | 246 | |
247 | 247 | |
248 | 248 | |
@@ -255,176 +255,176 @@ discard block |
||
255 | 255 | |
256 | 256 | |
257 | 257 | |
258 | - /******************************* |
|
258 | + /******************************* |
|
259 | 259 | * |
260 | 260 | * Generate URLs for crawling: |
261 | 261 | * |
262 | 262 | ******************************/ |
263 | 263 | |
264 | - /** |
|
265 | - * Produces a table with overview of the URLs to be crawled for each page |
|
266 | - * |
|
267 | - * @return string HTML output |
|
268 | - */ |
|
269 | - function drawURLs() { |
|
270 | - global $BACK_PATH, $BE_USER; |
|
271 | - |
|
272 | - // Init: |
|
273 | - $this->duplicateTrack = array(); |
|
274 | - $this->submitCrawlUrls = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('_crawl'); |
|
275 | - $this->downloadCrawlUrls = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('_download'); |
|
276 | - $this->makeCrawlerProcessableChecks(); |
|
277 | - |
|
278 | - switch((string)\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('tstamp')) { |
|
279 | - case 'midnight': |
|
280 | - $this->scheduledTime = mktime(0,0,0); |
|
281 | - break; |
|
282 | - case '04:00': |
|
283 | - $this->scheduledTime = mktime(0,0,0)+4*3600; |
|
284 | - break; |
|
285 | - case 'now': |
|
286 | - default: |
|
287 | - $this->scheduledTime = time(); |
|
288 | - break; |
|
289 | - } |
|
290 | - // $this->reqMinute = \TYPO3\CMS\Core\Utility\GeneralUtility::intInRange(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('perminute'),1,10000); |
|
291 | - // TODO: check relevance |
|
292 | - $this->reqMinute = 1000; |
|
264 | + /** |
|
265 | + * Produces a table with overview of the URLs to be crawled for each page |
|
266 | + * |
|
267 | + * @return string HTML output |
|
268 | + */ |
|
269 | + function drawURLs() { |
|
270 | + global $BACK_PATH, $BE_USER; |
|
271 | + |
|
272 | + // Init: |
|
273 | + $this->duplicateTrack = array(); |
|
274 | + $this->submitCrawlUrls = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('_crawl'); |
|
275 | + $this->downloadCrawlUrls = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('_download'); |
|
276 | + $this->makeCrawlerProcessableChecks(); |
|
277 | + |
|
278 | + switch((string)\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('tstamp')) { |
|
279 | + case 'midnight': |
|
280 | + $this->scheduledTime = mktime(0,0,0); |
|
281 | + break; |
|
282 | + case '04:00': |
|
283 | + $this->scheduledTime = mktime(0,0,0)+4*3600; |
|
284 | + break; |
|
285 | + case 'now': |
|
286 | + default: |
|
287 | + $this->scheduledTime = time(); |
|
288 | + break; |
|
289 | + } |
|
290 | + // $this->reqMinute = \TYPO3\CMS\Core\Utility\GeneralUtility::intInRange(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('perminute'),1,10000); |
|
291 | + // TODO: check relevance |
|
292 | + $this->reqMinute = 1000; |
|
293 | 293 | |
294 | 294 | |
295 | - $this->incomingConfigurationSelection = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('configurationSelection'); |
|
296 | - $this->incomingConfigurationSelection = is_array($this->incomingConfigurationSelection) ? $this->incomingConfigurationSelection : array(''); |
|
295 | + $this->incomingConfigurationSelection = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('configurationSelection'); |
|
296 | + $this->incomingConfigurationSelection = is_array($this->incomingConfigurationSelection) ? $this->incomingConfigurationSelection : array(''); |
|
297 | 297 | |
298 | - $this->crawlerObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_crawler_lib'); |
|
299 | - $this->crawlerObj->setAccessMode('gui'); |
|
300 | - $this->crawlerObj->setID = \TYPO3\CMS\Core\Utility\GeneralUtility::md5int(microtime()); |
|
298 | + $this->crawlerObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_crawler_lib'); |
|
299 | + $this->crawlerObj->setAccessMode('gui'); |
|
300 | + $this->crawlerObj->setID = \TYPO3\CMS\Core\Utility\GeneralUtility::md5int(microtime()); |
|
301 | 301 | |
302 | - if (empty($this->incomingConfigurationSelection) |
|
303 | - || (count($this->incomingConfigurationSelection)==1 && empty($this->incomingConfigurationSelection[0])) |
|
304 | - ) { |
|
305 | - $code= ' |
|
302 | + if (empty($this->incomingConfigurationSelection) |
|
303 | + || (count($this->incomingConfigurationSelection)==1 && empty($this->incomingConfigurationSelection[0])) |
|
304 | + ) { |
|
305 | + $code= ' |
|
306 | 306 | <tr> |
307 | 307 | <td colspan="7"><b>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.noConfigSelected').'</b></td> |
308 | 308 | </tr>'; |
309 | - } else { |
|
310 | - if($this->submitCrawlUrls){ |
|
311 | - $reason = new tx_crawler_domain_reason(); |
|
312 | - $reason->setReason(tx_crawler_domain_reason::REASON_GUI_SUBMIT); |
|
313 | - |
|
314 | - if($BE_USER instanceof \TYPO3\CMS\Core\Authentication\BackendUserAuthentication){ $username = $BE_USER->user['username']; } |
|
315 | - $reason->setDetailText('The user '.$username.' added pages to the crawler queue manually '); |
|
316 | - |
|
317 | - tx_crawler_domain_events_dispatcher::getInstance()->post( 'invokeQueueChange', |
|
318 | - $this->findCrawler()->setID, |
|
319 | - array( 'reason' => $reason )); |
|
320 | - } |
|
321 | - |
|
322 | - $code = $this->crawlerObj->getPageTreeAndUrls( |
|
323 | - $this->pObj->id, |
|
324 | - $this->pObj->MOD_SETTINGS['depth'], |
|
325 | - $this->scheduledTime, |
|
326 | - $this->reqMinute, |
|
327 | - $this->submitCrawlUrls, |
|
328 | - $this->downloadCrawlUrls, |
|
329 | - array(), // Do not filter any processing instructions |
|
330 | - $this->incomingConfigurationSelection |
|
331 | - ); |
|
309 | + } else { |
|
310 | + if($this->submitCrawlUrls){ |
|
311 | + $reason = new tx_crawler_domain_reason(); |
|
312 | + $reason->setReason(tx_crawler_domain_reason::REASON_GUI_SUBMIT); |
|
313 | + |
|
314 | + if($BE_USER instanceof \TYPO3\CMS\Core\Authentication\BackendUserAuthentication){ $username = $BE_USER->user['username']; } |
|
315 | + $reason->setDetailText('The user '.$username.' added pages to the crawler queue manually '); |
|
316 | + |
|
317 | + tx_crawler_domain_events_dispatcher::getInstance()->post( 'invokeQueueChange', |
|
318 | + $this->findCrawler()->setID, |
|
319 | + array( 'reason' => $reason )); |
|
320 | + } |
|
321 | + |
|
322 | + $code = $this->crawlerObj->getPageTreeAndUrls( |
|
323 | + $this->pObj->id, |
|
324 | + $this->pObj->MOD_SETTINGS['depth'], |
|
325 | + $this->scheduledTime, |
|
326 | + $this->reqMinute, |
|
327 | + $this->submitCrawlUrls, |
|
328 | + $this->downloadCrawlUrls, |
|
329 | + array(), // Do not filter any processing instructions |
|
330 | + $this->incomingConfigurationSelection |
|
331 | + ); |
|
332 | 332 | |
333 | 333 | |
334 | - } |
|
334 | + } |
|
335 | 335 | |
336 | - $this->downloadUrls = $this->crawlerObj->downloadUrls; |
|
337 | - $this->duplicateTrack = $this->crawlerObj->duplicateTrack; |
|
336 | + $this->downloadUrls = $this->crawlerObj->downloadUrls; |
|
337 | + $this->duplicateTrack = $this->crawlerObj->duplicateTrack; |
|
338 | 338 | |
339 | - $output = ''; |
|
340 | - if ($code) { |
|
339 | + $output = ''; |
|
340 | + if ($code) { |
|
341 | 341 | |
342 | - $output .= '<h3>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.configuration').':</h3>'; |
|
343 | - $output .= '<input type="hidden" name="id" value="'.intval($this->pObj->id).'" />'; |
|
342 | + $output .= '<h3>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.configuration').':</h3>'; |
|
343 | + $output .= '<input type="hidden" name="id" value="'.intval($this->pObj->id).'" />'; |
|
344 | 344 | |
345 | - if (!$this->submitCrawlUrls) { |
|
346 | - $output .= $this->drawURLs_cfgSelectors().'<br />'; |
|
347 | - $output .= '<input type="submit" name="_update" value="'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.triggerUpdate').'" /> '; |
|
348 | - $output .= '<input type="submit" name="_crawl" value="'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.triggerCrawl').'" /> '; |
|
349 | - $output .= '<input type="submit" name="_download" value="'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.triggerDownload').'" /><br /><br />'; |
|
350 | - $output .= $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.count').': '.count(array_keys($this->duplicateTrack)).'<br />'; |
|
351 | - $output .= $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.curtime').': '.date('H:i:s',time()).'<br />'; |
|
352 | - $output .= '<br /> |
|
345 | + if (!$this->submitCrawlUrls) { |
|
346 | + $output .= $this->drawURLs_cfgSelectors().'<br />'; |
|
347 | + $output .= '<input type="submit" name="_update" value="'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.triggerUpdate').'" /> '; |
|
348 | + $output .= '<input type="submit" name="_crawl" value="'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.triggerCrawl').'" /> '; |
|
349 | + $output .= '<input type="submit" name="_download" value="'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.triggerDownload').'" /><br /><br />'; |
|
350 | + $output .= $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.count').': '.count(array_keys($this->duplicateTrack)).'<br />'; |
|
351 | + $output .= $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.curtime').': '.date('H:i:s',time()).'<br />'; |
|
352 | + $output .= '<br /> |
|
353 | 353 | <table class="lrPadding c-list url-table">'. |
354 | - $this->drawURLs_printTableHeader(). |
|
355 | - $code. |
|
356 | - '</table>'; |
|
357 | - } else { |
|
358 | - $output .= count(array_keys($this->duplicateTrack)).' '.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.submitted').'. <br /><br />'; |
|
359 | - $output .= '<input type="submit" name="_" value="'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.continue').'" />'; |
|
360 | - $output .= '<input type="submit" onclick="this.form.elements[\'SET[crawlaction]\'].value=\'log\';" value="'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.continueinlog').'" />'; |
|
361 | - } |
|
362 | - } |
|
363 | - |
|
364 | - // Download Urls to crawl: |
|
365 | - if ($this->downloadCrawlUrls) { |
|
366 | - |
|
367 | - // Creating output header: |
|
368 | - $mimeType = 'application/octet-stream'; |
|
369 | - Header('Content-Type: '.$mimeType); |
|
370 | - Header('Content-Disposition: attachment; filename=CrawlerUrls.txt'); |
|
371 | - |
|
372 | - // Printing the content of the CSV lines: |
|
373 | - echo implode(chr(13).chr(10),$this->downloadUrls); |
|
374 | - |
|
375 | - // Exits: |
|
376 | - exit; |
|
377 | - } |
|
378 | - |
|
379 | - // Return output: |
|
380 | - return $output; |
|
381 | - } |
|
354 | + $this->drawURLs_printTableHeader(). |
|
355 | + $code. |
|
356 | + '</table>'; |
|
357 | + } else { |
|
358 | + $output .= count(array_keys($this->duplicateTrack)).' '.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.submitted').'. <br /><br />'; |
|
359 | + $output .= '<input type="submit" name="_" value="'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.continue').'" />'; |
|
360 | + $output .= '<input type="submit" onclick="this.form.elements[\'SET[crawlaction]\'].value=\'log\';" value="'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.continueinlog').'" />'; |
|
361 | + } |
|
362 | + } |
|
382 | 363 | |
383 | - /** |
|
384 | - * Draws the configuration selectors for compiling URLs: |
|
385 | - * |
|
386 | - * @return string HTML table |
|
387 | - */ |
|
388 | - function drawURLs_cfgSelectors() { |
|
364 | + // Download Urls to crawl: |
|
365 | + if ($this->downloadCrawlUrls) { |
|
389 | 366 | |
390 | - // depth |
|
391 | - $cell[] = $this->selectorBox( |
|
392 | - array( |
|
393 | - 0 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.depth_0'), |
|
394 | - 1 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.depth_1'), |
|
395 | - 2 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.depth_2'), |
|
396 | - 3 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.depth_3'), |
|
397 | - 4 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.depth_4'), |
|
398 | - 99 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.depth_infi'), |
|
399 | - ), |
|
400 | - 'SET[depth]', |
|
401 | - $this->pObj->MOD_SETTINGS['depth'], |
|
402 | - 0 |
|
403 | - ); |
|
404 | - $availableConfigurations = $this->crawlerObj->getConfigurationsForBranch($this->pObj->id, $this->pObj->MOD_SETTINGS['depth']?$this->pObj->MOD_SETTINGS['depth']:0 ); |
|
367 | + // Creating output header: |
|
368 | + $mimeType = 'application/octet-stream'; |
|
369 | + Header('Content-Type: '.$mimeType); |
|
370 | + Header('Content-Disposition: attachment; filename=CrawlerUrls.txt'); |
|
405 | 371 | |
406 | - // Configurations |
|
407 | - $cell[] = $this->selectorBox( |
|
408 | - empty($availableConfigurations)?array():array_combine($availableConfigurations, $availableConfigurations), |
|
409 | - 'configurationSelection', |
|
410 | - $this->incomingConfigurationSelection, |
|
411 | - 1 |
|
412 | - ); |
|
372 | + // Printing the content of the CSV lines: |
|
373 | + echo implode(chr(13).chr(10),$this->downloadUrls); |
|
413 | 374 | |
414 | - // Scheduled time: |
|
415 | - $cell[] = $this->selectorBox( |
|
416 | - array( |
|
417 | - 'now' => $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.time.now'), |
|
418 | - 'midnight' => $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.time.midnight'), |
|
419 | - '04:00' => $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.time.4am'), |
|
420 | - ), |
|
421 | - 'tstamp', |
|
422 | - \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('tstamp'), |
|
423 | - 0 |
|
424 | - ); |
|
375 | + // Exits: |
|
376 | + exit; |
|
377 | + } |
|
425 | 378 | |
426 | - // TODO: check relevance |
|
427 | - /* |
|
379 | + // Return output: |
|
380 | + return $output; |
|
381 | + } |
|
382 | + |
|
383 | + /** |
|
384 | + * Draws the configuration selectors for compiling URLs: |
|
385 | + * |
|
386 | + * @return string HTML table |
|
387 | + */ |
|
388 | + function drawURLs_cfgSelectors() { |
|
389 | + |
|
390 | + // depth |
|
391 | + $cell[] = $this->selectorBox( |
|
392 | + array( |
|
393 | + 0 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.depth_0'), |
|
394 | + 1 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.depth_1'), |
|
395 | + 2 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.depth_2'), |
|
396 | + 3 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.depth_3'), |
|
397 | + 4 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.depth_4'), |
|
398 | + 99 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.depth_infi'), |
|
399 | + ), |
|
400 | + 'SET[depth]', |
|
401 | + $this->pObj->MOD_SETTINGS['depth'], |
|
402 | + 0 |
|
403 | + ); |
|
404 | + $availableConfigurations = $this->crawlerObj->getConfigurationsForBranch($this->pObj->id, $this->pObj->MOD_SETTINGS['depth']?$this->pObj->MOD_SETTINGS['depth']:0 ); |
|
405 | + |
|
406 | + // Configurations |
|
407 | + $cell[] = $this->selectorBox( |
|
408 | + empty($availableConfigurations)?array():array_combine($availableConfigurations, $availableConfigurations), |
|
409 | + 'configurationSelection', |
|
410 | + $this->incomingConfigurationSelection, |
|
411 | + 1 |
|
412 | + ); |
|
413 | + |
|
414 | + // Scheduled time: |
|
415 | + $cell[] = $this->selectorBox( |
|
416 | + array( |
|
417 | + 'now' => $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.time.now'), |
|
418 | + 'midnight' => $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.time.midnight'), |
|
419 | + '04:00' => $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.time.4am'), |
|
420 | + ), |
|
421 | + 'tstamp', |
|
422 | + \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('tstamp'), |
|
423 | + 0 |
|
424 | + ); |
|
425 | + |
|
426 | + // TODO: check relevance |
|
427 | + /* |
|
428 | 428 | // Requests per minute: |
429 | 429 | $cell[] = $this->selectorBox( |
430 | 430 | array( |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | ); |
446 | 446 | */ |
447 | 447 | |
448 | - $output = ' |
|
448 | + $output = ' |
|
449 | 449 | <table class="lrPadding c-list"> |
450 | 450 | <tr class="bgColor5 tableheader"> |
451 | 451 | <td>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.depth').':</td> |
@@ -458,17 +458,17 @@ discard block |
||
458 | 458 | </tr> |
459 | 459 | </table>'; |
460 | 460 | |
461 | - return $output; |
|
462 | - } |
|
461 | + return $output; |
|
462 | + } |
|
463 | 463 | |
464 | - /** |
|
465 | - * Create Table header row for URL display |
|
466 | - * |
|
467 | - * @return string Table header |
|
468 | - */ |
|
469 | - function drawURLs_printTableHeader() { |
|
464 | + /** |
|
465 | + * Create Table header row for URL display |
|
466 | + * |
|
467 | + * @return string Table header |
|
468 | + */ |
|
469 | + function drawURLs_printTableHeader() { |
|
470 | 470 | |
471 | - $content = ' |
|
471 | + $content = ' |
|
472 | 472 | <tr class="bgColor5 tableheader"> |
473 | 473 | <td>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.pagetitle').':</td> |
474 | 474 | <td>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.key').':</td> |
@@ -479,8 +479,8 @@ discard block |
||
479 | 479 | <td>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.parameters').':</td> |
480 | 480 | </tr>'; |
481 | 481 | |
482 | - return $content; |
|
483 | - } |
|
482 | + return $content; |
|
483 | + } |
|
484 | 484 | |
485 | 485 | |
486 | 486 | |
@@ -493,109 +493,109 @@ discard block |
||
493 | 493 | |
494 | 494 | |
495 | 495 | |
496 | - /******************************* |
|
496 | + /******************************* |
|
497 | 497 | * |
498 | 498 | * Shows log of indexed URLs |
499 | 499 | * |
500 | 500 | ******************************/ |
501 | 501 | |
502 | - /** |
|
503 | - * Shows the log of indexed URLs |
|
504 | - * |
|
505 | - * @return string HTML output |
|
506 | - */ |
|
507 | - function drawLog() { |
|
508 | - global $BACK_PATH; |
|
509 | - $output = ''; |
|
510 | - |
|
511 | - // Init: |
|
512 | - $this->crawlerObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_crawler_lib'); |
|
513 | - $this->crawlerObj->setAccessMode('gui'); |
|
514 | - $this->crawlerObj->setID = \TYPO3\CMS\Core\Utility\GeneralUtility::md5int(microtime()); |
|
515 | - |
|
516 | - $this->CSVExport = \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('_csv'); |
|
517 | - |
|
518 | - // Read URL: |
|
519 | - if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('qid_read')) { |
|
520 | - $this->crawlerObj->readUrl(intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('qid_read')),TRUE); |
|
521 | - } |
|
502 | + /** |
|
503 | + * Shows the log of indexed URLs |
|
504 | + * |
|
505 | + * @return string HTML output |
|
506 | + */ |
|
507 | + function drawLog() { |
|
508 | + global $BACK_PATH; |
|
509 | + $output = ''; |
|
510 | + |
|
511 | + // Init: |
|
512 | + $this->crawlerObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_crawler_lib'); |
|
513 | + $this->crawlerObj->setAccessMode('gui'); |
|
514 | + $this->crawlerObj->setID = \TYPO3\CMS\Core\Utility\GeneralUtility::md5int(microtime()); |
|
515 | + |
|
516 | + $this->CSVExport = \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('_csv'); |
|
517 | + |
|
518 | + // Read URL: |
|
519 | + if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('qid_read')) { |
|
520 | + $this->crawlerObj->readUrl(intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('qid_read')),TRUE); |
|
521 | + } |
|
522 | 522 | |
523 | - // Look for set ID sent - if it is, we will display contents of that set: |
|
524 | - $showSetId = intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('setID')); |
|
523 | + // Look for set ID sent - if it is, we will display contents of that set: |
|
524 | + $showSetId = intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('setID')); |
|
525 | 525 | |
526 | - // Show details: |
|
527 | - if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('qid_details')) { |
|
526 | + // Show details: |
|
527 | + if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('qid_details')) { |
|
528 | 528 | |
529 | - // Get entry record: |
|
530 | - list($q_entry) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*','tx_crawler_queue','qid='.intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('qid_details'))); |
|
529 | + // Get entry record: |
|
530 | + list($q_entry) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*','tx_crawler_queue','qid='.intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('qid_details'))); |
|
531 | 531 | |
532 | - // Explode values: |
|
533 | - $resStatus = $this->getResStatus($q_entry); |
|
534 | - $q_entry['parameters'] = unserialize($q_entry['parameters']); |
|
535 | - $q_entry['result_data'] = unserialize($q_entry['result_data']); |
|
536 | - if (is_array($q_entry['result_data'])) { |
|
537 | - $q_entry['result_data']['content'] = unserialize($q_entry['result_data']['content']); |
|
538 | - } |
|
532 | + // Explode values: |
|
533 | + $resStatus = $this->getResStatus($q_entry); |
|
534 | + $q_entry['parameters'] = unserialize($q_entry['parameters']); |
|
535 | + $q_entry['result_data'] = unserialize($q_entry['result_data']); |
|
536 | + if (is_array($q_entry['result_data'])) { |
|
537 | + $q_entry['result_data']['content'] = unserialize($q_entry['result_data']['content']); |
|
538 | + } |
|
539 | 539 | |
540 | - if(!$this->pObj->MOD_SETTINGS['log_resultLog']) { |
|
541 | - unset($q_entry['result_data']['content']['log']); |
|
542 | - } |
|
540 | + if(!$this->pObj->MOD_SETTINGS['log_resultLog']) { |
|
541 | + unset($q_entry['result_data']['content']['log']); |
|
542 | + } |
|
543 | 543 | |
544 | - // Print rudimentary details: |
|
545 | - $output .= ' |
|
544 | + // Print rudimentary details: |
|
545 | + $output .= ' |
|
546 | 546 | <br /><br /> |
547 | 547 | <input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.back') . '" name="_back" /> |
548 | 548 | <input type="hidden" value="' . $this->pObj->id . '" name="id" /> |
549 | 549 | <input type="hidden" value="' . $showSetId . '" name="setID" /> |
550 | 550 | <br /> |
551 | 551 | Current server time: ' . date('H:i:s', time()) . '<br />' . |
552 | - 'Status: ' . $resStatus . '<br />' . |
|
553 | - \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($q_entry); |
|
554 | - } else { // Show list: |
|
555 | - |
|
556 | - // If either id or set id, show list: |
|
557 | - if ($this->pObj->id || $showSetId) { |
|
558 | - if ($this->pObj->id) { |
|
559 | - // Drawing tree: |
|
560 | - $tree = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Backend\Tree\View\PageTreeView'); |
|
561 | - $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1); |
|
562 | - $tree->init('AND '.$perms_clause); |
|
563 | - |
|
564 | - // Set root row: |
|
565 | - $HTML = \AOE\Crawler\Utility\IconUtility::getIconForRecord('pages', $this->pObj->pageinfo); |
|
566 | - $tree->tree[] = Array( |
|
567 | - 'row' => $this->pObj->pageinfo, |
|
568 | - 'HTML' => $HTML |
|
569 | - ); |
|
570 | - |
|
571 | - // Get branch beneath: |
|
572 | - if ($this->pObj->MOD_SETTINGS['depth']) { |
|
573 | - $tree->getTree($this->pObj->id, $this->pObj->MOD_SETTINGS['depth'], ''); |
|
574 | - } |
|
575 | - |
|
576 | - // Traverse page tree: |
|
577 | - $code = ''; $count = 0; |
|
578 | - foreach($tree->tree as $data) { |
|
579 | - $code .= $this->drawLog_addRows( |
|
580 | - $data['row'], |
|
581 | - $data['HTML'] . \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle('pages',$data['row'],TRUE), |
|
582 | - intval($this->pObj->MOD_SETTINGS['itemsPerPage']) |
|
583 | - ); |
|
584 | - if (++$count == 1000) { |
|
585 | - break; |
|
586 | - } |
|
587 | - } |
|
588 | - } else { |
|
589 | - $code = ''; |
|
590 | - $code.= $this->drawLog_addRows( |
|
591 | - $showSetId, |
|
592 | - 'Set ID: '.$showSetId |
|
593 | - ); |
|
594 | - } |
|
595 | - |
|
596 | - if ($code) { |
|
597 | - |
|
598 | - $output .= ' |
|
552 | + 'Status: ' . $resStatus . '<br />' . |
|
553 | + \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($q_entry); |
|
554 | + } else { // Show list: |
|
555 | + |
|
556 | + // If either id or set id, show list: |
|
557 | + if ($this->pObj->id || $showSetId) { |
|
558 | + if ($this->pObj->id) { |
|
559 | + // Drawing tree: |
|
560 | + $tree = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Backend\Tree\View\PageTreeView'); |
|
561 | + $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1); |
|
562 | + $tree->init('AND '.$perms_clause); |
|
563 | + |
|
564 | + // Set root row: |
|
565 | + $HTML = \AOE\Crawler\Utility\IconUtility::getIconForRecord('pages', $this->pObj->pageinfo); |
|
566 | + $tree->tree[] = Array( |
|
567 | + 'row' => $this->pObj->pageinfo, |
|
568 | + 'HTML' => $HTML |
|
569 | + ); |
|
570 | + |
|
571 | + // Get branch beneath: |
|
572 | + if ($this->pObj->MOD_SETTINGS['depth']) { |
|
573 | + $tree->getTree($this->pObj->id, $this->pObj->MOD_SETTINGS['depth'], ''); |
|
574 | + } |
|
575 | + |
|
576 | + // Traverse page tree: |
|
577 | + $code = ''; $count = 0; |
|
578 | + foreach($tree->tree as $data) { |
|
579 | + $code .= $this->drawLog_addRows( |
|
580 | + $data['row'], |
|
581 | + $data['HTML'] . \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle('pages',$data['row'],TRUE), |
|
582 | + intval($this->pObj->MOD_SETTINGS['itemsPerPage']) |
|
583 | + ); |
|
584 | + if (++$count == 1000) { |
|
585 | + break; |
|
586 | + } |
|
587 | + } |
|
588 | + } else { |
|
589 | + $code = ''; |
|
590 | + $code.= $this->drawLog_addRows( |
|
591 | + $showSetId, |
|
592 | + 'Set ID: '.$showSetId |
|
593 | + ); |
|
594 | + } |
|
595 | + |
|
596 | + if ($code) { |
|
597 | + |
|
598 | + $output .= ' |
|
599 | 599 | <br /><br /> |
600 | 600 | <input type="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.reloadlist').'" name="_reload" /> |
601 | 601 | <input type="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.downloadcsv').'" name="_csv" /> |
@@ -609,20 +609,20 @@ discard block |
||
609 | 609 | |
610 | 610 | |
611 | 611 | <table class="lrPadding c-list crawlerlog">'. |
612 | - $this->drawLog_printTableHeader(). |
|
613 | - $code. |
|
614 | - '</table>'; |
|
615 | - } |
|
616 | - } else { // Otherwise show available sets: |
|
617 | - $setList = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( |
|
618 | - 'set_id, count(*) as count_value, scheduled', |
|
619 | - 'tx_crawler_queue', |
|
620 | - '', |
|
621 | - 'set_id, scheduled', |
|
622 | - 'scheduled DESC' |
|
623 | - ); |
|
624 | - |
|
625 | - $code = ' |
|
612 | + $this->drawLog_printTableHeader(). |
|
613 | + $code. |
|
614 | + '</table>'; |
|
615 | + } |
|
616 | + } else { // Otherwise show available sets: |
|
617 | + $setList = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( |
|
618 | + 'set_id, count(*) as count_value, scheduled', |
|
619 | + 'tx_crawler_queue', |
|
620 | + '', |
|
621 | + 'set_id, scheduled', |
|
622 | + 'scheduled DESC' |
|
623 | + ); |
|
624 | + |
|
625 | + $code = ' |
|
626 | 626 | <tr class="bgColor5 tableheader"> |
627 | 627 | <td>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.setid').':</td> |
628 | 628 | <td>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.count').'t:</td> |
@@ -630,9 +630,9 @@ discard block |
||
630 | 630 | </tr> |
631 | 631 | '; |
632 | 632 | |
633 | - $cc=0; |
|
634 | - foreach($setList as $set) { |
|
635 | - $code.= ' |
|
633 | + $cc=0; |
|
634 | + foreach($setList as $set) { |
|
635 | + $code.= ' |
|
636 | 636 | <tr class="bgColor'.($cc%2 ? '-20':'-10').'"> |
637 | 637 | <td><a href="'.htmlspecialchars('index.php?setID='.$set['set_id']).'">'.$set['set_id'].'</a></td> |
638 | 638 | <td>'.$set['count_value'].'</td> |
@@ -640,217 +640,217 @@ discard block |
||
640 | 640 | </tr> |
641 | 641 | '; |
642 | 642 | |
643 | - $cc++; |
|
644 | - } |
|
643 | + $cc++; |
|
644 | + } |
|
645 | 645 | |
646 | - $output .= ' |
|
646 | + $output .= ' |
|
647 | 647 | <br /><br /> |
648 | 648 | <table class="lrPadding c-list">'. |
649 | - $code. |
|
650 | - '</table>'; |
|
651 | - } |
|
652 | - } |
|
649 | + $code. |
|
650 | + '</table>'; |
|
651 | + } |
|
652 | + } |
|
653 | 653 | |
654 | - if($this->CSVExport) { |
|
655 | - $this->outputCsvFile(); |
|
656 | - } |
|
654 | + if($this->CSVExport) { |
|
655 | + $this->outputCsvFile(); |
|
656 | + } |
|
657 | 657 | |
658 | - // Return output |
|
659 | - return $output; |
|
660 | - } |
|
658 | + // Return output |
|
659 | + return $output; |
|
660 | + } |
|
661 | 661 | |
662 | - /** |
|
663 | - * Outputs the CSV file and sets the correct headers |
|
664 | - */ |
|
665 | - protected function outputCsvFile() { |
|
662 | + /** |
|
663 | + * Outputs the CSV file and sets the correct headers |
|
664 | + */ |
|
665 | + protected function outputCsvFile() { |
|
666 | 666 | |
667 | - if (!count($this->CSVaccu)) { |
|
668 | - $this->addWarningMessage($GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:message.canNotExportEmptyQueueToCsvText')); |
|
669 | - return; |
|
670 | - } |
|
667 | + if (!count($this->CSVaccu)) { |
|
668 | + $this->addWarningMessage($GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:message.canNotExportEmptyQueueToCsvText')); |
|
669 | + return; |
|
670 | + } |
|
671 | 671 | |
672 | - $csvLines = array(); |
|
672 | + $csvLines = array(); |
|
673 | 673 | |
674 | - // Field names: |
|
675 | - reset($this->CSVaccu); |
|
676 | - $fieldNames = array_keys(current($this->CSVaccu)); |
|
677 | - $csvLines[] = \TYPO3\CMS\Core\Utility\GeneralUtility::csvValues($fieldNames); |
|
674 | + // Field names: |
|
675 | + reset($this->CSVaccu); |
|
676 | + $fieldNames = array_keys(current($this->CSVaccu)); |
|
677 | + $csvLines[] = \TYPO3\CMS\Core\Utility\GeneralUtility::csvValues($fieldNames); |
|
678 | 678 | |
679 | - // Data: |
|
680 | - foreach($this->CSVaccu as $row) { |
|
681 | - $csvLines[] = \TYPO3\CMS\Core\Utility\GeneralUtility::csvValues($row); |
|
682 | - } |
|
679 | + // Data: |
|
680 | + foreach($this->CSVaccu as $row) { |
|
681 | + $csvLines[] = \TYPO3\CMS\Core\Utility\GeneralUtility::csvValues($row); |
|
682 | + } |
|
683 | 683 | |
684 | - // Creating output header: |
|
685 | - $mimeType = 'application/octet-stream'; |
|
686 | - Header('Content-Type: '.$mimeType); |
|
687 | - Header('Content-Disposition: attachment; filename=CrawlerLog.csv'); |
|
684 | + // Creating output header: |
|
685 | + $mimeType = 'application/octet-stream'; |
|
686 | + Header('Content-Type: '.$mimeType); |
|
687 | + Header('Content-Disposition: attachment; filename=CrawlerLog.csv'); |
|
688 | + |
|
689 | + // Printing the content of the CSV lines: |
|
690 | + echo implode(chr(13).chr(10),$csvLines); |
|
691 | + |
|
692 | + // Exits: |
|
693 | + exit; |
|
694 | + } |
|
695 | + |
|
696 | + /** |
|
697 | + * Create the rows for display of the page tree |
|
698 | + * For each page a number of rows are shown displaying GET variable configuration |
|
699 | + * |
|
700 | + * @param array Page row or set-id |
|
701 | + * @param string Title string |
|
702 | + * @param int Items per Page setting |
|
703 | + * @return string HTML <tr> content (one or more) |
|
704 | + */ |
|
705 | + function drawLog_addRows($pageRow_setId, $titleString, $itemsPerPage=10) { |
|
706 | + |
|
707 | + // If Flush button is pressed, flush tables instead of selecting entries: |
|
708 | + |
|
709 | + if(\TYPO3\CMS\Core\Utility\GeneralUtility::_POST('_flush')) { |
|
710 | + $doFlush = true; |
|
711 | + $doFullFlush = false; |
|
712 | + } elseif(\TYPO3\CMS\Core\Utility\GeneralUtility::_POST('_flush_all')) { |
|
713 | + $doFlush = true; |
|
714 | + $doFullFlush = true; |
|
715 | + } else { |
|
716 | + $doFlush = false; |
|
717 | + $doFullFlush = false; |
|
718 | + } |
|
719 | + |
|
720 | + // Get result: |
|
721 | + if (is_array($pageRow_setId)) { |
|
722 | + $res = $this->crawlerObj->getLogEntriesForPageId($pageRow_setId['uid'], $this->pObj->MOD_SETTINGS['log_display'], $doFlush, $doFullFlush, intval($itemsPerPage)); |
|
723 | + } else { |
|
724 | + $res = $this->crawlerObj->getLogEntriesForSetId($pageRow_setId, $this->pObj->MOD_SETTINGS['log_display'], $doFlush, $doFullFlush, intval($itemsPerPage)); |
|
725 | + } |
|
688 | 726 | |
689 | - // Printing the content of the CSV lines: |
|
690 | - echo implode(chr(13).chr(10),$csvLines); |
|
727 | + // Init var: |
|
728 | + $colSpan = 9 |
|
729 | + + ($this->pObj->MOD_SETTINGS['log_resultLog'] ? -1 : 0) |
|
730 | + + ($this->pObj->MOD_SETTINGS['log_feVars'] ? 3 : 0); |
|
731 | + |
|
732 | + if (count($res)) { |
|
733 | + // Traverse parameter combinations: |
|
734 | + $c = 0; |
|
735 | + $content=''; |
|
736 | + foreach($res as $kk => $vv) { |
|
737 | + |
|
738 | + // Title column: |
|
739 | + if (!$c) { |
|
740 | + $titleClm = '<td rowspan="'.count($res).'">'.$titleString.'</td>'; |
|
741 | + } else { |
|
742 | + $titleClm = ''; |
|
743 | + } |
|
691 | 744 | |
692 | - // Exits: |
|
693 | - exit; |
|
694 | - } |
|
745 | + // Result: |
|
746 | + $resLog = $this->getResultLog($vv); |
|
695 | 747 | |
696 | - /** |
|
697 | - * Create the rows for display of the page tree |
|
698 | - * For each page a number of rows are shown displaying GET variable configuration |
|
699 | - * |
|
700 | - * @param array Page row or set-id |
|
701 | - * @param string Title string |
|
702 | - * @param int Items per Page setting |
|
703 | - * @return string HTML <tr> content (one or more) |
|
704 | - */ |
|
705 | - function drawLog_addRows($pageRow_setId, $titleString, $itemsPerPage=10) { |
|
706 | - |
|
707 | - // If Flush button is pressed, flush tables instead of selecting entries: |
|
708 | - |
|
709 | - if(\TYPO3\CMS\Core\Utility\GeneralUtility::_POST('_flush')) { |
|
710 | - $doFlush = true; |
|
711 | - $doFullFlush = false; |
|
712 | - } elseif(\TYPO3\CMS\Core\Utility\GeneralUtility::_POST('_flush_all')) { |
|
713 | - $doFlush = true; |
|
714 | - $doFullFlush = true; |
|
715 | - } else { |
|
716 | - $doFlush = false; |
|
717 | - $doFullFlush = false; |
|
718 | - } |
|
748 | + $resStatus = $this->getResStatus($vv); |
|
749 | + $resFeVars = $this->getResFeVars($vv); |
|
719 | 750 | |
720 | - // Get result: |
|
721 | - if (is_array($pageRow_setId)) { |
|
722 | - $res = $this->crawlerObj->getLogEntriesForPageId($pageRow_setId['uid'], $this->pObj->MOD_SETTINGS['log_display'], $doFlush, $doFullFlush, intval($itemsPerPage)); |
|
723 | - } else { |
|
724 | - $res = $this->crawlerObj->getLogEntriesForSetId($pageRow_setId, $this->pObj->MOD_SETTINGS['log_display'], $doFlush, $doFullFlush, intval($itemsPerPage)); |
|
725 | - } |
|
751 | + // Compile row: |
|
752 | + $parameters = unserialize($vv['parameters']); |
|
726 | 753 | |
727 | - // Init var: |
|
728 | - $colSpan = 9 |
|
729 | - + ($this->pObj->MOD_SETTINGS['log_resultLog'] ? -1 : 0) |
|
730 | - + ($this->pObj->MOD_SETTINGS['log_feVars'] ? 3 : 0); |
|
731 | - |
|
732 | - if (count($res)) { |
|
733 | - // Traverse parameter combinations: |
|
734 | - $c = 0; |
|
735 | - $content=''; |
|
736 | - foreach($res as $kk => $vv) { |
|
737 | - |
|
738 | - // Title column: |
|
739 | - if (!$c) { |
|
740 | - $titleClm = '<td rowspan="'.count($res).'">'.$titleString.'</td>'; |
|
741 | - } else { |
|
742 | - $titleClm = ''; |
|
743 | - } |
|
744 | - |
|
745 | - // Result: |
|
746 | - $resLog = $this->getResultLog($vv); |
|
747 | - |
|
748 | - $resStatus = $this->getResStatus($vv); |
|
749 | - $resFeVars = $this->getResFeVars($vv); |
|
750 | - |
|
751 | - // Compile row: |
|
752 | - $parameters = unserialize($vv['parameters']); |
|
753 | - |
|
754 | - // Put data into array: |
|
755 | - $rowData = array(); |
|
756 | - if ($this->pObj->MOD_SETTINGS['log_resultLog']) { |
|
757 | - $rowData['result_log'] = $resLog; |
|
758 | - } else { |
|
759 | - $rowData['scheduled'] = ($vv['scheduled']> 0) ? \TYPO3\CMS\Backend\Utility\BackendUtility::datetime($vv['scheduled']) : ' '.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.immediate'); |
|
760 | - $rowData['exec_time'] = $vv['exec_time'] ? \TYPO3\CMS\Backend\Utility\BackendUtility::datetime($vv['exec_time']) : '-'; |
|
761 | - } |
|
762 | - $rowData['result_status'] = \TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($resStatus,50); |
|
763 | - $rowData['url'] = '<a href="'.htmlspecialchars($parameters['url']).'" target="_newWIndow">'.htmlspecialchars($parameters['url']).'</a>'; |
|
764 | - $rowData['feUserGroupList'] = $parameters['feUserGroupList']; |
|
765 | - $rowData['procInstructions'] = is_array($parameters['procInstructions']) ? implode('; ',$parameters['procInstructions']) : ''; |
|
766 | - $rowData['set_id'] = $vv['set_id']; |
|
767 | - |
|
768 | - if ($this->pObj->MOD_SETTINGS['log_feVars']) { |
|
769 | - $rowData['tsfe_id'] = $resFeVars['id']; |
|
770 | - $rowData['tsfe_gr_list'] = $resFeVars['gr_list']; |
|
771 | - $rowData['tsfe_no_cache'] = $resFeVars['no_cache']; |
|
772 | - } |
|
773 | - |
|
774 | - $setId = intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('setID')); |
|
775 | - |
|
776 | - $refreshIcon = $GLOBALS['BACK_PATH'] . 'gfx/refresh_n.gif'; |
|
777 | - if (version_compare(TYPO3_version,'7.0','>=')) { |
|
778 | - $refreshIcon = $GLOBALS['BACK_PATH'] . 'sysext/t3skin/extjs/images/grid/refresh.gif'; |
|
779 | - } |
|
780 | - |
|
781 | - // Put rows together: |
|
782 | - $content.= ' |
|
754 | + // Put data into array: |
|
755 | + $rowData = array(); |
|
756 | + if ($this->pObj->MOD_SETTINGS['log_resultLog']) { |
|
757 | + $rowData['result_log'] = $resLog; |
|
758 | + } else { |
|
759 | + $rowData['scheduled'] = ($vv['scheduled']> 0) ? \TYPO3\CMS\Backend\Utility\BackendUtility::datetime($vv['scheduled']) : ' '.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.immediate'); |
|
760 | + $rowData['exec_time'] = $vv['exec_time'] ? \TYPO3\CMS\Backend\Utility\BackendUtility::datetime($vv['exec_time']) : '-'; |
|
761 | + } |
|
762 | + $rowData['result_status'] = \TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($resStatus,50); |
|
763 | + $rowData['url'] = '<a href="'.htmlspecialchars($parameters['url']).'" target="_newWIndow">'.htmlspecialchars($parameters['url']).'</a>'; |
|
764 | + $rowData['feUserGroupList'] = $parameters['feUserGroupList']; |
|
765 | + $rowData['procInstructions'] = is_array($parameters['procInstructions']) ? implode('; ',$parameters['procInstructions']) : ''; |
|
766 | + $rowData['set_id'] = $vv['set_id']; |
|
767 | + |
|
768 | + if ($this->pObj->MOD_SETTINGS['log_feVars']) { |
|
769 | + $rowData['tsfe_id'] = $resFeVars['id']; |
|
770 | + $rowData['tsfe_gr_list'] = $resFeVars['gr_list']; |
|
771 | + $rowData['tsfe_no_cache'] = $resFeVars['no_cache']; |
|
772 | + } |
|
773 | + |
|
774 | + $setId = intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('setID')); |
|
775 | + |
|
776 | + $refreshIcon = $GLOBALS['BACK_PATH'] . 'gfx/refresh_n.gif'; |
|
777 | + if (version_compare(TYPO3_version,'7.0','>=')) { |
|
778 | + $refreshIcon = $GLOBALS['BACK_PATH'] . 'sysext/t3skin/extjs/images/grid/refresh.gif'; |
|
779 | + } |
|
780 | + |
|
781 | + // Put rows together: |
|
782 | + $content.= ' |
|
783 | 783 | <tr class="bgColor'.($c%2 ? '-20':'-10').'"> |
784 | 784 | '.$titleClm.' |
785 | 785 | <td><a href="' . $this->getModuleUrl(array('qid_details' => $vv['qid'], 'setID' => $setId)) . '">'.htmlspecialchars($vv['qid']).'</a></td> |
786 | 786 | <td><a href="' . $this->getModuleUrl(array('qid_read' => $vv['qid'], 'setID' => $setId)) . '"><img src="' . $refreshIcon . '" width="14" hspace="1" vspace="2" height="14" border="0" title="'.htmlspecialchars('Read').'" alt="" /></a></td>'; |
787 | - foreach($rowData as $fKey => $value) { |
|
787 | + foreach($rowData as $fKey => $value) { |
|
788 | 788 | |
789 | - if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList('url',$fKey)) { |
|
790 | - $content.= ' |
|
789 | + if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList('url',$fKey)) { |
|
790 | + $content.= ' |
|
791 | 791 | <td>'.$value.'</td>'; |
792 | - } else { |
|
793 | - $content.= ' |
|
792 | + } else { |
|
793 | + $content.= ' |
|
794 | 794 | <td>'.nl2br(htmlspecialchars($value)).'</td>'; |
795 | - } |
|
796 | - } |
|
797 | - $content.= ' |
|
795 | + } |
|
796 | + } |
|
797 | + $content.= ' |
|
798 | 798 | </tr>'; |
799 | - $c++; |
|
800 | - |
|
801 | - if ($this->CSVExport) { |
|
802 | - // Only for CSV (adding qid and scheduled/exec_time if needed): |
|
803 | - $rowData['result_log'] = implode('// ',explode(chr(10),$resLog)); |
|
804 | - $rowData['qid'] = $vv['qid']; |
|
805 | - $rowData['scheduled'] = \TYPO3\CMS\Backend\Utility\BackendUtility::datetime($vv['scheduled']); |
|
806 | - $rowData['exec_time'] = $vv['exec_time'] ? \TYPO3\CMS\Backend\Utility\BackendUtility::datetime($vv['exec_time']) : '-'; |
|
807 | - $this->CSVaccu[] = $rowData; |
|
808 | - } |
|
809 | - } |
|
810 | - } else { |
|
799 | + $c++; |
|
800 | + |
|
801 | + if ($this->CSVExport) { |
|
802 | + // Only for CSV (adding qid and scheduled/exec_time if needed): |
|
803 | + $rowData['result_log'] = implode('// ',explode(chr(10),$resLog)); |
|
804 | + $rowData['qid'] = $vv['qid']; |
|
805 | + $rowData['scheduled'] = \TYPO3\CMS\Backend\Utility\BackendUtility::datetime($vv['scheduled']); |
|
806 | + $rowData['exec_time'] = $vv['exec_time'] ? \TYPO3\CMS\Backend\Utility\BackendUtility::datetime($vv['exec_time']) : '-'; |
|
807 | + $this->CSVaccu[] = $rowData; |
|
808 | + } |
|
809 | + } |
|
810 | + } else { |
|
811 | 811 | |
812 | - // Compile row: |
|
813 | - $content = ' |
|
812 | + // Compile row: |
|
813 | + $content = ' |
|
814 | 814 | <tr class="bgColor-20"> |
815 | 815 | <td>'.$titleString.'</td> |
816 | 816 | <td colspan="'.$colSpan.'"><em>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.noentries').'</em></td> |
817 | 817 | </tr>'; |
818 | - } |
|
819 | - |
|
820 | - return $content; |
|
821 | - } |
|
818 | + } |
|
822 | 819 | |
823 | - /** |
|
824 | - * Find Fe vars |
|
825 | - * |
|
826 | - * @param array $row |
|
827 | - * @return array |
|
828 | - */ |
|
829 | - function getResFeVars($row) { |
|
830 | - $feVars = array(); |
|
831 | - |
|
832 | - if ($row['result_data']) { |
|
833 | - $resultData = unserialize($row['result_data']); |
|
834 | - $requestResult = unserialize($resultData['content']); |
|
835 | - $feVars = $requestResult['vars']; |
|
836 | - } |
|
820 | + return $content; |
|
821 | + } |
|
822 | + |
|
823 | + /** |
|
824 | + * Find Fe vars |
|
825 | + * |
|
826 | + * @param array $row |
|
827 | + * @return array |
|
828 | + */ |
|
829 | + function getResFeVars($row) { |
|
830 | + $feVars = array(); |
|
831 | + |
|
832 | + if ($row['result_data']) { |
|
833 | + $resultData = unserialize($row['result_data']); |
|
834 | + $requestResult = unserialize($resultData['content']); |
|
835 | + $feVars = $requestResult['vars']; |
|
836 | + } |
|
837 | 837 | |
838 | - return $feVars; |
|
839 | - } |
|
838 | + return $feVars; |
|
839 | + } |
|
840 | 840 | |
841 | - /** |
|
842 | - * Create Table header row (log) |
|
843 | - * |
|
844 | - * @return string Table header |
|
845 | - */ |
|
846 | - function drawLog_printTableHeader() { |
|
841 | + /** |
|
842 | + * Create Table header row (log) |
|
843 | + * |
|
844 | + * @return string Table header |
|
845 | + */ |
|
846 | + function drawLog_printTableHeader() { |
|
847 | 847 | |
848 | - $content = ' |
|
848 | + $content = ' |
|
849 | 849 | <tr class="bgColor5 tableheader"> |
850 | 850 | <td>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.pagetitle').':</td> |
851 | 851 | <td>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.qid').':</td> |
852 | 852 | <td> </td>'. |
853 | - ($this->pObj->MOD_SETTINGS['log_resultLog'] ? ' |
|
853 | + ($this->pObj->MOD_SETTINGS['log_resultLog'] ? ' |
|
854 | 854 | <td>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.resultlog').':</td>' : ' |
855 | 855 | <td>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.scheduledtime').':</td> |
856 | 856 | <td>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.runtime').':</td>').' |
@@ -859,14 +859,14 @@ discard block |
||
859 | 859 | <td>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.groups').':</td> |
860 | 860 | <td>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.procinstr').':</td> |
861 | 861 | <td>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.setid').':</td>'. |
862 | - ($this->pObj->MOD_SETTINGS['log_feVars'] ? ' |
|
862 | + ($this->pObj->MOD_SETTINGS['log_feVars'] ? ' |
|
863 | 863 | <td>'.htmlspecialchars('TSFE->id').'</td> |
864 | 864 | <td>'.htmlspecialchars('TSFE->gr_list').'</td> |
865 | 865 | <td>'.htmlspecialchars('TSFE->no_cache').'</td>' : '').' |
866 | 866 | </tr>'; |
867 | 867 | |
868 | - return $content; |
|
869 | - } |
|
868 | + return $content; |
|
869 | + } |
|
870 | 870 | |
871 | 871 | /** |
872 | 872 | * Extract the log information from the current row and retrive it as formatted string. |
@@ -890,25 +890,25 @@ discard block |
||
890 | 890 | return $content; |
891 | 891 | } |
892 | 892 | |
893 | - function getResStatus($vv) { |
|
894 | - if ($vv['result_data']) { |
|
895 | - $requestContent = unserialize($vv['result_data']); |
|
896 | - $requestResult = unserialize($requestContent['content']); |
|
897 | - if (is_array($requestResult)) { |
|
898 | - if (empty($requestResult['errorlog'])) { |
|
899 | - $resStatus = 'OK'; |
|
900 | - } else { |
|
901 | - $resStatus = implode("\n", $requestResult['errorlog']); |
|
902 | - } |
|
903 | - $resLog = is_array($requestResult['log']) ? implode(chr(10),$requestResult['log']) : ''; |
|
904 | - } else { |
|
905 | - $resStatus = 'Error: '.substr(preg_replace('/\s+/',' ',strip_tags($requestContent['content'])),0,10000).'...'; |
|
906 | - } |
|
907 | - } else { |
|
908 | - $resStatus = '-'; |
|
909 | - } |
|
910 | - return $resStatus; |
|
911 | - } |
|
893 | + function getResStatus($vv) { |
|
894 | + if ($vv['result_data']) { |
|
895 | + $requestContent = unserialize($vv['result_data']); |
|
896 | + $requestResult = unserialize($requestContent['content']); |
|
897 | + if (is_array($requestResult)) { |
|
898 | + if (empty($requestResult['errorlog'])) { |
|
899 | + $resStatus = 'OK'; |
|
900 | + } else { |
|
901 | + $resStatus = implode("\n", $requestResult['errorlog']); |
|
902 | + } |
|
903 | + $resLog = is_array($requestResult['log']) ? implode(chr(10),$requestResult['log']) : ''; |
|
904 | + } else { |
|
905 | + $resStatus = 'Error: '.substr(preg_replace('/\s+/',' ',strip_tags($requestContent['content'])),0,10000).'...'; |
|
906 | + } |
|
907 | + } else { |
|
908 | + $resStatus = '-'; |
|
909 | + } |
|
910 | + return $resStatus; |
|
911 | + } |
|
912 | 912 | |
913 | 913 | |
914 | 914 | |
@@ -917,320 +917,320 @@ discard block |
||
917 | 917 | |
918 | 918 | |
919 | 919 | |
920 | - /***************************** |
|
920 | + /***************************** |
|
921 | 921 | * |
922 | 922 | * CLI status display |
923 | 923 | * |
924 | 924 | *****************************/ |
925 | 925 | |
926 | - /** |
|
927 | - * This method is used to show an overview about the active an the finished crawling processes |
|
928 | - * |
|
929 | - * @param void |
|
930 | - * @return string |
|
931 | - */ |
|
932 | - protected function drawProcessOverviewAction(){ |
|
933 | - |
|
934 | - $this->runRefreshHooks(); |
|
935 | - |
|
936 | - global $BACK_PATH; |
|
937 | - $this->makeCrawlerProcessableChecks(); |
|
938 | - |
|
939 | - $crawler = $this->findCrawler(); |
|
940 | - try { |
|
941 | - $this->handleProcessOverviewActions(); |
|
942 | - } catch (Exception $e) { |
|
943 | - $this->addErrorMessage($e->getMessage()); |
|
944 | - } |
|
945 | - |
|
946 | - $offset = intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('offset')); |
|
947 | - $perpage = 20; |
|
948 | - |
|
949 | - $processRepository = new tx_crawler_domain_process_repository(); |
|
950 | - $queueRepository = new tx_crawler_domain_queue_repository(); |
|
926 | + /** |
|
927 | + * This method is used to show an overview about the active an the finished crawling processes |
|
928 | + * |
|
929 | + * @param void |
|
930 | + * @return string |
|
931 | + */ |
|
932 | + protected function drawProcessOverviewAction(){ |
|
951 | 933 | |
952 | - $mode = $this->pObj->MOD_SETTINGS['processListMode']; |
|
953 | - if ($mode == 'detail') { |
|
954 | - $where = ''; |
|
955 | - } elseif($mode == 'simple') { |
|
956 | - $where = 'active = 1'; |
|
957 | - } |
|
958 | - |
|
959 | - $allProcesses = $processRepository->findAll('ttl','DESC', $perpage, $offset,$where); |
|
960 | - $allCount = $processRepository->countAll($where); |
|
961 | - |
|
962 | - $listView = new tx_crawler_view_process_list(); |
|
963 | - $listView->setPageId($this->pObj->id); |
|
964 | - $listView->setIconPath($BACK_PATH.'../typo3conf/ext/crawler/template/process/res/img/'); |
|
965 | - $listView->setProcessCollection($allProcesses); |
|
966 | - $listView->setCliPath($this->processManager->getCrawlerCliPath()); |
|
967 | - $listView->setIsCrawlerEnabled(!$crawler->getDisabled() && !$this->isErrorDetected); |
|
968 | - $listView->setTotalUnprocessedItemCount($queueRepository->countAllPendingItems()); |
|
969 | - $listView->setAssignedUnprocessedItemCount($queueRepository->countAllAssignedPendingItems()); |
|
970 | - $listView->setActiveProcessCount($processRepository->countActive()); |
|
971 | - $listView->setMaxActiveProcessCount(tx_crawler_api::forceIntegerInRange($this->extensionSettings['processLimit'],1,99,1)); |
|
972 | - $listView->setMode($mode); |
|
973 | - |
|
974 | - $paginationView = new tx_crawler_view_pagination(); |
|
975 | - $paginationView->setCurrentOffset($offset); |
|
976 | - $paginationView->setPerPage($perpage); |
|
977 | - $paginationView->setTotalItemCount($allCount); |
|
978 | - |
|
979 | - $output = $listView->render(); |
|
980 | - |
|
981 | - if ($paginationView->getTotalPagesCount() > 1) { |
|
982 | - $output .= ' <br />'.$paginationView->render(); |
|
983 | - } |
|
934 | + $this->runRefreshHooks(); |
|
984 | 935 | |
985 | - return $output; |
|
986 | - } |
|
987 | - |
|
988 | - /** |
|
989 | - * Verify that the crawler is exectuable. |
|
990 | - * |
|
991 | - * @return void |
|
992 | - */ |
|
993 | - protected function makeCrawlerProcessableChecks() { |
|
994 | - global $LANG; |
|
995 | - |
|
996 | - if ($this->isCrawlerUserAvailable() === false) { |
|
997 | - $this->addErrorMessage($LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:message.noBeUserAvailable')); |
|
998 | - } elseif ($this->isCrawlerUserNotAdmin() === false) { |
|
999 | - $this->addErrorMessage($LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:message.beUserIsAdmin')); |
|
1000 | - } |
|
1001 | - |
|
1002 | - if ($this->isPhpForkAvailable() === false) { |
|
1003 | - $this->addErrorMessage($LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:message.noPhpForkAvailable')); |
|
1004 | - } |
|
936 | + global $BACK_PATH; |
|
937 | + $this->makeCrawlerProcessableChecks(); |
|
1005 | 938 | |
1006 | - $exitCode = 0; |
|
1007 | - $out = array(); |
|
1008 | - exec(escapeshellcmd($this->extensionSettings['phpPath'] . ' -v'), $out, $exitCode); |
|
1009 | - if ($exitCode > 0) { |
|
1010 | - $this->addErrorMessage(sprintf($LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:message.phpBinaryNotFound'), htmlspecialchars($this->extensionSettings['phpPath']))); |
|
1011 | - } |
|
1012 | - } |
|
939 | + $crawler = $this->findCrawler(); |
|
940 | + try { |
|
941 | + $this->handleProcessOverviewActions(); |
|
942 | + } catch (Exception $e) { |
|
943 | + $this->addErrorMessage($e->getMessage()); |
|
944 | + } |
|
1013 | 945 | |
1014 | - /** |
|
1015 | - * Indicate that the required PHP method "popen" is |
|
1016 | - * available in the system. |
|
1017 | - * |
|
1018 | - * @return boolean |
|
1019 | - */ |
|
1020 | - protected function isPhpForkAvailable() { |
|
1021 | - return function_exists('popen'); |
|
1022 | - } |
|
1023 | - |
|
1024 | - /** |
|
1025 | - * Indicate that the required be_user "_cli_crawler" is |
|
1026 | - * global available in the system. |
|
1027 | - * |
|
1028 | - * @return boolean |
|
1029 | - */ |
|
1030 | - protected function isCrawlerUserAvailable() { |
|
1031 | - $isAvailable = false; |
|
1032 | - $userArray = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordsByField('be_users', 'username', '_cli_crawler'); |
|
946 | + $offset = intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('offset')); |
|
947 | + $perpage = 20; |
|
1033 | 948 | |
1034 | - if (is_array($userArray)) |
|
1035 | - $isAvailable = true; |
|
949 | + $processRepository = new tx_crawler_domain_process_repository(); |
|
950 | + $queueRepository = new tx_crawler_domain_queue_repository(); |
|
1036 | 951 | |
1037 | - return $isAvailable; |
|
1038 | - } |
|
952 | + $mode = $this->pObj->MOD_SETTINGS['processListMode']; |
|
953 | + if ($mode == 'detail') { |
|
954 | + $where = ''; |
|
955 | + } elseif($mode == 'simple') { |
|
956 | + $where = 'active = 1'; |
|
957 | + } |
|
1039 | 958 | |
1040 | - /** |
|
1041 | - * Indicate that the required be_user "_cli_crawler" is |
|
1042 | - * has no admin rights. |
|
1043 | - * |
|
1044 | - * @return boolean* |
|
1045 | - */ |
|
1046 | - protected function isCrawlerUserNotAdmin() { |
|
1047 | - $isAvailable = false; |
|
1048 | - $userArray = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordsByField('be_users', 'username', '_cli_crawler'); |
|
959 | + $allProcesses = $processRepository->findAll('ttl','DESC', $perpage, $offset,$where); |
|
960 | + $allCount = $processRepository->countAll($where); |
|
961 | + |
|
962 | + $listView = new tx_crawler_view_process_list(); |
|
963 | + $listView->setPageId($this->pObj->id); |
|
964 | + $listView->setIconPath($BACK_PATH.'../typo3conf/ext/crawler/template/process/res/img/'); |
|
965 | + $listView->setProcessCollection($allProcesses); |
|
966 | + $listView->setCliPath($this->processManager->getCrawlerCliPath()); |
|
967 | + $listView->setIsCrawlerEnabled(!$crawler->getDisabled() && !$this->isErrorDetected); |
|
968 | + $listView->setTotalUnprocessedItemCount($queueRepository->countAllPendingItems()); |
|
969 | + $listView->setAssignedUnprocessedItemCount($queueRepository->countAllAssignedPendingItems()); |
|
970 | + $listView->setActiveProcessCount($processRepository->countActive()); |
|
971 | + $listView->setMaxActiveProcessCount(tx_crawler_api::forceIntegerInRange($this->extensionSettings['processLimit'],1,99,1)); |
|
972 | + $listView->setMode($mode); |
|
973 | + |
|
974 | + $paginationView = new tx_crawler_view_pagination(); |
|
975 | + $paginationView->setCurrentOffset($offset); |
|
976 | + $paginationView->setPerPage($perpage); |
|
977 | + $paginationView->setTotalItemCount($allCount); |
|
978 | + |
|
979 | + $output = $listView->render(); |
|
980 | + |
|
981 | + if ($paginationView->getTotalPagesCount() > 1) { |
|
982 | + $output .= ' <br />'.$paginationView->render(); |
|
983 | + } |
|
1049 | 984 | |
1050 | - if (is_array($userArray) && $userArray[0]['admin'] == 0) |
|
1051 | - $isAvailable = true; |
|
985 | + return $output; |
|
986 | + } |
|
987 | + |
|
988 | + /** |
|
989 | + * Verify that the crawler is exectuable. |
|
990 | + * |
|
991 | + * @return void |
|
992 | + */ |
|
993 | + protected function makeCrawlerProcessableChecks() { |
|
994 | + global $LANG; |
|
995 | + |
|
996 | + if ($this->isCrawlerUserAvailable() === false) { |
|
997 | + $this->addErrorMessage($LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:message.noBeUserAvailable')); |
|
998 | + } elseif ($this->isCrawlerUserNotAdmin() === false) { |
|
999 | + $this->addErrorMessage($LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:message.beUserIsAdmin')); |
|
1000 | + } |
|
1052 | 1001 | |
1053 | - return $isAvailable; |
|
1054 | - } |
|
1002 | + if ($this->isPhpForkAvailable() === false) { |
|
1003 | + $this->addErrorMessage($LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:message.noPhpForkAvailable')); |
|
1004 | + } |
|
1055 | 1005 | |
1056 | - /** |
|
1057 | - * Method to handle incomming actions of the process overview |
|
1058 | - * |
|
1059 | - * @return void |
|
1060 | - * @throws Exception |
|
1061 | - * @internal param $void |
|
1062 | - */ |
|
1063 | - protected function handleProcessOverviewActions(){ |
|
1064 | - |
|
1065 | - $crawler = $this->findCrawler(); |
|
1066 | - |
|
1067 | - switch (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('action')) { |
|
1068 | - case 'stopCrawling' : |
|
1069 | - //set the cli status to disable (all processes will be terminated) |
|
1070 | - $crawler->setDisabled(true); |
|
1071 | - break; |
|
1072 | - case 'resumeCrawling' : |
|
1073 | - //set the cli status to end (all processes will be terminated) |
|
1074 | - $crawler->setDisabled(false); |
|
1075 | - break; |
|
1076 | - case 'addProcess' : |
|
1077 | - $handle = $this->processManager->startProcess(); |
|
1078 | - if ($handle === false) { |
|
1079 | - throw new Exception($GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.newprocesserror')); |
|
1080 | - } |
|
1081 | - $this->addNoticeMessage($GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.newprocess')); |
|
1082 | - break; |
|
1083 | - } |
|
1084 | - } |
|
1006 | + $exitCode = 0; |
|
1007 | + $out = array(); |
|
1008 | + exec(escapeshellcmd($this->extensionSettings['phpPath'] . ' -v'), $out, $exitCode); |
|
1009 | + if ($exitCode > 0) { |
|
1010 | + $this->addErrorMessage(sprintf($LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:message.phpBinaryNotFound'), htmlspecialchars($this->extensionSettings['phpPath']))); |
|
1011 | + } |
|
1012 | + } |
|
1013 | + |
|
1014 | + /** |
|
1015 | + * Indicate that the required PHP method "popen" is |
|
1016 | + * available in the system. |
|
1017 | + * |
|
1018 | + * @return boolean |
|
1019 | + */ |
|
1020 | + protected function isPhpForkAvailable() { |
|
1021 | + return function_exists('popen'); |
|
1022 | + } |
|
1023 | + |
|
1024 | + /** |
|
1025 | + * Indicate that the required be_user "_cli_crawler" is |
|
1026 | + * global available in the system. |
|
1027 | + * |
|
1028 | + * @return boolean |
|
1029 | + */ |
|
1030 | + protected function isCrawlerUserAvailable() { |
|
1031 | + $isAvailable = false; |
|
1032 | + $userArray = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordsByField('be_users', 'username', '_cli_crawler'); |
|
1033 | + |
|
1034 | + if (is_array($userArray)) |
|
1035 | + $isAvailable = true; |
|
1036 | + |
|
1037 | + return $isAvailable; |
|
1038 | + } |
|
1039 | + |
|
1040 | + /** |
|
1041 | + * Indicate that the required be_user "_cli_crawler" is |
|
1042 | + * has no admin rights. |
|
1043 | + * |
|
1044 | + * @return boolean* |
|
1045 | + */ |
|
1046 | + protected function isCrawlerUserNotAdmin() { |
|
1047 | + $isAvailable = false; |
|
1048 | + $userArray = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordsByField('be_users', 'username', '_cli_crawler'); |
|
1049 | + |
|
1050 | + if (is_array($userArray) && $userArray[0]['admin'] == 0) |
|
1051 | + $isAvailable = true; |
|
1052 | + |
|
1053 | + return $isAvailable; |
|
1054 | + } |
|
1055 | + |
|
1056 | + /** |
|
1057 | + * Method to handle incomming actions of the process overview |
|
1058 | + * |
|
1059 | + * @return void |
|
1060 | + * @throws Exception |
|
1061 | + * @internal param $void |
|
1062 | + */ |
|
1063 | + protected function handleProcessOverviewActions(){ |
|
1064 | + |
|
1065 | + $crawler = $this->findCrawler(); |
|
1066 | + |
|
1067 | + switch (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('action')) { |
|
1068 | + case 'stopCrawling' : |
|
1069 | + //set the cli status to disable (all processes will be terminated) |
|
1070 | + $crawler->setDisabled(true); |
|
1071 | + break; |
|
1072 | + case 'resumeCrawling' : |
|
1073 | + //set the cli status to end (all processes will be terminated) |
|
1074 | + $crawler->setDisabled(false); |
|
1075 | + break; |
|
1076 | + case 'addProcess' : |
|
1077 | + $handle = $this->processManager->startProcess(); |
|
1078 | + if ($handle === false) { |
|
1079 | + throw new Exception($GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.newprocesserror')); |
|
1080 | + } |
|
1081 | + $this->addNoticeMessage($GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.newprocess')); |
|
1082 | + break; |
|
1083 | + } |
|
1084 | + } |
|
1085 | 1085 | |
1086 | 1086 | |
1087 | 1087 | |
1088 | 1088 | |
1089 | - /** |
|
1090 | - * Returns the singleton instance of the crawler. |
|
1091 | - * |
|
1092 | - * @param void |
|
1093 | - * @return tx_crawler_lib crawler object |
|
1094 | - */ |
|
1095 | - protected function findCrawler(){ |
|
1096 | - if(!$this->crawlerObj instanceof tx_crawler_lib){ |
|
1097 | - $this->crawlerObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_crawler_lib'); |
|
1098 | - } |
|
1099 | - return $this->crawlerObj; |
|
1100 | - } |
|
1089 | + /** |
|
1090 | + * Returns the singleton instance of the crawler. |
|
1091 | + * |
|
1092 | + * @param void |
|
1093 | + * @return tx_crawler_lib crawler object |
|
1094 | + */ |
|
1095 | + protected function findCrawler(){ |
|
1096 | + if(!$this->crawlerObj instanceof tx_crawler_lib){ |
|
1097 | + $this->crawlerObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_crawler_lib'); |
|
1098 | + } |
|
1099 | + return $this->crawlerObj; |
|
1100 | + } |
|
1101 | 1101 | |
1102 | 1102 | |
1103 | 1103 | |
1104 | - /***************************** |
|
1104 | + /***************************** |
|
1105 | 1105 | * |
1106 | 1106 | * General Helper Functions |
1107 | 1107 | * |
1108 | 1108 | *****************************/ |
1109 | 1109 | |
1110 | - /** |
|
1111 | - * This method is used to add a message to the internal queue |
|
1112 | - * |
|
1113 | - * NOTE: |
|
1114 | - * This method is basesd on TYPO3 4.3 or higher! |
|
1115 | - * |
|
1116 | - * @param string the message itself |
|
1117 | - * @param integer message level (-1 = success (default), 0 = info, 1 = notice, 2 = warning, 3 = error) |
|
1118 | - * |
|
1119 | - * @return void |
|
1120 | - */ |
|
1121 | - private function addMessage($message, $severity = \TYPO3\CMS\Core\Messaging\FlashMessage::OK) { |
|
1122 | - $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
1123 | - 'TYPO3\CMS\Core\Messaging\FlashMessage', |
|
1124 | - $message, |
|
1125 | - '', |
|
1126 | - $severity |
|
1127 | - ); |
|
1128 | - |
|
1129 | - // TODO: |
|
1130 | - /** @var \TYPO3\CMS\Core\Messaging\FlashMessageService $flashMessageService */ |
|
1131 | - $flashMessageService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService'); |
|
1132 | - $flashMessageService->getMessageQueueByIdentifier()->addMessage($message); |
|
1133 | - } |
|
1134 | - |
|
1135 | - /** |
|
1136 | - * Add notice message to the user interface. |
|
1137 | - * |
|
1138 | - * NOTE: |
|
1139 | - * This method is basesd on TYPO3 4.3 or higher! |
|
1140 | - * |
|
1141 | - * @param string The message |
|
1142 | - * |
|
1143 | - * @return void |
|
1144 | - */ |
|
1145 | - protected function addNoticeMessage($message) { |
|
1146 | - $this->addMessage($message, \TYPO3\CMS\Core\Messaging\FlashMessage::NOTICE); |
|
1147 | - } |
|
1148 | - |
|
1149 | - /** |
|
1150 | - * Add error message to the user interface. |
|
1151 | - * |
|
1152 | - * NOTE: |
|
1153 | - * This method is basesd on TYPO3 4.3 or higher! |
|
1154 | - * |
|
1155 | - * @param string The message |
|
1156 | - * |
|
1157 | - * @return void |
|
1158 | - */ |
|
1159 | - protected function addErrorMessage($message) { |
|
1160 | - $this->isErrorDetected = TRUE; |
|
1161 | - $this->addMessage($message, \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); |
|
1162 | - } |
|
1163 | - |
|
1164 | - /** |
|
1165 | - * Add error message to the user interface. |
|
1166 | - * |
|
1167 | - * NOTE: |
|
1168 | - * This method is basesd on TYPO3 4.3 or higher! |
|
1169 | - * |
|
1170 | - * @param string The message |
|
1171 | - * |
|
1172 | - * @return void |
|
1173 | - */ |
|
1174 | - protected function addWarningMessage($message) { |
|
1175 | - $this->addMessage($message, \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING); |
|
1176 | - } |
|
1177 | - |
|
1178 | - /** |
|
1179 | - * Create selector box |
|
1180 | - * |
|
1181 | - * @param array Options key(value) => label pairs |
|
1182 | - * @param string Selector box name |
|
1183 | - * @param string Selector box value (array for multiple...) |
|
1184 | - * @param boolean If set, will draw multiple box. |
|
1185 | - * @return string HTML select element |
|
1186 | - */ |
|
1187 | - function selectorBox($optArray, $name, $value, $multiple) { |
|
1188 | - |
|
1189 | - $options = array(); |
|
1190 | - foreach($optArray as $key => $val) { |
|
1191 | - $options[] = ' |
|
1110 | + /** |
|
1111 | + * This method is used to add a message to the internal queue |
|
1112 | + * |
|
1113 | + * NOTE: |
|
1114 | + * This method is basesd on TYPO3 4.3 or higher! |
|
1115 | + * |
|
1116 | + * @param string the message itself |
|
1117 | + * @param integer message level (-1 = success (default), 0 = info, 1 = notice, 2 = warning, 3 = error) |
|
1118 | + * |
|
1119 | + * @return void |
|
1120 | + */ |
|
1121 | + private function addMessage($message, $severity = \TYPO3\CMS\Core\Messaging\FlashMessage::OK) { |
|
1122 | + $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( |
|
1123 | + 'TYPO3\CMS\Core\Messaging\FlashMessage', |
|
1124 | + $message, |
|
1125 | + '', |
|
1126 | + $severity |
|
1127 | + ); |
|
1128 | + |
|
1129 | + // TODO: |
|
1130 | + /** @var \TYPO3\CMS\Core\Messaging\FlashMessageService $flashMessageService */ |
|
1131 | + $flashMessageService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService'); |
|
1132 | + $flashMessageService->getMessageQueueByIdentifier()->addMessage($message); |
|
1133 | + } |
|
1134 | + |
|
1135 | + /** |
|
1136 | + * Add notice message to the user interface. |
|
1137 | + * |
|
1138 | + * NOTE: |
|
1139 | + * This method is basesd on TYPO3 4.3 or higher! |
|
1140 | + * |
|
1141 | + * @param string The message |
|
1142 | + * |
|
1143 | + * @return void |
|
1144 | + */ |
|
1145 | + protected function addNoticeMessage($message) { |
|
1146 | + $this->addMessage($message, \TYPO3\CMS\Core\Messaging\FlashMessage::NOTICE); |
|
1147 | + } |
|
1148 | + |
|
1149 | + /** |
|
1150 | + * Add error message to the user interface. |
|
1151 | + * |
|
1152 | + * NOTE: |
|
1153 | + * This method is basesd on TYPO3 4.3 or higher! |
|
1154 | + * |
|
1155 | + * @param string The message |
|
1156 | + * |
|
1157 | + * @return void |
|
1158 | + */ |
|
1159 | + protected function addErrorMessage($message) { |
|
1160 | + $this->isErrorDetected = TRUE; |
|
1161 | + $this->addMessage($message, \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); |
|
1162 | + } |
|
1163 | + |
|
1164 | + /** |
|
1165 | + * Add error message to the user interface. |
|
1166 | + * |
|
1167 | + * NOTE: |
|
1168 | + * This method is basesd on TYPO3 4.3 or higher! |
|
1169 | + * |
|
1170 | + * @param string The message |
|
1171 | + * |
|
1172 | + * @return void |
|
1173 | + */ |
|
1174 | + protected function addWarningMessage($message) { |
|
1175 | + $this->addMessage($message, \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING); |
|
1176 | + } |
|
1177 | + |
|
1178 | + /** |
|
1179 | + * Create selector box |
|
1180 | + * |
|
1181 | + * @param array Options key(value) => label pairs |
|
1182 | + * @param string Selector box name |
|
1183 | + * @param string Selector box value (array for multiple...) |
|
1184 | + * @param boolean If set, will draw multiple box. |
|
1185 | + * @return string HTML select element |
|
1186 | + */ |
|
1187 | + function selectorBox($optArray, $name, $value, $multiple) { |
|
1188 | + |
|
1189 | + $options = array(); |
|
1190 | + foreach($optArray as $key => $val) { |
|
1191 | + $options[] = ' |
|
1192 | 1192 | <option value="'.htmlspecialchars($key).'"'.((!$multiple && !strcmp($value,$key)) || ($multiple && in_array($key,(array)$value))?' selected="selected"':'').'>'.htmlspecialchars($val).'</option>'; |
1193 | - } |
|
1194 | - |
|
1195 | - $output = '<select name="'.htmlspecialchars($name.($multiple?'[]':'')).'"'.($multiple ? ' multiple="multiple" size="'.count($options).'"' : '').'>'.implode('',$options).'</select>'; |
|
1196 | - |
|
1197 | - return $output; |
|
1198 | - } |
|
1199 | - |
|
1200 | - /** |
|
1201 | - * Activate hooks |
|
1202 | - * |
|
1203 | - * @return void |
|
1204 | - */ |
|
1205 | - function runRefreshHooks() { |
|
1206 | - $crawlerLib = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_crawler_lib'); |
|
1207 | - if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['refresh_hooks'])) { |
|
1208 | - foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['refresh_hooks'] as $objRef) { |
|
1209 | - $hookObj = &\TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($objRef); |
|
1210 | - if (is_object($hookObj)) { |
|
1211 | - $hookObj->crawler_init($crawlerLib); |
|
1212 | - } |
|
1213 | - } |
|
1214 | - } |
|
1193 | + } |
|
1215 | 1194 | |
1216 | - } |
|
1195 | + $output = '<select name="'.htmlspecialchars($name.($multiple?'[]':'')).'"'.($multiple ? ' multiple="multiple" size="'.count($options).'"' : '').'>'.implode('',$options).'</select>'; |
|
1196 | + |
|
1197 | + return $output; |
|
1198 | + } |
|
1199 | + |
|
1200 | + /** |
|
1201 | + * Activate hooks |
|
1202 | + * |
|
1203 | + * @return void |
|
1204 | + */ |
|
1205 | + function runRefreshHooks() { |
|
1206 | + $crawlerLib = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_crawler_lib'); |
|
1207 | + if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['refresh_hooks'])) { |
|
1208 | + foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['refresh_hooks'] as $objRef) { |
|
1209 | + $hookObj = &\TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($objRef); |
|
1210 | + if (is_object($hookObj)) { |
|
1211 | + $hookObj->crawler_init($crawlerLib); |
|
1212 | + } |
|
1213 | + } |
|
1214 | + } |
|
1217 | 1215 | |
1218 | - /** |
|
1219 | - * Returns the URL to the current module, including $_GET['id']. |
|
1220 | - * |
|
1221 | - * @param array $urlParameters optional parameters to add to the URL |
|
1222 | - * @return string |
|
1223 | - */ |
|
1224 | - protected function getModuleUrl(array $urlParameters = array()) { |
|
1225 | - if ($this->pObj->id) { |
|
1226 | - $urlParameters = array_merge($urlParameters, array( |
|
1216 | + } |
|
1217 | + |
|
1218 | + /** |
|
1219 | + * Returns the URL to the current module, including $_GET['id']. |
|
1220 | + * |
|
1221 | + * @param array $urlParameters optional parameters to add to the URL |
|
1222 | + * @return string |
|
1223 | + */ |
|
1224 | + protected function getModuleUrl(array $urlParameters = array()) { |
|
1225 | + if ($this->pObj->id) { |
|
1226 | + $urlParameters = array_merge($urlParameters, array( |
|
1227 | 1227 | 'id' => $this->pObj->id |
1228 | 1228 | )); |
1229 | - } |
|
1229 | + } |
|
1230 | 1230 | return \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('M'), $urlParameters); |
1231 | - } |
|
1231 | + } |
|
1232 | 1232 | } |
1233 | 1233 | |
1234 | 1234 | if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/crawler/modfunc1/class.tx_crawler_modfunc1.php']) { |
1235 | - include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/crawler/modfunc1/class.tx_crawler_modfunc1.php']); |
|
1235 | + include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/crawler/modfunc1/class.tx_crawler_modfunc1.php']); |
|
1236 | 1236 | } |