/** * Main method of the module * * @return HTML */ function main() { global $LANG; $LANG->includeLLFile('EXT:solradmin/mod1/locallang.xml'); $id = t3lib_div::_GP('id'); $content = ''; $content .= ' <script language="javascript" type="text/javascript"> script_ended = 0; function jumpToUrl(URL) { document.location = URL; } function deleteRecord(url) { // if (confirm(' . $LANG->JScharCode($LANG->getLL('areyousure')) . ')) { jumpToUrl(url); } return false; } </script> '; if ($id > 0) { $solrConnection = t3lib_div::makeInstance('tx_solr_ConnectionManager')->getConnectionByPageId($id); $solrAdminConnection = new tx_solradmin_connection($solrConnection); $solrAdminConnection->checkDelete(); $site = $solrAdminConnection->escape(t3lib_div::getIndpEnv('TYPO3_SITE_URL')); $host = t3lib_div::getIndpEnv('TYPO3_HOST_ONLY'); //$query = 'uid:' . intval($id) . ' AND (site:' . $site . ' OR site:' . $host . ')'; $query = ' (*:* uid:' . intval($id) . ' AND type:pages) OR (*:* pid:' . intval($id) . ' AND NOT type:pages)'; $offset = 0; $limit = 100; $params = array('qt' => 'standard'); $solrid = t3lib_div::_GP('solrid'); $solrAdminConnection->setCurrentUrl(t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR') . 'index.php?id=' . $id); if (!empty($solrid)) { $response = $solrAdminConnection->search('id:' . $solrAdminConnection->escape($solrid), 0, 1000, $params); $content .= $solrAdminConnection->renderRecord($response); } else { $response = $solrAdminConnection->search($query, $offset, $limit, $params); if (intval($response->response->numFound) === 0) { $content .= $GLOBALS['LANG']->getLL('nodata'); } else { $content .= $solrAdminConnection->renderRecords($response, array('id', 'title', 'indexed')); } } } else { $content .= $GLOBALS['LANG']->getLL('nosolrconf'); } return $this->pObj->doc->spacer(5) . $this->pObj->doc->section('Solr Admin', $content, 0, 1); }
/** * Execute the task * * @return bool */ public function execute() { require_once PATH_site . 'typo3conf/ext/solradmin/classes/class.tx_solradmin_connection.php'; $site = $this->site; $solrConnections = t3lib_div::makeInstance('tx_solr_ConnectionManager')->getAllConnections(); $this->solrAdminConnection = new tx_solradmin_connection($solrConnections[0]); $query = 'site:' . $this->solrAdminConnection->escapeUrlvalue($site) . '*'; $offset = 0; $limit = $this->limit; $params = array('qt' => 'standard'); $response = $this->solrAdminConnection->search($query, $offset, $limit, $params); if (defined('TYPO3_cliMode') && TYPO3_cliMode) { echo '---------------------------------------------' . LF; echo 'Checking query "' . $query . '" (' . intval($response->response->numFound) . ' results) --> limit ' . $limit . LF; echo '---------------------------------------------' . LF; } foreach ($response->response->docs as $doc) { if (substr($doc->url, 0, 4) == 'http') { $url = $doc->url; } else { $url = $site . $doc->url; } //echo $url; if (($checkUrl = $this->checkUrl($url)) === TRUE) { //echo ' --> OK' . LF; } else { $this->urlDelete[] = array('id' => $doc->id, 'created' => $doc->created, 'indexed' => $doc->indexed, 'url' => $url); //echo ' --> !!!!! KO !!!!!' . LF; } } if (empty($this->delete)) { if (defined('TYPO3_cliMode') && TYPO3_cliMode) { echo 'Just checking url and not delete them...' . LF; } } else { if (defined('TYPO3_cliMode') && TYPO3_cliMode) { echo 'Check and delete url...' . LF; } foreach ($this->urlDelete as $deleteRecord) { $delete = tx_solradmin_connection::escape($deleteRecord['id']); $this->solrAdminConnection->getSolrConnection()->commit(); $this->solrAdminConnection->getSolrConnection()->deleteByQuery('id:' . $delete); $this->solrAdminConnection->getSolrConnection()->commit(); } } if (defined('TYPO3_cliMode') && TYPO3_cliMode) { echo '---------------------------------------------' . LF; echo 'Bad urls (' . count($this->urlDelete) . ' results)' . LF; echo '---------------------------------------------' . LF; print_r($this->urlDelete); } return TRUE; }