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