diff options
author | ioguix | 2008-03-17 21:35:48 +0000 |
---|---|---|
committer | ioguix | 2008-03-17 21:35:48 +0000 |
commit | f42e84683d0fe2b4077bdbef31aa6ab4c139895a (patch) | |
tree | 845088665aeb146fc11fcaa9514dc395e5232533 | |
parent | 38b6ee8a8d8ec73d905f41740e2523b5f502adce (diff) |
FTS fix and links to help pages from Ivan Zolotukhin
-rw-r--r-- | classes/Misc.php | 12 | ||||
-rw-r--r-- | classes/database/Postgres83.php | 34 | ||||
-rw-r--r-- | fulltext.php | 74 | ||||
-rw-r--r-- | help/PostgresDoc83.php | 16 |
4 files changed, 72 insertions, 64 deletions
diff --git a/classes/Misc.php b/classes/Misc.php index b6eebf31..6986345c 100644 --- a/classes/Misc.php +++ b/classes/Misc.php @@ -2,7 +2,7 @@ /** * Class to hold various commonly used functions * - * $Id: Misc.php,v 1.170 2008/02/18 22:20:26 ioguix Exp $ + * $Id: Misc.php,v 1.171 2008/03/17 21:35:48 ioguix Exp $ */ class Misc { @@ -654,7 +654,7 @@ 'title' => $lang['strfulltext'], 'url' => 'fulltext.php', 'urlvars' => array('subject' => 'database'), - 'help' => 'PUT_DOC_LINK_HERE', + 'help' => 'pg.fts', 'tree' => true, 'icon' => 'Fts', ), @@ -1021,7 +1021,7 @@ 'url' => 'fulltext.php', 'urlvars' => array('subject' => 'database'), 'hide' => !$data->hasFTS(), - 'help' => 'PUT_DOC_LINK_HERE', + 'help' => 'pg.ftscfg', 'tree' => true, 'icon' => 'FtsCfg', ), @@ -1030,7 +1030,7 @@ 'url' => 'fulltext.php', 'urlvars' => array('subject' => 'database', 'action' => 'viewdicts'), 'hide' => !$data->hasFTS(), - 'help' => 'PUT_DOC_LINK_HERE', + 'help' => 'pg.ftsdict', 'tree' => true, 'icon' => 'FtsDict', ), @@ -1039,7 +1039,7 @@ 'url' => 'fulltext.php', 'urlvars' => array('subject' => 'database', 'action' => 'viewparsers'), 'hide' => !$data->hasFTS(), - 'help' => 'PUT_DOC_LINK_HERE', + 'help' => 'pg.ftsparser', 'tree' => true, 'icon' => 'FtsParser', ), @@ -1296,7 +1296,7 @@ 'title' => $lang['strftsconfig'], 'text' => $_REQUEST['ftscfg'], 'url' => "fulltext.php?{$vars}", - 'help' => 'PUT_DOC_LINK_HERE', + 'help' => 'pg.ftscfg.example', 'icon' => 'Fts' ); } diff --git a/classes/database/Postgres83.php b/classes/database/Postgres83.php index 8d96e65e..14a6f8d9 100644 --- a/classes/database/Postgres83.php +++ b/classes/database/Postgres83.php @@ -3,7 +3,7 @@ /** * PostgreSQL 8.3 support * - * $Id: Postgres83.php,v 1.17 2007/12/28 17:43:26 ioguix Exp $ + * $Id: Postgres83.php,v 1.18 2008/03/17 21:35:48 ioguix Exp $ */ include_once('./classes/database/Postgres82.php'); @@ -159,18 +159,21 @@ class Postgres83 extends Postgres82 { * @param string $comment If omitted, defaults to nothing * @return 0 success */ - function createFtsConfiguration($cfgname, $parser = '', $template = '', $withMap = '', $comment = '') { + function createFtsConfiguration($cfgname, $parser = '', $template = '', $comment = '') { $this->fieldClean($cfgname); - $this->fieldClean($template); - $this->fieldClean($parser); - $this->clean($comment); - $sql = "CREATE TEXT SEARCH CONFIGURATION \"{$cfgname}\""; - if ($parser != '') $sql .= " PARSER \"{$parser}\""; + $sql = "CREATE TEXT SEARCH CONFIGURATION \"{$cfgname}\" ("; + if ($parser != '') { + $this->fieldClean($parser['schema']); + $this->fieldClean($parser['parser']); + $parser = "\"{$parser['schema']}\".\"{$parser['parser']}\""; + $sql .= " PARSER = {$parser}"; + } if ($template != '') { - $sql .= " LIKE \"{$template}\""; - if ($withMap != '') $sql .= " WITH MAP"; + $this->fieldClean($template); + $sql .= " COPY = \"{$template}\""; } + $sql .= ")"; if ($comment != '') { $status = $this->beginTransaction(); @@ -186,6 +189,7 @@ class Postgres83 extends Postgres82 { // Set the comment if ($comment != '') { + $this->clean($comment); $status = $this->setComment('TEXT SEARCH CONFIGURATION', $cfgname, '', $comment); if ($status != 0) { $this->rollbackTransaction(); @@ -345,7 +349,7 @@ class Postgres83 extends Postgres82 { /** * Alters FTS configuration */ - function updateFtsConfiguration($cfgname, $comment, $name, $prsname = null) { + function updateFtsConfiguration($cfgname, $comment, $name) { $this->fieldClean($cfgname); $this->fieldClean($name); $this->clean($comment); @@ -372,16 +376,6 @@ class Postgres83 extends Postgres82 { } } - // Only if parser is defined - if ($prsname) { - $sql = "ALTER TEXT SEARCH CONFIGURATION \"{$cfgname}\" SET PARSER \"{$prsname}\""; - $status = $this->execute($sql); - if ($status != 0) { - $this->rollbackTransaction(); - return -1; - } - } - return $this->endTransaction(); } diff --git a/fulltext.php b/fulltext.php index 96958f26..fff741b0 100644 --- a/fulltext.php +++ b/fulltext.php @@ -3,7 +3,7 @@ /** * Manage fulltext configurations, dictionaries and mappings * - * $Id: fulltext.php,v 1.5 2007/11/30 15:17:22 soranzo Exp $ + * $Id: fulltext.php,v 1.6 2008/03/17 21:35:48 ioguix Exp $ */ // Include application functions @@ -70,7 +70,7 @@ if ($confirm) { $misc->printTrail('ftscfg'); - $misc->printTitle($lang['strdrop'],'PUT_DOC_LINK_HERE'); + $misc->printTitle($lang['strdrop'], 'pg.ftscfg.drop'); echo "<p>", sprintf($lang['strconfdropftsconfig'], $misc->printVal($_REQUEST['ftscfg'])), "</p>\n"; @@ -105,7 +105,7 @@ if ($confirm) { $misc->printTrail('ftscfg'); // TODO: change to smth related to dictionary - $misc->printTitle($lang['strdrop'],'PUT_DOC_LINK_HERE'); + $misc->printTitle($lang['strdrop'], 'pg.ftsdict.drop'); echo "<p>", sprintf($lang['strconfdropftsdict'], $misc->printVal($_REQUEST['ftsdict'])), "</p>\n"; @@ -118,7 +118,7 @@ echo "<input type=\"hidden\" name=\"database\" value=\"", htmlspecialchars($_REQUEST['database']), "\" />\n"; echo "<input type=\"hidden\" name=\"ftsdict\" value=\"", htmlspecialchars($_REQUEST['ftsdict']), "\" />\n"; echo "<input type=\"hidden\" name=\"ftscfg\" value=\"", htmlspecialchars($_REQUEST['ftscfg']), "\" />\n"; - echo "<input type=\"hidden\" name=\"prev_action\" value=\"viewconfig\" /></p>\n"; + echo "<input type=\"hidden\" name=\"prev_action\" value=\"viewdicts\" /></p>\n"; echo $misc->form; echo "<input type=\"submit\" name=\"drop\" value=\"{$lang['strdrop']}\" />\n"; echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" /></p>\n"; @@ -143,6 +143,8 @@ global $data, $misc; global $lang; + include_once('./classes/Gui.php'); + $server_info = $misc->getServerInfo(); if (!isset($_POST['formName'])) $_POST['formName'] = ''; @@ -157,7 +159,7 @@ $ftsparsers = $data->getFtsParsers(); $misc->printTrail('schema'); - $misc->printTitle($lang['strftscreateconfig'],'PUT_DOC_LINK_HERE'); + $misc->printTitle($lang['strftscreateconfig'], 'pg.ftscfg.create'); $misc->printMsg($msg); echo "<form action=\"fulltext.php\" method=\"post\">\n"; @@ -168,7 +170,7 @@ // Template echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['strftstemplate']}</th>\n"; - echo "\t\t<td class=\"data1\">\n\t\t\t<select name=\"formTemplate\" onchange=\"document.getElementsByName('formWithMap')[0].disabled = !this.value;if(!this.value)document.getElementsByName('formWithMap')[0].checked = false;\">\n"; + echo "\t\t<td class=\"data1\">\n\t\t\t<select name=\"formTemplate\">\n"; echo "\t\t\t\t<option value=\"\"></option>\n"; while (!$ftscfgs->EOF) { $ftscfg = htmlspecialchars($ftscfgs->fields['name']); @@ -176,22 +178,26 @@ ($ftscfg == $_POST['formTemplate']) ? ' selected="selected"' : '', ">{$ftscfg}</option>\n"; $ftscfgs->moveNext(); } - echo "\t\t\t</select>\n"; - echo "\t\t<input type=\"checkbox\" disabled=\"disabled\" id=\"withmap\" name=\"formWithMap\"", - $_POST['formWithMap'] ? ' checked="checked"' : '', - " /> <label for=\"withmap\">{$lang['strftswithmap']}</label></td>\n\t</tr>\n"; + echo "\t\t\t</select>\n\t\t</td>\n\t</tr>\n"; // Parser echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['strftsparser']}</th>\n"; - echo "\t\t<td class=\"data1\">\n\t\t\t<select name=\"formParser\">\n"; - echo "\t\t\t\t<option value=\"\"></option>\n"; - while (!$ftsparsers->EOF) { - $ftsparser = htmlspecialchars($ftsparsers->fields['schema'] . "." . $ftsparsers->fields['name']); - echo "\t\t\t\t<option value=\"{$ftsparser}\"", - ($ftsparser == $_POST['formParser']) ? ' selected="selected"' : '', ">{$ftsparser}</option>\n"; - $ftsparsers->moveNext(); + echo "\t\t<td class=\"data1\">\n"; + $ftsparsers_ = array(); + $ftsparsel = ''; + if (!$ftsparsers->EOF) { + $ftsparsers = $ftsparsers->getArray(); + foreach ($ftsparsers as $a) { + $data->fieldClean($a['schema']); + $data->fieldClean($a['name']); + $ftsparsers_["\"{$a['schema']}\".\"{$a['name']}\""] = serialize(array('schema' => $a['schema'], 'parser' => $a['name'])); + if ($_POST['formParser'] == $ftsparsers_["\"{$a['schema']}\".\"{$a['name']}\""]) { + $ftsparsel = htmlspecialchars($ftsparsers_["\"{$a['schema']}\".\"{$a['name']}\""]); + } + } } - echo "\t\t\t</select>\n\t\t</td>\n\t</tr>\n"; + echo GUI::printCombo($ftsparsers_, 'formParser', true, $ftsparsel, false); + echo "\n\t\t</td>\n\t</tr>\n"; // Comment echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['strcomment']}</th>\n"; @@ -217,9 +223,11 @@ // Check that they've given a name if ($_POST['formName'] == '') doCreateConfig($lang['strftsconfigneedsname']); + if (($_POST['formParser'] != '') && ($_POST['formTemplate'] != '')) doCreateConfig($lang['strftscantparsercopy']); else { - $heh = ""; - $status = $data->createFtsConfiguration($_POST['formName'], $_POST['formParser'], $_POST['formTemplate'], $_POST['formWithMap'], $_POST['formComment']); + if ($_POST['formParser'] != '') $_POST['formParser'] = unserialize($_POST['formParser']); + + $status = $data->createFtsConfiguration($_POST['formName'], $_POST['formParser'], $_POST['formTemplate'], $_POST['formComment']); if ($status == 0) { $_reload_browser = true; doDefault($lang['strftsconfigcreated']); @@ -236,7 +244,7 @@ global $data, $misc, $lang; $misc->printTrail('ftscfg'); - $misc->printTitle($lang['stralter'],'PUT_DOC_LINK_HERE'); + $misc->printTitle($lang['stralter'], 'pg.ftscfg.alter'); $misc->printMsg($msg); $ftscfg = $data->getFtsConfigurationByName($_REQUEST['ftscfg']); @@ -260,17 +268,6 @@ echo "\t\t</td>\n"; echo "\t</tr>\n"; - // Parser - echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['strftsparser']}</th>\n"; - echo "\t\t<td class=\"data1\">\n\t\t\t<select name=\"formParser\">\n"; - while (!$ftsparsers->EOF) { - $ftsparser = htmlspecialchars($ftsparsers->fields['schema'] . "." . $ftsparsers->fields['name']); - echo "\t\t\t\t<option value=\"{$ftsparser}\"", - ($ftsparser == $_POST['formParser'] || $ftsparser == $ftscfg->fields['parser']) ? ' selected="selected"' : '', ">{$ftsparser}</option>\n"; - $ftsparsers->moveNext(); - } - echo "\t\t\t</select>\n\t\t</td>\n\t</tr>\n"; - // Comment echo "\t<tr>\n"; echo "\t\t<th class=\"data\">{$lang['strcomment']}</th>\n"; @@ -478,7 +475,7 @@ $misc->printTrail('schema'); // TODO: create doc links - $misc->printTitle($lang['strftscreatedict'], 'PUT_DOC_LINK_HERE'); + $misc->printTitle($lang['strftscreatedict'], 'pg.ftsdict.create'); $misc->printMsg($msg); echo "<form action=\"fulltext.php\" method=\"post\">\n"; @@ -561,7 +558,7 @@ global $data, $misc, $lang; $misc->printTrail('ftscfg'); // TODO: change to smth related to dictionary - $misc->printTitle($lang['stralter'],'PUT_DOC_LINK_HERE'); + $misc->printTitle($lang['stralter'], 'pg.ftsdict.alter'); $misc->printMsg($msg); $ftsdict = $data->getFtsDictionaryByName($_REQUEST['ftsdict']); @@ -631,7 +628,7 @@ if ($confirm) { $misc->printTrail('ftscfg'); // TODO: proper breadcrumbs - $misc->printTitle($lang['strdrop'], 'PUT_DOC_LINK_HERE'); + $misc->printTitle($lang['strdrop'], 'pg.ftscfg.alter'); echo "<form action=\"fulltext.php\" method=\"post\">\n"; @@ -651,6 +648,7 @@ echo "<input type=\"hidden\" name=\"ftscfg\" value=\"{$_REQUEST['ftscfg']}\" />\n"; echo "<input type=\"hidden\" name=\"action\" value=\"dropmapping\" />\n"; + echo "<input type=\"hidden\" name=\"prev_action\" value=\"viewconfig\" /></p>\n"; echo $misc->form; echo "<input type=\"submit\" name=\"drop\" value=\"{$lang['strdrop']}\" />\n"; echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n"; @@ -679,7 +677,7 @@ global $data, $misc, $lang; $misc->printTrail('ftscfg'); - $misc->printTitle($lang['stralter'],'PUT_DOC_LINK_HERE'); + $misc->printTitle($lang['stralter'], 'pg.ftscfg.alter'); $misc->printMsg($msg); $ftsdicts = $data->getFtsDictionaries(); @@ -734,6 +732,8 @@ echo "</table>\n"; echo "<p><input type=\"hidden\" name=\"action\" value=\"altermapping\" />\n"; echo "<input type=\"hidden\" name=\"ftscfg\" value=\"", htmlspecialchars($_POST['ftscfg']), "\" />\n"; + echo "<input type=\"hidden\" name=\"prev_action\" value=\"viewconfig\" /></p>\n"; + echo $misc->form; echo "<input type=\"submit\" name=\"alter\" value=\"{$lang['stralter']}\" />\n"; echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" /></p>\n"; @@ -764,7 +764,7 @@ global $data, $misc, $lang; $misc->printTrail('ftscfg'); - $misc->printTitle($lang['stralter'],'PUT_DOC_LINK_HERE'); + $misc->printTitle($lang['stralter'], 'pg.ftscfg.alter'); $misc->printMsg($msg); $ftsdicts = $data->getFtsDictionaries(); diff --git a/help/PostgresDoc83.php b/help/PostgresDoc83.php index 35758a6c..3684ad28 100644 --- a/help/PostgresDoc83.php +++ b/help/PostgresDoc83.php @@ -3,11 +3,25 @@ /** * Help links for PostgreSQL 8.3 documentation * - * $Id: PostgresDoc83.php,v 1.2 2007/11/30 15:27:26 soranzo Exp $ + * $Id: PostgresDoc83.php,v 1.3 2008/03/17 21:35:48 ioguix Exp $ */ include('./help/PostgresDoc82.php'); $this->help_base = sprintf($GLOBALS['conf']['help_base'], '8.3'); +$this->help_page['pg.fts'] = 'textsearch.html'; + +$this->help_page['pg.ftscfg'] = 'textsearch-intro.html#TEXTSEARCH-INTRO-CONFIGURATIONS'; +$this->help_page['pg.ftscfg.example'] = 'textsearch-configuration.html'; +$this->help_page['pg.ftscfg.drop'] = 'sql-droptsconfig.html'; +$this->help_page['pg.ftscfg.create'] = 'sql-createtsconfig.html'; +$this->help_page['pg.ftscfg.alter'] = 'sql-altertsconfig.html'; + +$this->help_page['pg.ftsdict'] = 'textsearch-dictionaries.html'; +$this->help_page['pg.ftsdict.drop'] = 'sql-droptsdictionary.html'; +$this->help_page['pg.ftsdict.create'] = array('sql-createtsdictionary.html', 'sql-createtstemplate.html'); +$this->help_page['pg.ftsdict.alter'] = 'sql-altertsdictionary.html'; + +$this->help_page['pg.ftsparser'] = 'textsearch-parsers.html'; ?> |