コード例 #1
0
 /**
  * Index action, shows an overview of the state of the Solr index
  *
  * @return void
  */
 public function indexAction()
 {
     $this->checkConnections();
     $this->view->assign('site', $this->request->getArgument('site'));
     $this->view->assign('apiKey', \Tx_Solr_Api::getApiKey());
 }
コード例 #2
0
ファイル: index.php プロジェクト: punktDe/solr
    /**
     * Generates the module content
     *
     * @return void
     */
    protected function getModuleContent()
    {
        //// TEMPORARY
        // TODO add a "discover/update Solr connections button to the global section"
        $content = '
			<input type="hidden" id="solraction" name="solraction" value="" />
			';
        $content .= '<fieldset><legend>Site Actions</legend>';
        $content .= $this->renderIndexQueueInitializationSelector();
        $content .= '
				<input type="submit" value="Initialize Index Queue" name="s_initializeIndexQueue" onclick="document.forms[0].solraction.value=\'initializeIndexQueue\';" /> ';
        $content .= t3lib_BEfunc::wrapInHelp('', '', '', array('title' => 'Index Queue Initialization', 'description' => 'Initializing the Index Queue is the most complete way to force reindexing, or to build the Index Queue for
							 the first time. The Index Queue Worker scheduler task will then index the items listed in the Index Queue.
							 Initializing the Index Queue without selecting specific indexing configurations will behave like selecting all.'));
        $content .= '
				<br /><br /><hr /><br />
				<input type="submit" value="Clean up Site Index" name="s_cleanupSiteCores" onclick="document.forms[0].solraction.value=\'cleanupSiteCores\';" />';
        $content .= '
				<br /><br />
				<input type="submit" value="Empty Site Index" name="s_deleteSiteDocuments" onclick="Check = confirm(\'This will commit documents which may be pending, delete documents belonging to the currently selected site and commit again afterwards. Are you sure you want to delete the site\\\'s documents?\'); if (Check == true) document.forms[0].solraction.value=\'deleteSiteDocuments\';" />
			';
        $content .= '
				<br /><br />
				<input type="submit" value="Reload Index Configuration" name="s_reloadCore" onclick="document.forms[0].solraction.value=\'reloadSiteCores\';" />';
        $content .= '
			<br /><br /><hr /><br />
			<p>
				Delete document(s) from site index<br /><br />
			</p>
			<label for="delete_uid" style="display:block;width:60px;float:left">Item uid</label>
			<input id="delete_uid" type="text" name="delete_uid" value="" /> (also accepts comma separated lists of uids)<br /><br />
			<label for="delete_type" style="display:block;width:60px;float:left;">Item type</label>
			<input id="delete_type" type="text" name="delete_type" value="" /> (table name)<br /><br />
			<input type="submit" value="Delete Document(s)"name="s_deleteDocument" onclick="document.forms[0].solraction.value=\'deleteDocument\';" /><br /><br />
			';
        $content .= '</fieldset>';
        $content .= '
			<fieldset>
				<legend>Global Actions (affecting all sites and indexes)</legend>
				<input type="submit" value="Empty Index" name="s_emptyIndex" onclick="Check = confirm(\'This will commit documents which may be pending, clear the index and commit again afterwards. Are you sure you want to empty the index?\'); if (Check == true) document.forms[0].solraction.value=\'emptyIndex\';" /><br /><br />
			</fieldset>';
        $content .= '
			<hr class="double" />
			API Key: ' . Tx_Solr_Api::getApiKey();
        // TODO add a checkbox to the delete documents fields to also remove from Index Queue
        switch ($_POST['solraction']) {
            case 'initializeIndexQueue':
                $this->initializeIndexQueue();
                break;
            case 'cleanupSiteCores':
                $this->cleanupSiteIndex();
                break;
            case 'deleteSiteDocuments':
                $this->deleteSiteDocuments();
                break;
            case 'reloadSiteCores':
                $this->reloadSiteCores();
                break;
            case 'emptyIndex':
                $this->emptyIndex();
                break;
            case 'deleteDocument':
                $this->deleteDocument();
                break;
            default:
        }
        $this->content .= $this->doc->section('Apache Solr for TYPO3', $content, FALSE, TRUE);
    }
コード例 #3
0
ファイル: Dispatch.php プロジェクト: punktDe/solr
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  The GNU General Public License can be found at
*  http://www.gnu.org/copyleft/gpl.html.
*
*  This script is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
$api = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('api');
$apiKey = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('apiKey'));
if (!Tx_Solr_Api::isValidApiKey($apiKey)) {
    header(t3lib_utility_Http::HTTP_STATUS_403);
    header('Content-Type: application/json; charset=utf-8');
    echo json_encode(array('errorMessage' => 'Invalid API key'));
} else {
    switch ($api) {
        case 'siteHash':
            include 'SiteHash.php';
            break;
        default:
            header(t3lib_utility_Http::HTTP_STATUS_400);
            header('Content-Type: application/json; charset=utf-8');
            echo json_encode(array('errorMessage' => 'You must provide an available API method, e.g. siteHash.'));
            break;
    }
}