action) { return $this->doTree(); } if ('subtree' == $this->action) { return $this->doSubTree($_REQUEST['what']); } $this->printHeader(); $this->printBody(); if (isset($_POST['cancel'])) { if (isset($_POST['prev_action'])) { $this->action = $_POST['prev_action']; } else { $this->action = ''; } } switch ($this->action) { case 'createconfig': if (isset($_POST['create'])) { $this->doSaveCreateConfig(); } else { $this->doCreateConfig(); } break; case 'alterconfig': if (isset($_POST['alter'])) { $this->doSaveAlterConfig(); } else { $this->doAlterConfig(); } break; case 'dropconfig': if (isset($_POST['drop'])) { $this->doDropConfig(false); } else { $this->doDropConfig(true); } break; case 'viewconfig': $this->doViewConfig($_REQUEST['ftscfg']); break; case 'viewparsers': $this->doViewParsers(); break; case 'viewdicts': $this->doViewDicts(); break; case 'createdict': if (isset($_POST['create'])) { $this->doSaveCreateDict(); } else { $this->doCreateDict(); } break; case 'alterdict': if (isset($_POST['alter'])) { $this->doSaveAlterDict(); } else { $this->doAlterDict(); } break; case 'dropdict': if (isset($_POST['drop'])) { $this->doDropDict(false); } else { $this->doDropDict(true); } break; case 'dropmapping': if (isset($_POST['drop'])) { $this->doDropMapping(false); } else { $this->doDropMapping(true); } break; case 'altermapping': if (isset($_POST['alter'])) { $this->doSaveAlterMapping(); } else { $this->doAlterMapping(); } break; case 'addmapping': if (isset($_POST['add'])) { $this->doSaveAddMapping(); } else { $this->doAddMapping(); } break; default: $this->doDefault(); break; } return $this->printFooter(); } public function doDefault($msg = '') { $data = $this->misc->getDatabaseAccessor(); $this->printTrail('schema'); $this->printTabs('schema', 'fulltext'); $this->printTabs('fulltext', 'ftsconfigs'); $this->printMsg($msg); $cfgs = $data->getFtsConfigurations(false); $columns = [ 'configuration' => [ 'title' => $this->lang['strftsconfig'], 'field' => Decorator::field('name'), 'url' => "fulltext?action=viewconfig&{$this->misc->href}&", 'vars' => ['ftscfg' => 'name'], ], 'schema' => [ 'title' => $this->lang['strschema'], 'field' => Decorator::field('schema'), ], 'actions' => [ 'title' => $this->lang['stractions'], ], 'comment' => [ 'title' => $this->lang['strcomment'], 'field' => Decorator::field('comment'), ], ]; $actions = [ 'drop' => [ 'content' => $this->lang['strdrop'], 'attr' => [ 'href' => [ 'url' => 'fulltext', 'urlvars' => [ 'action' => 'dropconfig', 'ftscfg' => Decorator::field('name'), ], ], ], ], 'alter' => [ 'content' => $this->lang['stralter'], 'attr' => [ 'href' => [ 'url' => 'fulltext', 'urlvars' => [ 'action' => 'alterconfig', 'ftscfg' => Decorator::field('name'), ], ], ], ], ]; echo $this->printTable($cfgs, $columns, $actions, 'fulltext-fulltext', $this->lang['strftsnoconfigs']); $navlinks = [ 'createconf' => [ 'attr' => [ 'href' => [ 'url' => 'fulltext', 'urlvars' => [ 'action' => 'createconfig', 'server' => $_REQUEST['server'], 'database' => $_REQUEST['database'], 'schema' => $_REQUEST['schema'], ], ], ], 'content' => $this->lang['strftscreateconfig'], ], ]; $this->printNavLinks($navlinks, 'fulltext-fulltext', get_defined_vars()); } /** * Generate XML for the browser tree. */ public function doTree() { $tabs = $this->misc->getNavTabs('fulltext'); $items = $this->adjustTabsForTree($tabs); $reqvars = $this->misc->getRequestVars('ftscfg'); $attrs = [ 'text' => Decorator::field('title'), 'icon' => Decorator::field('icon'), 'action' => Decorator::actionurl( 'fulltext', $reqvars, Decorator::field('urlvars') ), 'branch' => Decorator::url( 'fulltext', $reqvars, [ 'action' => 'subtree', 'what' => Decorator::field('icon'), // IZ: yeah, it's ugly, but I do not want to change navigation tabs arrays ] ), ]; return $this->printTree($items, $attrs, 'fts'); } public function doSubTree($what) { $data = $this->misc->getDatabaseAccessor(); switch ($what) { case 'FtsCfg': $items = $data->getFtsConfigurations(false); $urlvars = ['action' => 'viewconfig', 'ftscfg' => Decorator::field('name')]; break; case 'FtsDict': $items = $data->getFtsDictionaries(false); $urlvars = ['action' => 'viewdicts']; break; case 'FtsParser': $items = $data->getFtsParsers(false); $urlvars = ['action' => 'viewparsers']; break; default: return; } $reqvars = $this->misc->getRequestVars('ftscfg'); $attrs = [ 'text' => Decorator::field('name'), 'icon' => $what, 'toolTip' => Decorator::field('comment'), 'action' => Decorator::actionurl( 'fulltext', $reqvars, $urlvars ), 'branch' => Decorator::ifempty( Decorator::field('branch'), '', Decorator::url( 'fulltext', $reqvars, [ 'action' => 'subtree', 'ftscfg' => Decorator::field('name'), ] ) ), ]; return $this->printTree($items, $attrs, strtolower($what)); } public function doDropConfig($confirm) { $data = $this->misc->getDatabaseAccessor(); if ($confirm) { $this->printTrail('ftscfg'); $this->printTitle($this->lang['strdrop'], 'pg.ftscfg.drop'); echo '

', sprintf($this->lang['strconfdropftsconfig'], $this->misc->printVal($_REQUEST['ftscfg'])), '

'.PHP_EOL; echo '
'.PHP_EOL; echo "

".PHP_EOL; echo '

'.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo $this->misc->form; echo "lang['strdrop']}\" />".PHP_EOL; echo "lang['strcancel']}\" />

".PHP_EOL; echo '
'.PHP_EOL; } else { $status = $data->dropFtsConfiguration($_POST['ftscfg'], isset($_POST['cascade'])); if (0 == $status) { $this->misc->setReloadBrowser(true); $this->doDefault($this->lang['strftsconfigdropped']); } else { $this->doDefault($this->lang['strftsconfigdroppedbad']); } } } public function doDropDict($confirm) { $data = $this->misc->getDatabaseAccessor(); if ($confirm) { $this->printTrail('ftscfg'); // TODO: change to smth related to dictionary $this->printTitle($this->lang['strdrop'], 'pg.ftsdict.drop'); echo '

', sprintf($this->lang['strconfdropftsdict'], $this->misc->printVal($_REQUEST['ftsdict'])), '

'.PHP_EOL; echo '
'.PHP_EOL; echo "

".PHP_EOL; echo '

'.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; //echo "".PHP_EOL; echo '

'.PHP_EOL; echo $this->misc->form; echo "lang['strdrop']}\" />".PHP_EOL; echo "lang['strcancel']}\" />

".PHP_EOL; echo '
'.PHP_EOL; } else { $status = $data->dropFtsDictionary($_POST['ftsdict'], isset($_POST['cascade'])); if (0 == $status) { $this->misc->setReloadBrowser(true); $this->doViewDicts($this->lang['strftsdictdropped']); } else { $this->doViewDicts($this->lang['strftsdictdroppedbad']); } } } /** * Displays a screen where one can enter a new FTS configuration. * * @param mixed $msg */ public function doCreateConfig($msg = '') { $data = $this->misc->getDatabaseAccessor(); $this->coalesceArr($_POST, 'formName', ''); $this->coalesceArr($_POST, 'formParser', ''); $this->coalesceArr($_POST, 'formTemplate', ''); $this->coalesceArr($_POST, 'formWithMap', ''); $this->coalesceArr($_POST, 'formComment', ''); // Fetch all FTS configurations from the database $ftscfgs = $data->getFtsConfigurations(); // Fetch all FTS parsers from the database $ftsparsers = $data->getFtsParsers(); $this->printTrail('schema'); $this->printTitle($this->lang['strftscreateconfig'], 'pg.ftscfg.create'); $this->printMsg($msg); echo '
'.PHP_EOL; echo ''.PHP_EOL; // conf name echo "\t\n\t\t".PHP_EOL; echo "\t\t\n\t".PHP_EOL; // Template echo "\t\n\t\t".PHP_EOL; echo "\t\t\n\t".PHP_EOL; // Parser echo "\t\n\t\t".PHP_EOL; echo "\t\t\n\t".PHP_EOL; // Comment echo "\t\n\t\t".PHP_EOL; echo "\t\t\n\t".PHP_EOL; echo '
{$this->lang['strname']}_maxNameLen}\" value=\"", htmlspecialchars($_POST['formName']), "\" />
{$this->lang['strftstemplate']}"; $tpls = []; $tplsel = ''; while (!$ftscfgs->EOF) { $data->fieldClean($ftscfgs->fields['schema']); $data->fieldClean($ftscfgs->fields['name']); $tplname = $ftscfgs->fields['schema'].'.'.$ftscfgs->fields['name']; $tpls[$tplname] = serialize([ 'name' => $ftscfgs->fields['name'], 'schema' => $ftscfgs->fields['schema'], ]); if ($_POST['formTemplate'] == $tpls[$tplname]) { $tplsel = htmlspecialchars($tpls[$tplname]); } $ftscfgs->moveNext(); } echo \PHPPgAdmin\XHtml\HTMLController::printCombo($tpls, 'formTemplate', true, $tplsel, false); echo "\n\t\t
{$this->lang['strftsparser']}".PHP_EOL; $ftsparsers_ = []; $ftsparsel = ''; while (!$ftsparsers->EOF) { $data->fieldClean($ftsparsers->fields['schema']); $data->fieldClean($ftsparsers->fields['name']); $parsername = $ftsparsers->fields['schema'].'.'.$ftsparsers->fields['name']; $ftsparsers_[$parsername] = serialize([ 'parser' => $ftsparsers->fields['name'], 'schema' => $ftsparsers->fields['schema'], ]); if ($_POST['formParser'] == $ftsparsers_[$parsername]) { $ftsparsel = htmlspecialchars($ftsparsers_[$parsername]); } $ftsparsers->moveNext(); } echo \PHPPgAdmin\XHtml\HTMLController::printCombo($ftsparsers_, 'formParser', true, $ftsparsel, false); echo "\n\t\t
{$this->lang['strcomment']}
'.PHP_EOL; echo '

'.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo $this->misc->form; echo "lang['strcreate']}\" />".PHP_EOL; echo "lang['strcancel']}\" />".PHP_EOL; echo '

'.PHP_EOL; echo '
'.PHP_EOL; } /** * Actually creates the new FTS configuration in the database. */ public function doSaveCreateConfig() { $data = $this->misc->getDatabaseAccessor(); $err = ''; // Check that they've given a name if ('' == $_POST['formName']) { $err .= "{$this->lang['strftsconfigneedsname']}
"; } if (('' != $_POST['formParser']) && ('' != $_POST['formTemplate'])) { $err .= "{$this->lang['strftscantparsercopy']}
"; } if ($err !== '') { return $this->doCreateConfig($err); } if ('' != $_POST['formParser']) { $formParser = unserialize($_POST['formParser']); } else { $formParser = ''; } if ('' != $_POST['formTemplate']) { $formTemplate = unserialize($_POST['formTemplate']); } else { $formTemplate = ''; } $status = $data->createFtsConfiguration($_POST['formName'], $formParser, $formTemplate, $_POST['formComment']); if (0 == $status) { $this->misc->setReloadBrowser(true); $this->doDefault($this->lang['strftsconfigcreated']); } else { $this->doCreateConfig($this->lang['strftsconfigcreatedbad']); } } /** * Display a form to permit editing FTS configuration properies. * * @param mixed $msg */ public function doAlterConfig($msg = '') { $data = $this->misc->getDatabaseAccessor(); $this->printTrail('ftscfg'); $this->printTitle($this->lang['stralter'], 'pg.ftscfg.alter'); $this->printMsg($msg); $ftscfg = $data->getFtsConfigurationByName($_REQUEST['ftscfg']); if ($ftscfg->recordCount() > 0) { $this->coalesceArr($_POST, 'formComment', $ftscfg->fields['comment']); $this->coalesceArr($_POST, 'ftscfg', $_REQUEST['ftscfg']); $this->coalesceArr($_POST, 'formName', $_REQUEST['ftscfg']); $this->coalesceArr($_POST, 'formParser', ''); // Fetch all FTS parsers from the database $ftsparsers = $data->getFtsParsers(); echo '
'.PHP_EOL; echo ''.PHP_EOL; echo "\t".PHP_EOL; echo "\t\t".PHP_EOL; echo "\t\t".PHP_EOL; echo "\t".PHP_EOL; // Comment echo "\t".PHP_EOL; echo "\t\t".PHP_EOL; echo "\t\t'.PHP_EOL; echo "\t".PHP_EOL; echo '
{$this->lang['strname']}"; echo "\t\t\t_maxNameLen}\" value=\"", htmlspecialchars($_POST['formName']), '" />'.PHP_EOL; echo "\t\t
{$this->lang['strcomment']}
'.PHP_EOL; echo '

'.PHP_EOL; echo ''.PHP_EOL; echo $this->misc->form; echo "lang['stralter']}\" />".PHP_EOL; echo "lang['strcancel']}\" />

".PHP_EOL; echo '
'.PHP_EOL; } else { echo "

{$this->lang['strnodata']}

".PHP_EOL; } } /** * Save the form submission containing changes to a FTS configuration. */ public function doSaveAlterConfig() { $data = $this->misc->getDatabaseAccessor(); $status = $data->updateFtsConfiguration($_POST['ftscfg'], $_POST['formComment'], $_POST['formName']); if (0 == $status) { $this->doDefault($this->lang['strftsconfigaltered']); } else { $this->doAlterConfig($this->lang['strftsconfigalteredbad']); } } /** * View list of FTS parsers. * * @param mixed $msg */ public function doViewParsers($msg = '') { $data = $this->misc->getDatabaseAccessor(); $this->printTrail('schema'); $this->printTabs('schema', 'fulltext'); $this->printTabs('fulltext', 'ftsparsers'); $this->printMsg($msg); $parsers = $data->getFtsParsers(false); $columns = [ 'schema' => [ 'title' => $this->lang['strschema'], 'field' => Decorator::field('schema'), ], 'name' => [ 'title' => $this->lang['strname'], 'field' => Decorator::field('name'), ], 'comment' => [ 'title' => $this->lang['strcomment'], 'field' => Decorator::field('comment'), ], ]; $actions = []; echo $this->printTable($parsers, $columns, $actions, 'fulltext-viewparsers', $this->lang['strftsnoparsers']); //TODO: navlink to "create parser" } /** * View list of FTS dictionaries. * * @param mixed $msg */ public function doViewDicts($msg = '') { $data = $this->misc->getDatabaseAccessor(); $this->printTrail('schema'); $this->printTabs('schema', 'fulltext'); $this->printTabs('fulltext', 'ftsdicts'); $this->printMsg($msg); $dicts = $data->getFtsDictionaries(false); $columns = [ 'schema' => [ 'title' => $this->lang['strschema'], 'field' => Decorator::field('schema'), ], 'name' => [ 'title' => $this->lang['strname'], 'field' => Decorator::field('name'), ], 'actions' => [ 'title' => $this->lang['stractions'], ], 'comment' => [ 'title' => $this->lang['strcomment'], 'field' => Decorator::field('comment'), ], ]; $actions = [ 'drop' => [ 'content' => $this->lang['strdrop'], 'attr' => [ 'href' => [ 'url' => 'fulltext', 'urlvars' => [ 'action' => 'dropdict', 'ftsdict' => Decorator::field('name'), ], ], ], ], 'alter' => [ 'content' => $this->lang['stralter'], 'attr' => [ 'href' => [ 'url' => 'fulltext', 'urlvars' => [ 'action' => 'alterdict', 'ftsdict' => Decorator::field('name'), ], ], ], ], ]; echo $this->printTable($dicts, $columns, $actions, 'fulltext-viewdicts', $this->lang['strftsnodicts']); $navlinks = [ 'createdict' => [ 'attr' => [ 'href' => [ 'url' => 'fulltext', 'urlvars' => [ 'action' => 'createdict', 'server' => $_REQUEST['server'], 'database' => $_REQUEST['database'], 'schema' => $_REQUEST['schema'], ], ], ], 'content' => $this->lang['strftscreatedict'], ], ]; $this->printNavLinks($navlinks, 'fulltext-viewdicts', get_defined_vars()); } /** * View details of FTS configuration given. * * @param mixed $ftscfg * @param mixed $msg */ public function doViewConfig($ftscfg, $msg = '') { $data = $this->misc->getDatabaseAccessor(); $this->printTrail('ftscfg'); $this->printTabs('schema', 'fulltext'); $this->printTabs('fulltext', 'ftsconfigs'); $this->printMsg($msg); echo "

{$this->lang['strftsconfigmap']}

".PHP_EOL; $map = $data->getFtsConfigurationMap($ftscfg); $columns = [ 'name' => [ 'title' => $this->lang['strftsmapping'], 'field' => Decorator::field('name'), ], 'dictionaries' => [ 'title' => $this->lang['strftsdicts'], 'field' => Decorator::field('dictionaries'), ], 'actions' => [ 'title' => $this->lang['stractions'], ], 'comment' => [ 'title' => $this->lang['strcomment'], 'field' => Decorator::field('description'), ], ]; $actions = [ 'drop' => [ 'multiaction' => 'dropmapping', 'content' => $this->lang['strdrop'], 'attr' => [ 'href' => [ 'url' => 'fulltext', 'urlvars' => [ 'action' => 'dropmapping', 'mapping' => Decorator::field('name'), 'ftscfg' => Decorator::field('cfgname'), ], ], ], ], 'alter' => [ 'content' => $this->lang['stralter'], 'attr' => [ 'href' => [ 'url' => 'fulltext', 'urlvars' => [ 'action' => 'altermapping', 'mapping' => Decorator::field('name'), 'ftscfg' => Decorator::field('cfgname'), ], ], ], ], 'multiactions' => [ 'keycols' => ['mapping' => 'name'], 'url' => 'fulltext', 'default' => null, 'vars' => ['ftscfg' => $ftscfg], ], ]; echo $this->printTable($map, $columns, $actions, 'fulltext-viewconfig', $this->lang['strftsemptymap']); $navlinks = [ 'addmapping' => [ 'attr' => [ 'href' => [ 'url' => 'fulltext', 'urlvars' => [ 'action' => 'addmapping', 'server' => $_REQUEST['server'], 'database' => $_REQUEST['database'], 'schema' => $_REQUEST['schema'], 'ftscfg' => $ftscfg, ], ], ], 'content' => $this->lang['strftsaddmapping'], ], ]; $this->printNavLinks($navlinks, 'fulltext-viewconfig', get_defined_vars()); } /** * Displays a screen where one can enter a details of a new FTS dictionary. * * @param mixed $msg */ public function doCreateDict($msg = '') { $data = $this->misc->getDatabaseAccessor(); $this->coalesceArr($_POST, 'formName', ''); $this->coalesceArr($_POST, 'formIsTemplate', false); $this->coalesceArr($_POST, 'formTemplate', ''); $this->coalesceArr($_POST, 'formLexize', ''); $this->coalesceArr($_POST, 'formInit', ''); $this->coalesceArr($_POST, 'formOption', ''); $this->coalesceArr($_POST, 'formComment', ''); // Fetch all FTS dictionaries from the database $ftstpls = $data->getFtsDictionaryTemplates(); $this->printTrail('schema'); // TODO: create doc links $this->printTitle($this->lang['strftscreatedict'], 'pg.ftsdict.create'); $this->printMsg($msg); echo '
'.PHP_EOL; echo ''.PHP_EOL; echo "\t\n\t\t".PHP_EOL; echo "\t\t\n\t".PHP_EOL; // Template echo "\t\n\t\t".PHP_EOL; echo "\t\t\n\t".PHP_EOL; // TODO: what about maxlengths? // Lexize echo "\t\n\t\t".PHP_EOL; echo "\t\t\n\t".PHP_EOL; // Init echo "\t\n\t\t".PHP_EOL; echo "\t\t\n\t".PHP_EOL; // Option echo "\t\n\t\t".PHP_EOL; echo "\t\t\n\t".PHP_EOL; // Comment echo "\t\n\t\t".PHP_EOL; echo "\t\t\n\t".PHP_EOL; echo '
{$this->lang['strname']}_maxNameLen}\" value=\"", htmlspecialchars($_POST['formName']), '" /> ', '\n", "
{$this->lang['strftstemplate']}"; $tpls = []; $tplsel = ''; while (!$ftstpls->EOF) { $data->fieldClean($ftstpls->fields['schema']); $data->fieldClean($ftstpls->fields['name']); $tplname = $ftstpls->fields['schema'].'.'.$ftstpls->fields['name']; $tpls[$tplname] = serialize([ 'name' => $ftstpls->fields['name'], 'schema' => $ftstpls->fields['schema'], ]); if ($_POST['formTemplate'] == $tpls[$tplname]) { $tplsel = htmlspecialchars($tpls[$tplname]); } $ftstpls->moveNext(); } echo \PHPPgAdmin\XHtml\HTMLController::printCombo($tpls, 'formTemplate', true, $tplsel, false); echo "\n\t\t
{$this->lang['strftslexize']}
{$this->lang['strftsinit']}
{$this->lang['strftsoptionsvalues']}
{$this->lang['strcomment']}
'.PHP_EOL; echo '

'.PHP_EOL; echo ''.PHP_EOL; echo ''.PHP_EOL; echo $this->misc->form; echo "lang['strcreate']}\" />".PHP_EOL; echo "lang['strcancel']}\" />".PHP_EOL; echo '

'.PHP_EOL; echo "
\n", "".PHP_EOL; } /** * Actually creates the new FTS dictionary in the database. */ public function doSaveCreateDict() { $data = $this->misc->getDatabaseAccessor(); // Check that they've given a name if ('' == $_POST['formName']) { $this->doCreateDict($this->lang['strftsdictneedsname']); } else { $this->coalesceArr($_POST, 'formIsTemplate', false); if (isset($_POST['formTemplate'])) { $formTemplate = unserialize($_POST['formTemplate']); } else { $formTemplate = ''; } $this->coalesceArr($_POST, 'formLexize', ''); $this->coalesceArr($_POST, 'formInit', ''); $this->coalesceArr($_POST, 'formOption', ''); $status = $data->createFtsDictionary( $_POST['formName'], $_POST['formIsTemplate'], $formTemplate, $_POST['formLexize'], $_POST['formInit'], $_POST['formOption'], $_POST['formComment'] ); if (0 == $status) { $this->misc->setReloadBrowser(true); $this->doViewDicts($this->lang['strftsdictcreated']); } else { $this->doCreateDict($this->lang['strftsdictcreatedbad']); } } } /** * Display a form to permit editing FTS dictionary properies. * * @param mixed $msg */ public function doAlterDict($msg = '') { $data = $this->misc->getDatabaseAccessor(); $this->printTrail('ftscfg'); // TODO: change to smth related to dictionary $this->printTitle($this->lang['stralter'], 'pg.ftsdict.alter'); $this->printMsg($msg); $ftsdict = $data->getFtsDictionaryByName($_REQUEST['ftsdict']); if ($ftsdict->recordCount() > 0) { $this->coalesceArr($_POST, 'formComment', $ftsdict->fields['comment']); $this->coalesceArr($_POST, 'ftsdict', $_REQUEST['ftsdict']); $this->coalesceArr($_POST, 'formName', $_REQUEST['ftsdict']); echo '
'.PHP_EOL; echo ''.PHP_EOL; echo "\t".PHP_EOL; echo "\t\t".PHP_EOL; echo "\t\t".PHP_EOL; echo "\t".PHP_EOL; // Comment echo "\t".PHP_EOL; echo "\t\t".PHP_EOL; echo "\t\t'.PHP_EOL; echo "\t".PHP_EOL; echo '
{$this->lang['strname']}"; echo "\t\t\t_maxNameLen}\" value=\"", htmlspecialchars($_POST['formName']), '" />'.PHP_EOL; echo "\t\t
{$this->lang['strcomment']}
'.PHP_EOL; echo '

'.PHP_EOL; echo ''.PHP_EOL; echo '

'.PHP_EOL; echo $this->misc->form; echo "lang['stralter']}\" />".PHP_EOL; echo "lang['strcancel']}\" />

".PHP_EOL; echo '
'.PHP_EOL; } else { echo "

{$this->lang['strnodata']}

".PHP_EOL; } } /** * Save the form submission containing changes to a FTS dictionary. */ public function doSaveAlterDict() { $data = $this->misc->getDatabaseAccessor(); $status = $data->updateFtsDictionary($_POST['ftsdict'], $_POST['formComment'], $_POST['formName']); if (0 == $status) { $this->doViewDicts($this->lang['strftsdictaltered']); } else { $this->doAlterDict($this->lang['strftsdictalteredbad']); } } /** * Show confirmation of drop and perform actual drop of FTS mapping. * * @param mixed $confirm */ public function doDropMapping($confirm) { $data = $this->misc->getDatabaseAccessor(); if (empty($_REQUEST['mapping']) && empty($_REQUEST['ma'])) { $this->doDefault($this->lang['strftsspecifymappingtodrop']); return; } if (empty($_REQUEST['ftscfg'])) { $this->doDefault($this->lang['strftsspecifyconfigtoalter']); return; } if ($confirm) { $this->printTrail('ftscfg'); // TODO: proper breadcrumbs $this->printTitle($this->lang['strdrop'], 'pg.ftscfg.alter'); echo '
'.PHP_EOL; // Case of multiaction drop if (isset($_REQUEST['ma'])) { foreach ($_REQUEST['ma'] as $v) { $a = unserialize(htmlspecialchars_decode($v, ENT_QUOTES)); echo '

', sprintf($this->lang['strconfdropftsmapping'], $this->misc->printVal($a['mapping']), $this->misc->printVal($_REQUEST['ftscfg'])), '

'.PHP_EOL; printf('', htmlspecialchars($a['mapping'])); } } else { echo '

', sprintf($this->lang['strconfdropftsmapping'], $this->misc->printVal($_REQUEST['mapping']), $this->misc->printVal($_REQUEST['ftscfg'])), '

'.PHP_EOL; echo ''.PHP_EOL; } echo "".PHP_EOL; echo ''.PHP_EOL; echo '

'.PHP_EOL; echo $this->misc->form; echo "lang['strdrop']}\" />".PHP_EOL; echo "lang['strcancel']}\" />".PHP_EOL; echo '
'.PHP_EOL; } else { // Case of multiaction drop if (is_array($_REQUEST['mapping'])) { $status = $data->changeFtsMapping($_REQUEST['ftscfg'], $_REQUEST['mapping'], 'drop'); if (0 != $status) { $this->doViewConfig($_REQUEST['ftscfg'], $this->lang['strftsmappingdroppedbad']); return; } $this->doViewConfig($_REQUEST['ftscfg'], $this->lang['strftsmappingdropped']); } else { $status = $data->changeFtsMapping($_REQUEST['ftscfg'], [$_REQUEST['mapping']], 'drop'); if (0 == $status) { $this->doViewConfig($_REQUEST['ftscfg'], $this->lang['strftsmappingdropped']); } else { $this->doViewConfig($_REQUEST['ftscfg'], $this->lang['strftsmappingdroppedbad']); } } } } public function doAlterMapping($msg = '') { $data = $this->misc->getDatabaseAccessor(); $this->printTrail('ftscfg'); $this->printTitle($this->lang['stralter'], 'pg.ftscfg.alter'); $this->printMsg($msg); $ftsdicts = $data->getFtsDictionaries(); if ($ftsdicts->recordCount() > 0) { $this->coalesceArr($_POST, 'formMapping', @$_REQUEST['mapping']); $this->coalesceArr($_POST, 'formDictionary', ''); $this->coalesceArr($_POST, 'ftscfg', $_REQUEST['ftscfg']); echo '
'.PHP_EOL; echo ''.PHP_EOL; echo "\t".PHP_EOL; echo "\t\t".PHP_EOL; echo "\t\t".PHP_EOL; echo "\t".PHP_EOL; // Dictionary echo "\t".PHP_EOL; echo "\t\t".PHP_EOL; echo "\t\t".PHP_EOL; echo "\t".PHP_EOL; echo '
{$this->lang['strftsmapping']}"; $ma_mappings = []; // Case of multiaction drop if (isset($_REQUEST['ma'])) { $ma_mappings_names = []; foreach ($_REQUEST['ma'] as $v) { $a = unserialize(htmlspecialchars_decode($v, ENT_QUOTES)); printf('', htmlspecialchars($a['mapping'])); $ma_mappings[] = $data->getFtsMappingByName($_POST['ftscfg'], $a['mapping']); $ma_mappings_names[] = $a['mapping']; } echo implode(', ', $ma_mappings_names); } else { $mapping = $data->getFtsMappingByName($_POST['ftscfg'], $_POST['formMapping']); echo $mapping->fields['name']; echo ''.PHP_EOL; } echo "\t\t
{$this->lang['strftsdict']}"; echo "\t\t\t
'.PHP_EOL; echo '

'.PHP_EOL; echo ''.PHP_EOL; echo '

'.PHP_EOL; echo $this->misc->form; echo "lang['stralter']}\" />".PHP_EOL; echo "lang['strcancel']}\" />

".PHP_EOL; echo '
'.PHP_EOL; } else { echo "

{$this->lang['strftsnodictionaries']}

".PHP_EOL; } } /** * Save the form submission containing changes to a FTS mapping. */ public function doSaveAlterMapping() { $data = $this->misc->getDatabaseAccessor(); $mappingArray = (is_array($_POST['formMapping']) ? $_POST['formMapping'] : [$_POST['formMapping']]); $status = $data->changeFtsMapping($_POST['ftscfg'], $mappingArray, 'alter', $_POST['formDictionary']); if (0 == $status) { $this->doViewConfig($_POST['ftscfg'], $this->lang['strftsmappingaltered']); } else { $this->doAlterMapping($this->lang['strftsmappingalteredbad']); } } /** * Show the form to enter parameters of a new FTS mapping. * * @param mixed $msg */ public function doAddMapping($msg = '') { $data = $this->misc->getDatabaseAccessor(); $this->printTrail('ftscfg'); $this->printTitle($this->lang['stralter'], 'pg.ftscfg.alter'); $this->printMsg($msg); $ftsdicts = $data->getFtsDictionaries(); if ($ftsdicts->recordCount() > 0) { $this->coalesceArr($_POST, 'formMapping', ''); $this->coalesceArr($_POST, 'formDictionary', ''); $this->coalesceArr($_POST, 'ftscfg', $_REQUEST['ftscfg']); $mappings = $data->getFtsMappings($_POST['ftscfg']); echo '
'.PHP_EOL; echo ''.PHP_EOL; echo "\t".PHP_EOL; echo "\t\t".PHP_EOL; echo "\t\t".PHP_EOL; echo "\t".PHP_EOL; // Dictionary echo "\t".PHP_EOL; echo "\t\t".PHP_EOL; echo "\t\t".PHP_EOL; echo "\t".PHP_EOL; echo '
{$this->lang['strftsmapping']}"; echo "\t\t\t
{$this->lang['strftsdict']}"; echo "\t\t\t
'.PHP_EOL; echo '

'.PHP_EOL; echo ''.PHP_EOL; echo '

'.PHP_EOL; echo $this->misc->form; echo "lang['stradd']}\" />".PHP_EOL; echo "lang['strcancel']}\" />

".PHP_EOL; echo '
'.PHP_EOL; } else { echo "

{$this->lang['strftsnodictionaries']}

".PHP_EOL; } } /** * Save the form submission containing parameters of a new FTS mapping. */ public function doSaveAddMapping() { $data = $this->misc->getDatabaseAccessor(); $mappingArray = (is_array($_POST['formMapping']) ? $_POST['formMapping'] : [$_POST['formMapping']]); $status = $data->changeFtsMapping($_POST['ftscfg'], $mappingArray, 'add', $_POST['formDictionary']); if (0 == $status) { $this->doViewConfig($_POST['ftscfg'], $this->lang['strftsmappingadded']); } else { $this->doAddMapping($this->lang['strftsmappingaddedbad']); } } }