示例#1
0
文件: index.php 项目: punktDe/solr
 protected function deleteDocument()
 {
     $documentUid = \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('delete_uid');
     $documentType = \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('delete_type');
     $message = 'Document(s) with type ' . $documentType . ' and id ' . $documentUid . ' deleted';
     $severity = t3lib_FlashMessage::OK;
     if (empty($documentUid) || empty($documentType)) {
         $message = 'Missing uid or type to delete documents.';
         $severity = t3lib_FlashMessage::ERROR;
     } else {
         try {
             $uids = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $documentUid);
             $uidCondition = implode(' OR ', $uids);
             $solrServers = $this->connectionManager->getConnectionsBySite($this->site);
             foreach ($solrServers as $solrServer) {
                 $response = $solrServer->deleteByQuery('uid:(' . $uidCondition . ')' . ' AND type:' . $documentType . ' AND siteHash:' . $this->site->getSiteHash());
                 $solrServer->commit(FALSE, FALSE, FALSE);
                 if ($response->getHttpStatus() != 200) {
                     throw new RuntimeException('Delete Query failed.', 1332250835);
                 }
             }
         } catch (Exception $e) {
             $message = $e->getMessage();
             $severity = t3lib_FlashMessage::ERROR;
         }
     }
     $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('t3lib_FlashMessage', $message, '', $severity);
     t3lib_FlashMessageQueue::addMessage($flashMessage);
 }
示例#2
0
 /**
  * Checks whether a Solr server is available and provides some information.
  *
  * @param	array	Solr connection parameters
  * @return	tx_reports_reports_status_Status Status of the Solr connection
  */
 protected function getConnectionStatus(array $solrConection)
 {
     $value = 'Your site was unable to contact the Apache Solr server.';
     $severity = tx_reports_reports_status_Status::ERROR;
     $solr = $this->connectionManager->getConnection($solrConection['solrHost'], $solrConection['solrPort'], $solrConection['solrPath'], $solrConection['solrScheme']);
     $message = '<ul>' . '<li style="padding-bottom: 10px;">Site: ' . $solrConection['label'] . '</li>' . '<li>Scheme: ' . $solr->getScheme() . '</li>' . '<li>Host: ' . $solr->getHost() . '</li>' . '<li>Port: ' . $solr->getPort() . '</li>' . '<li style="padding-bottom: 10px;">Path: ' . $solr->getPath() . '</li>';
     $pingQueryTime = $solr->ping();
     if ($pingQueryTime !== FALSE) {
         $severity = tx_reports_reports_status_Status::OK;
         $value = 'Your site has contacted the Apache Solr server.';
         $solrVersion = $this->formatSolrVersion($solr->getSolrServerVersion());
         $message .= '<li>Apache Solr: ' . $solrVersion . '</li>';
         $message .= '<li>Ping Query Time: ' . (int) ($pingQueryTime * 1000) . 'ms</li>';
         $message .= '<li>schema.xml: ' . $solr->getSchemaName() . '</li>';
         $message .= '<li>solrconfig.xml: ' . $solr->getSolrconfigName() . '</li>';
         $accessFilterPluginStatus = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Solr_Report_AccessFilterPluginInstalledStatus');
         $accessFilterPluginVersion = $accessFilterPluginStatus->getInstalledPluginVersion($solr);
         $message .= '<li>Access Filter Plugin: ' . $accessFilterPluginVersion . '</li>';
     }
     $message .= '</ul>';
     return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_reports_reports_status_Status', 'Apache Solr', $value, $message, $severity);
 }
示例#3
0
文件: Indexer.php 项目: punktDe/solr
 /**
  * Checks for which languages connections have been configured and returns
  * these connections.
  *
  * @param	array	An array of translation overlays to check for configured connections.
  * @return	array	An array of Tx_Solr_SolrService connections.
  */
 protected function getConnectionsForIndexableLanguages(array $translationOverlays)
 {
     $connections = array();
     foreach ($translationOverlays as $translationOverlay) {
         $pageId = $translationOverlay['pid'];
         $languageId = $translationOverlay['sys_language_uid'];
         try {
             $connection = $this->connectionManager->getConnectionByPageId($pageId, $languageId);
             $connections[$languageId] = $connection;
         } catch (Tx_Solr_NoSolrConnectionFoundException $e) {
             // ignore the exception as we seek only those connections
             // actually available
         }
     }
     return $connections;
 }