69 lines
1.8 KiB
PHP
69 lines
1.8 KiB
PHP
<?php
|
|
|
|
use KupShop\CatalogBundle\Search\FulltextInterface;
|
|
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
|
|
|
|
$main_class = 'fulltext';
|
|
|
|
class fulltext extends Window
|
|
{
|
|
use \KupShop\AdminBundle\FulltextUpdatesTrait;
|
|
|
|
public function get_vars()
|
|
{
|
|
$vars = parent::get_vars();
|
|
|
|
/** @var FulltextInterface $fulltext */
|
|
$fulltext = ServiceContainer::getService(FulltextInterface::class);
|
|
|
|
$vars['synonyms'] = $fulltext->loadSynonyms();
|
|
$vars['support'] = true;
|
|
|
|
return $vars;
|
|
}
|
|
|
|
public function handle()
|
|
{
|
|
if (!getVal('Submit') && !getVal('Reindex')) {
|
|
return;
|
|
}
|
|
|
|
/** @var FulltextInterface $fulltext */
|
|
$fulltext = ServiceContainer::getService(FulltextInterface::class);
|
|
$data = $this->getData();
|
|
$synonyms = [];
|
|
|
|
foreach ($data as $line) {
|
|
if (!empty($line['from']) && !empty($line['to']) && !key_exists('delete', $line)) {
|
|
$synonyms[] = $line;
|
|
}
|
|
}
|
|
$fulltext->updateSynonyms($synonyms);
|
|
|
|
if (getVal('Reindex')) {
|
|
ini_set('max_execution_time', 500);
|
|
try {
|
|
$this->updateIndices();
|
|
} catch (\KupShop\CatalogBundle\Search\Exception\FulltextException $e) {
|
|
getRaven()->captureException($e);
|
|
$this->returnError('Nastala chyba při generování vyhledávácího indexu');
|
|
}
|
|
}
|
|
|
|
$this->handleTabs(true);
|
|
|
|
$this->returnOK();
|
|
}
|
|
|
|
public function hasRights($name = null)
|
|
{
|
|
switch ($name) {
|
|
case Window::RIGHT_DUPLICATE:
|
|
case Window::RIGHT_DELETE:
|
|
return false;
|
|
default:
|
|
return parent::hasRights($name);
|
|
}
|
|
}
|
|
}
|