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