/** * Produces a table with overview of the URLs to be crawled for each page * * @return string HTML output */ function drawURLs() { global $BACK_PATH, $BE_USER; // Init: $this->duplicateTrack = array(); $this->submitCrawlUrls = t3lib_div::_GP('_crawl'); $this->downloadCrawlUrls = t3lib_div::_GP('_download'); $this->makeCrawlerProcessableChecks(); switch ((string) t3lib_div::_GP('tstamp')) { case 'midnight': $this->scheduledTime = mktime(0, 0, 0); break; case '04:00': $this->scheduledTime = mktime(0, 0, 0) + 4 * 3600; break; case 'now': default: $this->scheduledTime = time(); break; } // $this->reqMinute = t3lib_div::intInRange(t3lib_div::_GP('perminute'),1,10000); // TODO: check relevance $this->reqMinute = 1000; $this->incomingConfigurationSelection = t3lib_div::_GP('configurationSelection'); $this->incomingConfigurationSelection = is_array($this->incomingConfigurationSelection) ? $this->incomingConfigurationSelection : array(''); $this->crawlerObj = t3lib_div::makeInstance('tx_crawler_lib'); $this->crawlerObj->setAccessMode('gui'); $this->crawlerObj->setID = t3lib_div::md5int(microtime()); if (empty($this->incomingConfigurationSelection) || count($this->incomingConfigurationSelection) == 1 && empty($this->incomingConfigurationSelection[0])) { $code = ' <tr> <td colspan="7"><b>' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.noConfigSelected') . '</b></td> </tr>'; } else { if ($this->submitCrawlUrls) { $reason = new tx_crawler_domain_reason(); $reason->setReason(tx_crawler_domain_reason::REASON_GUI_SUBMIT); if ($BE_USER instanceof t3lib_beUserAuth) { $username = $BE_USER->user['username']; } $reason->setDetailText('The user ' . $username . ' added pages to the crawler queue manually '); tx_crawler_domain_events_dispatcher::getInstance()->post('invokeQueueChange', $this->findCrawler()->setID, array('reason' => $reason)); } $code = $this->crawlerObj->getPageTreeAndUrls($this->pObj->id, $this->pObj->MOD_SETTINGS['depth'], $this->scheduledTime, $this->reqMinute, $this->submitCrawlUrls, $this->downloadCrawlUrls, array(), $this->incomingConfigurationSelection); } $this->downloadUrls = $this->crawlerObj->downloadUrls; $this->duplicateTrack = $this->crawlerObj->duplicateTrack; $output = ''; if ($code) { $output .= '<h3>' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.configuration') . ':</h3>'; $output .= '<input type="hidden" name="id" value="' . intval($this->pObj->id) . '" />'; if (!$this->submitCrawlUrls) { $output .= $this->drawURLs_cfgSelectors() . '<br />'; $output .= '<input type="submit" name="_update" value="' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.triggerUpdate') . '" /> '; $output .= '<input type="submit" name="_crawl" value="' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.triggerCrawl') . '" /> '; $output .= '<input type="submit" name="_download" value="' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.triggerDownload') . '" /><br /><br />'; $output .= $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.count') . ': ' . count(array_keys($this->duplicateTrack)) . '<br />'; $output .= $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.curtime') . ': ' . date('H:i:s', time()) . '<br />'; $output .= '<br /> <table class="lrPadding c-list url-table">' . $this->drawURLs_printTableHeader() . $code . '</table>'; } else { $output .= count(array_keys($this->duplicateTrack)) . ' ' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.submitted') . '. <br /><br />'; $output .= '<input type="submit" name="_" value="' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.continue') . '" />'; $output .= '<input type="submit" onclick="this.form.elements[\'SET[crawlaction]\'].value=\'log\';" value="' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.continueinlog') . '" />'; } } // Download Urls to crawl: if ($this->downloadCrawlUrls) { // Creating output header: $mimeType = 'application/octet-stream'; Header('Content-Type: ' . $mimeType); Header('Content-Disposition: attachment; filename=CrawlerUrls.txt'); // Printing the content of the CSV lines: echo implode(chr(13) . chr(10), $this->downloadUrls); // Exits: exit; } // Return output: return $output; }