printTrail('schema'); $misc->printTabs('schema','fulltext'); $misc->printTabs('fulltext','ftsconfigs'); $misc->printMsg($msg); $cfgs = $data->getFtsConfigurations(false); $columns = array( 'configuration' => array( 'title' => $lang['strftsconfig'], 'field' => field('name'), 'url' => "fulltext.php?action=viewconfig&{$misc->href}&", 'vars' => array('ftscfg' => 'name'), ), 'schema' => array( 'title' => $lang['strschema'], 'field' => field('schema'), ), 'actions' => array( 'title' => $lang['stractions'], ), 'comment' => array( 'title' => $lang['strcomment'], 'field' => field('comment'), ), ); $actions = array( 'drop' => array( 'content' => $lang['strdrop'], 'attr'=> array ( 'href' => array ( 'url' => 'fulltext.php', 'urlvars' => array ( 'action' => 'dropconfig', 'ftscfg' => field('name') ) ) ) ), 'alter' => array( 'content' => $lang['stralter'], 'attr'=> array ( 'href' => array ( 'url' => 'fulltext.php', 'urlvars' => array ( 'action' => 'alterconfig', 'ftscfg' => field('name') ) ) ) ), ); $misc->printTable($cfgs, $columns, $actions, 'fulltext-fulltext', $lang['strftsnoconfigs']); $navlinks = array( 'createconf' => array ( 'attr'=> array ( 'href' => array ( 'url' => 'fulltext.php', 'urlvars' => array ( 'action' => 'createconfig', 'server' => $_REQUEST['server'], 'database' => $_REQUEST['database'], 'schema' => $_REQUEST['schema'] ) ) ), 'content' => $lang['strftscreateconfig'] ) ); $misc->printNavLinks($navlinks, 'fulltext-fulltext', get_defined_vars()); } function doDropConfig($confirm) { global $data, $data, $misc; global $lang, $_reload_browser; if ($confirm) { $misc->printTrail('ftscfg'); $misc->printTitle($lang['strdrop'], 'pg.ftscfg.drop'); echo "
", sprintf($lang['strconfdropftsconfig'], $misc->printVal($_REQUEST['ftscfg'])), "
\n"; echo "\n"; } else { $status = $data->dropFtsConfiguration($_POST['ftscfg'], isset($_POST['cascade'])); if ($status == 0) { $_reload_browser = true; doDefault($lang['strftsconfigdropped']); } else doDefault($lang['strftsconfigdroppedbad']); } } function doDropDict($confirm) { global $data, $data, $misc; global $lang, $_reload_browser; if ($confirm) { $misc->printTrail('ftscfg'); // TODO: change to smth related to dictionary $misc->printTitle($lang['strdrop'], 'pg.ftsdict.drop'); echo "", sprintf($lang['strconfdropftsdict'], $misc->printVal($_REQUEST['ftsdict'])), "
\n"; echo "\n"; } else { $status = $data->dropFtsDictionary($_POST['ftsdict'], isset($_POST['cascade'])); if ($status == 0) { $_reload_browser = true; doViewDicts($lang['strftsdictdropped']); } else doViewDicts($lang['strftsdictdroppedbad']); } } /** * Displays a screen where one can enter a new FTS configuration */ function doCreateConfig($msg = '') { global $data, $misc; global $lang; include_once('./classes/Gui.php'); $server_info = $misc->getServerInfo(); if (!isset($_POST['formName'])) $_POST['formName'] = ''; if (!isset($_POST['formParser'])) $_POST['formParser'] = ''; if (!isset($_POST['formTemplate'])) $_POST['formTemplate'] = ''; if (!isset($_POST['formWithMap'])) $_POST['formWithMap'] = ''; if (!isset($_POST['formComment'])) $_POST['formComment'] = ''; // Fetch all FTS configurations from the database $ftscfgs = $data->getFtsConfigurations(); // Fetch all FTS parsers from the database $ftsparsers = $data->getFtsParsers(); $misc->printTrail('schema'); $misc->printTitle($lang['strftscreateconfig'], 'pg.ftscfg.create'); $misc->printMsg($msg); echo "\n"; } /** * Actually creates the new FTS configuration in the database */ function doSaveCreateConfig() { global $data, $lang, $_reload_browser; $err = ''; // Check that they've given a name if ($_POST['formName'] == '') $err .= "{$lang['strftsconfigneedsname']}{$lang['strnodata']}
\n"; } } /** * Save the form submission containing changes to a FTS configuration */ function doSaveAlterConfig() { global $data, $misc, $lang; $status = $data->updateFtsConfiguration($_POST['ftscfg'], $_POST['formComment'], $_POST['formName']); if ($status == 0) doDefault($lang['strftsconfigaltered']); else doAlterConfig($lang['strftsconfigalteredbad']); } /** * View list of FTS parsers */ function doViewParsers($msg = '') { global $data, $misc; global $lang; $misc->printTrail('schema'); $misc->printTabs('schema','fulltext'); $misc->printTabs('fulltext','ftsparsers'); $misc->printMsg($msg); $parsers = $data->getFtsParsers(false); $columns = array( 'schema' => array( 'title' => $lang['strschema'], 'field' => field('schema'), ), 'name' => array( 'title' => $lang['strname'], 'field' => field('name'), ), 'comment' => array( 'title' => $lang['strcomment'], 'field' => field('comment'), ), ); $actions = array(); $misc->printTable($parsers, $columns, $actions, 'fulltext-viewparsers', $lang['strftsnoparsers']); //TODO: navlink to "create parser" } /** * View list of FTS dictionaries */ function doViewDicts($msg = '') { global $data, $misc; global $lang; $misc->printTrail('schema'); $misc->printTabs('schema','fulltext'); $misc->printTabs('fulltext','ftsdicts'); $misc->printMsg($msg); $dicts = $data->getFtsDictionaries(false); $columns = array( 'schema' => array( 'title' => $lang['strschema'], 'field' => field('schema'), ), 'name' => array( 'title' => $lang['strname'], 'field' => field('name'), ), 'actions' => array( 'title' => $lang['stractions'], ), 'comment' => array( 'title' => $lang['strcomment'], 'field' => field('comment'), ), ); $actions = array( 'drop' => array( 'content' => $lang['strdrop'], 'attr'=> array ( 'href' => array ( 'url' => 'fulltext.php', 'urlvars' => array ( 'action' => 'dropdict', 'ftsdict' => field('name') ) ) ) ), 'alter' => array( 'content' => $lang['stralter'], 'attr'=> array ( 'href' => array ( 'url' => 'fulltext.php', 'urlvars' => array ( 'action' => 'alterdict', 'ftsdict' => field('name') ) ) ) ), ); $misc->printTable($dicts, $columns, $actions, 'fulltext-viewdicts', $lang['strftsnodicts']); $navlinks = array( 'createdict' => array ( 'attr'=> array ( 'href' => array ( 'url' => 'fulltext.php', 'urlvars' => array ( 'action' => 'createdict', 'server' => $_REQUEST['server'], 'database' => $_REQUEST['database'], 'schema' => $_REQUEST['schema'], ) ) ), 'content' => $lang['strftscreatedict'] ) ); $misc->printNavLinks($navlinks, 'fulltext-viewdicts', get_defined_vars()); } /** * View details of FTS configuration given */ function doViewConfig($ftscfg, $msg = '') { global $data, $misc; global $lang; $misc->printTrail('ftscfg'); $misc->printTabs('schema','fulltext'); $misc->printTabs('fulltext','ftsconfigs'); $misc->printMsg($msg); echo "{$lang['strnodata']}
\n"; } } /** * Save the form submission containing changes to a FTS dictionary */ function doSaveAlterDict() { global $data, $misc, $lang; $status = $data->updateFtsDictionary($_POST['ftsdict'], $_POST['formComment'], $_POST['formName']); if ($status == 0) doViewDicts($lang['strftsdictaltered']); else doAlterDict($lang['strftsdictalteredbad']); } /** * Show confirmation of drop and perform actual drop of FTS mapping */ function doDropMapping($confirm) { global $data, $misc; global $lang, $_reload_drop_database; if (empty($_REQUEST['mapping']) && empty($_REQUEST['ma'])) { doDefault($lang['strftsspecifymappingtodrop']); return; } if (empty($_REQUEST['ftscfg'])) { doDefault($lang['strftsspecifyconfigtoalter']); return; } if ($confirm) { $misc->printTrail('ftscfg'); // TODO: proper breadcrumbs $misc->printTitle($lang['strdrop'], 'pg.ftscfg.alter'); echo "\n"; } else { // Case of multiaction drop if (is_array($_REQUEST['mapping'])) { $status = $data->changeFtsMapping($_REQUEST['ftscfg'], $_REQUEST['mapping'], 'drop'); if ($status != 0) { doViewConfig($_REQUEST['ftscfg'], $lang['strftsmappingdroppedbad']); return; } doViewConfig($_REQUEST['ftscfg'], $lang['strftsmappingdropped']); } else { $status = $data->changeFtsMapping($_REQUEST['ftscfg'], array($_REQUEST['mapping']), 'drop'); if ($status == 0) { doViewConfig($_REQUEST['ftscfg'], $lang['strftsmappingdropped']); } else { doViewConfig($_REQUEST['ftscfg'], $lang['strftsmappingdroppedbad']); } } } } function doAlterMapping($msg = '') { global $data, $misc, $lang; $misc->printTrail('ftscfg'); $misc->printTitle($lang['stralter'], 'pg.ftscfg.alter'); $misc->printMsg($msg); $ftsdicts = $data->getFtsDictionaries(); if ($ftsdicts->recordCount() > 0) { if (!isset($_POST['formMapping'])) $_POST['formMapping'] = @$_REQUEST['mapping']; if (!isset($_POST['formDictionary'])) $_POST['formDictionary'] = ''; if (!isset($_POST['ftscfg'])) $_POST['ftscfg'] = $_REQUEST['ftscfg']; echo "\n"; } else { echo "{$lang['strftsnodictionaries']}
\n"; } } /** * Save the form submission containing changes to a FTS mapping */ function doSaveAlterMapping() { global $data, $misc, $lang; $mappingArray = (is_array($_POST['formMapping']) ? $_POST['formMapping'] : array($_POST['formMapping'])); $status = $data->changeFtsMapping($_POST['ftscfg'], $mappingArray, 'alter', $_POST['formDictionary']); if ($status == 0) doViewConfig($_POST['ftscfg'], $lang['strftsmappingaltered']); else doAlterMapping($lang['strftsmappingalteredbad']); } /** * Show the form to enter parameters of a new FTS mapping */ function doAddMapping($msg = '') { global $data, $misc, $lang; $misc->printTrail('ftscfg'); $misc->printTitle($lang['stralter'], 'pg.ftscfg.alter'); $misc->printMsg($msg); $ftsdicts = $data->getFtsDictionaries(); if ($ftsdicts->recordCount() > 0) { if (!isset($_POST['formMapping'])) $_POST['formMapping'] = ''; if (!isset($_POST['formDictionary'])) $_POST['formDictionary'] = ''; if (!isset($_POST['ftscfg'])) $_POST['ftscfg'] = $_REQUEST['ftscfg']; $mappings = $data->getFtsMappings($_POST['ftscfg']); echo "\n"; } else { echo "{$lang['strftsnodictionaries']}
\n"; } } /** * Save the form submission containing parameters of a new FTS mapping */ function doSaveAddMapping() { global $data, $misc, $lang; $mappingArray = (is_array($_POST['formMapping']) ? $_POST['formMapping'] : array($_POST['formMapping'])); $status = $data->changeFtsMapping($_POST['ftscfg'], $mappingArray, 'add', $_POST['formDictionary']); if ($status == 0) doViewConfig($_POST['ftscfg'], $lang['strftsmappingadded']); else doAddMapping($lang['strftsmappingaddedbad']); } /** * Generate XML for the browser tree. */ function doTree() { global $misc, $data, $lang; $tabs = $misc->getNavTabs('fulltext'); $items = $misc->adjustTabsForTree($tabs); $reqvars = $misc->getRequestVars('ftscfg'); $attrs = array( 'text' => field('title'), 'icon' => field('icon'), 'action' => url('fulltext.php', $reqvars, field('urlvars') ), 'branch' => url('fulltext.php', $reqvars, array( 'action' => 'subtree', 'what' => field('icon') // IZ: yeah, it's ugly, but I do not want to change navigation tabs arrays ) ), ); $misc->printTree($items, $attrs, 'fts'); exit; } function doSubTree($what) { global $misc, $data, $lang; switch($what) { case 'FtsCfg': $items = $data->getFtsConfigurations(false); $urlvars = array('action' => 'viewconfig', 'ftscfg' => field('name')); break; case 'FtsDict': $items = $data->getFtsDictionaries(false); $urlvars = array('action' => 'viewdicts'); break; case 'FtsParser': $items = $data->getFtsParsers(false); $urlvars = array('action' => 'viewparsers'); break; default: exit; } $reqvars = $misc->getRequestVars('ftscfg'); $attrs = array( 'text' => field('name'), 'icon' => $what, 'toolTip'=> field('comment'), 'action' => url('fulltext.php', $reqvars, $urlvars ), 'branch' => ifempty(field('branch'), '', url('fulltext.php', $reqvars, array( 'action' => 'subtree', 'ftscfg' => field('name') ) ) ), ); $misc->printTree($items, $attrs, strtolower($what)); exit; } if ($action == 'tree') doTree(); if ($action == 'subtree') doSubTree($_REQUEST['what']); $misc->printHeader($lang['strschemas']); $misc->printBody(); if (isset($_POST['cancel'])) { if (isset($_POST['prev_action'])) { $action = $_POST['prev_action']; } else { $action = ''; } } switch ($action) { case 'createconfig': if (isset($_POST['create'])) doSaveCreateConfig(); else doCreateConfig(); break; case 'alterconfig': if (isset($_POST['alter'])) doSaveAlterConfig(); else doAlterConfig(); break; case 'dropconfig': if (isset($_POST['drop'])) doDropConfig(false); else doDropConfig(true); break; case 'viewconfig': doViewConfig($_REQUEST['ftscfg']); break; case 'viewparsers': doViewParsers(); break; case 'viewdicts': doViewDicts(); break; case 'createdict': if (isset($_POST['create'])) doSaveCreateDict(); else doCreateDict(); break; case 'alterdict': if (isset($_POST['alter'])) doSaveAlterDict(); else doAlterDict(); break; case 'dropdict': if (isset($_POST['drop'])) doDropDict(false); else doDropDict(true); break; case 'dropmapping': if (isset($_POST['drop'])) doDropMapping(false); else doDropMapping(true); break; case 'altermapping': if (isset($_POST['alter'])) doSaveAlterMapping(); else doAlterMapping(); break; case 'addmapping': if (isset($_POST['add'])) doSaveAddMapping(); else doAddMapping(); break; default: doDefault(); break; } $misc->printFooter(); ?>