New help system.
authorjollytoad <jollytoad>
Tue, 7 Sep 2004 14:00:26 +0000 (14:00 +0000)
committerjollytoad <jollytoad>
Tue, 7 Sep 2004 14:00:26 +0000 (14:00 +0000)
classes/Misc.php
classes/database/Postgres.php
classes/database/Postgres71.php
classes/database/Postgres72.php
classes/database/Postgres73.php
classes/database/Postgres74.php
classes/database/Postgres80.php

index 2a13e5a766005af9e04d997e994b4d57b6c134bd..456188e86ff0abfbb5e5255d892cb1ad5af9df15 100644 (file)
@@ -2,7 +2,7 @@
        /**
         * Class to hold various commonly used functions
         *
-        * $Id: Misc.php,v 1.91 2004/09/03 08:24:35 jollytoad Exp $
+        * $Id: Misc.php,v 1.92 2004/09/07 14:00:26 jollytoad Exp $
         */
         
        class Misc {
                                                'databases' => array (
                                                        'title' => $lang['strdatabases'],
                                                        'url'   => "all_db.php",
-                                                       'help'  => 'managing_databases',
+                                                       'help'  => 'pg.database',
                                                ),
                                                'users' => array (
                                                        'title' => $lang['strusers'],
                                                        'url'   => "users.php",
                                                        'hide'  => $hide_users,
-                                                       'help'  => 'users',
+                                                       'help'  => 'pg.user',
                                                ),
                                                'groups' => array (
                                                        'title' => $lang['strgroups'],
                                                        'url'   => "groups.php",
                                                        'hide'  => $hide_users,
-                                                       'help'  => 'groups',
+                                                       'help'  => 'pg.group',
                                                ),
                                                'tablespaces' => array (
                                                        'title' => $lang['strtablespaces'],
                                                        'url'   => "tablespaces.php",
                                                        'hide'  => (!$data->hasTablespaces()),
+                                                       'help'  => 'pg.tablespace',
                                                ),
                                                'export' => array (
                                                        'title' => $lang['strexport'],
                                                        'title' => $lang['strschemas'],
                                                        'url'   => "database.php?{$vars}",
                                                        'hide'  => (!$data->hasSchemas()),
-                                                       'help'  => 'schemas',
+                                                       'help'  => 'pg.schema',
                                                ),
                                                'sql' => array (
                                                        'title' => $lang['strsql'],
                                                        'url'   => "database.php?{$vars}&action=sql",
-                                                       'help'  => 'sql',
+                                                       'help'  => 'pg.sql',
                                                ),
                                                'find' => array (
                                                        'title' => $lang['strfind'],
                                                        'title' => $lang['strvariables'],
                                                        'url'   => "database.php?{$vars}&action=variables",
                                                        'hide'  => (!$data->hasVariables()),
-                                                       'help'  => 'runtime_config',
+                                                       'help'  => 'pg.variable',
                                                ),
                                                'processes' => array (
                                                        'title' => $lang['strprocesses'],
                                                        'url'   => "database.php?{$vars}&action=processes",
                                                        'hide'  => (!$data->hasProcesses()),
-                                                       'help'  => 'processes',
+                                                       'help'  => 'pg.process',
                                                ),
                                                'admin' => array (
                                                        'title' => $lang['stradmin'],
                                                        'title' => $lang['strprivileges'],
                                                        'url'   => "privileges.php?{$vars}",
                                                        'hide'  => (!isset($data->privlist['database'])),
+                                                       'help'  => 'pg.privilege',
                                                ),
                                                'languages' => array (
                                                        'title' => $lang['strlanguages'],
                                                        'url'   => "languages.php?{$vars}",
                                                        'hide'  => $hide_advanced,
+                                                       'help'  => 'pg.language',
                                                ),
                                                'casts' => array (
                                                        'title' => $lang['strcasts'],
                                                        'url'   => "casts.php?{$vars}",
                                                        'hide'  => ($hide_advanced || !$data->hasCasts()),
+                                                       'help'  => 'pg.cast',
                                                ),
                                                'export' => array (
                                                        'title' => $lang['strexport'],
                                                'tables' => array (
                                                        'title' => $lang['strtables'],
                                                        'url'   => "tables.php?{$vars}",
-                                                       'help'  => 'tables',
+                                                       'help'  => 'pg.table',
                                                ),
                                                'views' => array (
                                                        'title' => $lang['strviews'],
                                                        'url'   => "views.php?{$vars}",
-                                                       'help'  => 'views',
+                                                       'help'  => 'pg.view',
                                                ),
                                                'sequences' => array (
                                                        'title' => $lang['strsequences'],
                                                        'url'   => "sequences.php?{$vars}",
-                                                       'help'  => 'sequences',
+                                                       'help'  => 'pg.sequence',
                                                ),
                                                'functions' => array (
                                                        'title' => $lang['strfunctions'],
                                                        'url'   => "functions.php?{$vars}",
+                                                       'help'  => 'pg.function',
                                                ),
                                                'domains' => array (
                                                        'title' => $lang['strdomains'],
                                                        'url'   => "domains.php?{$vars}",
                                                        'hide'  => (!$data->hasDomains()),
-                                                       'help'  => 'domains',
+                                                       'help'  => 'pg.domain',
                                                ),
                                                'aggregates' => array (
                                                        'title' => $lang['straggregates'],
                                                        'url'   => "aggregates.php?{$vars}",
                                                        'hide'  => $hide_advanced,
-                                                       'help'  => 'aggregates',
+                                                       'help'  => 'pg.aggregate',
                                                ),
                                                'types' => array (
                                                        'title' => $lang['strtypes'],
                                                        'url'   => "types.php?{$vars}",
                                                        'hide'  => $hide_advanced,
+                                                       'help'  => 'pg.type',
                                                ),
                                                'operators' => array (
                                                        'title' => $lang['stroperators'],
                                                        'url'   => "operators.php?{$vars}",
                                                        'hide'  => $hide_advanced,
-                                                       'help'  => 'operators',
+                                                       'help'  => 'pg.operator',
                                                ),
                                                'opclasses' => array (
                                                        'title' => $lang['stropclasses'],
                                                        'url'   => "opclasses.php?{$vars}",
                                                        'hide'  => $hide_advanced,
-                                                       'help'  => 'opclasses',
+                                                       'help'  => 'pg.opclass',
                                                ),
                                                'conversions' => array (
                                                        'title' => $lang['strconversions'],
                                                        'url'   => "conversions.php?{$vars}",
                                                        'hide'  => ($hide_advanced || !$data->hasConversions()),
-                                                       'help'  => 'conversions',
+                                                       'help'  => 'pg.conversion',
                                                ),
                                                'privileges' => array (
                                                        'title' => $lang['strprivileges'],
                                                        'url'   => "privileges.php?{$vars}",
                                                        'hide'  => (!$data->hasSchemas()),
+                                                       'help'  => 'pg.privilege',
                                                ),
                                        );
 
                                                'indexes' => array (
                                                        'title' => $lang['strindexes'],
                                                        'url'   => "indexes.php?{$vars}",
+                                                       'help'  => 'pg.index',
                                                ),
                                                'constraints' => array (
                                                        'title' => $lang['strconstraints'],
                                                        'url'   => "constraints.php?{$vars}",
-                                                       'help'  => 'constraints',
+                                                       'help'  => 'pg.constraint',
                                                ),
                                                'triggers' => array (
                                                        'title' => $lang['strtriggers'],
                                                        'url'   => "triggers.php?{$vars}",
+                                                       'help'  => 'pg.trigger',
                                                ),
                                                'rules' => array (
                                                        'title' => $lang['strrules'],
                                                        'url'   => "rules.php?{$vars}",
+                                                       'help'  => 'pg.rule',
                                                ),
                                                'info' => array (
                                                        'title' => $lang['strinfo'],
                                                'privileges' => array (
                                                        'title' => $lang['strprivileges'],
                                                        'url'   => "privileges.php?{$vars}",
+                                                       'help'  => 'pg.privilege',
                                                ),
                                                'import' => array (
                                                        'title' => $lang['strimport'],
                                                'rules' => array (
                                                        'title' => $lang['strrules'],
                                                        'url'   => "rules.php?{$vars}",
+                                                       'help'  => 'pg.rule',
                                                ),
                                                'privileges' => array (
                                                        'title' => $lang['strprivileges'],
                                                        'url'   => "privileges.php?{$vars}",
+                                                       'help'  => 'pg.privilege',
                                                ),
                                                'export' => array (
                                                        'title' => $lang['strexport'],
                                                'sql' => array (
                                                        'title' => $lang['strsql'],
                                                        'url'   => "sqledit.php?{$vars}&action=sql",
+                                                       'help'  => 'pg.sql',
                                                ),
                                                'find' => array (
                                                        'title' => $lang['strfind'],
                                'title' => $lang['strserver'],
                                'text'  => $conf['servers'][$_SESSION['webdbServerID']]['desc'],
                                'url'   => 'redirect.php?section=server',
+                               'help'  => 'pg.server',
                        );
                        if ($subject == 'server') $done = true;
                        
                                        'title' => $lang['strdatabase'],
                                        'text'  => $_REQUEST['database'],
                                        'url'   => "redirect.php?section=database&{$vars}",
+                                       'help'  => 'pg.database',
                                );
                        }
                        if ($subject == 'database') $done = true;
                                        'title' => $lang['strschema'],
                                        'text'  => $_REQUEST['schema'],
                                        'url'   => "redirect.php?section=schema&{$vars}",
-                                       'help'  => 'schemas',
+                                       'help'  => 'pg.schema',
                                );
                        }
                        if ($subject == 'schema') $done = true;
                                        'title' => $lang['strtable'],
                                        'text'  => $_REQUEST['table'],
                                        'url'   => "redirect.php?{$vars}",
-                                       'help'  => 'tables',
+                                       'help'  => 'pg.table',
                                );
                        } elseif (isset($_REQUEST['view']) && !$done) {
                                $vars .= "section=view&view=".urlencode($_REQUEST['view']);
                                        'title' => $lang['strview'],
                                        'text'  => $_REQUEST['view'],
                                        'url'   => "redirect.php?{$vars}",
-                                       'help'  => 'views',
+                                       'help'  => 'pg.view',
                                );
                        }
                        if ($subject == 'table' || $subject == 'view') $done = true;
                                                        'title' => $lang['str'.$subject],
                                                        'text'  => $_REQUEST[$subject],
                                                        'url'   => "redirect.php?{$vars}",
-                                                       'help'  => $subject.'s',
+                                                       'help'  => 'pg.'.$subject,
                                                );
                                                break;
                                        default:
 
                /**
                 * Displays link to the context help.
-                * @param $str   - a string to place a context help by (already escaped) 
-                * @param $help  - help section name
+                * @param $str   - the string that the context help is related to (already escaped) 
+                * @param $help  - help section identifier
                 */
                function printHelp($str, $help) {
                        global $lang, $data;
                        
                        echo $str;
-                       if (!is_null($help) && isset($data->help_page[$help])) {
+                       if ($help) {
                                echo "<a class=\"help\" href=\"";
-                               echo htmlspecialchars($data->help_base . $data->help_page[$help]);
+                               echo htmlspecialchars("help.php?help=".urlencode($help));
                                echo "\" title=\"{$lang['strhelp']}\" target=\"phppgadminhelp\">{$lang['strhelpicon']}</a>";
                        }
                }
index 47388c5de71aed606ed6d77058d2244f2c174fd5..fe99185dd5e93cfa155df6f9f99ac467cb584399 100755 (executable)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres.php,v 1.244 2004/08/25 07:47:34 chriskl Exp $
+ * $Id: Postgres.php,v 1.245 2004/09/07 14:04:21 jollytoad Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -142,37 +142,10 @@ class Postgres extends ADODB_base {
        var $joinOps = array('INNER JOIN' => 'INNER JOIN');
        
        // Default help URL
-       var $help_base = 'http://www.postgresql.org/docs/7/interactive/';
+       var $help_base;
 
        // Help sub pages
-       var $help_page = array(
-               'create_table' => 'sql-createtable.htm',
-               'drop_table' => 'sql-droptable.htm',
-               'insert' => 'sql-insert.htm',
-               'select' => 'sql-select.htm',
-               'tables' => 'ddl.htm#DDL-BASICS',
-               'schemas' => 'ddl-schemas.htm',
-               'create_schema' => 'sql-createschema.htm',
-               'alter_schema' => 'sql-alterschema.htm',
-               'drop_schema' => 'sql-dropschema.htm',
-               'runtime_config' => 'runtime-config.htm',
-               'processes' => 'monitoring-stats.htm#MONITORING-STATS-VIEWS-TABLE',
-               'sql' => 'sql-syntax.htm',
-               'views' => 'tutorial-views.htm',
-               'create_view' => 'sql-createview.htm',
-               'drop_view' => 'sql-dropview.htm',
-               'aggregates' => 'xaggr.htm',
-               'types' => 'xtypes.htm',
-               'create_type' => 'sql-createtype.htm',
-               'drop_type' => 'sql-droptype.htm',
-               'operators' => 'xoper.htm',
-               'managing_databases' => 'managing-databases.htm',
-               'users' => 'security17760.htm',
-               'groups' => 'security17760.htm',                
-               'create_database' => 'sql-createdatabase.htm',
-               'drop_database' => 'sql-dropdatabase.htm',
-               'constraints' => 'ddl-constraints.htm'
-       );
+       var $help_page;
        
        /**
         * Constructor
@@ -182,6 +155,35 @@ class Postgres extends ADODB_base {
                $this->ADODB_base($conn);
        }
 
+       // Help functions
+       
+       /**
+        * Fetch a URL (or array of URLs) for a given help page.
+        */
+       function getHelp($help) {
+               $this->getHelpPages();
+               
+               if (isset($this->help_page[$help])) {
+                       if (is_array($this->help_page[$help])) {
+                               $urls = array();
+                               foreach ($this->help_page[$help] as $link) {
+                                       $urls[] = $this->help_base . $link;
+                               }
+                               return $urls;
+                       } else
+                               return $this->help_base . $this->help_page[$help];
+               } else
+                       return null;
+       }
+
+       /**
+        * Initialize help pages and return the full list
+        */
+       function &getHelpPages() {
+               include_once('./help/PostgresDoc70.php');
+               return $this->help_page;
+       }
+       
        // Formatting functions
        
        /**
@@ -191,6 +193,7 @@ class Postgres extends ADODB_base {
         */
        function clean(&$str) {
                if ($str === null) return null;
+               $str = str_replace("\r\n","\n",$str);
                if (function_exists('pg_escape_string'))
                        $str = pg_escape_string($str);
                else
@@ -237,7 +240,7 @@ class Postgres extends ADODB_base {
                }
                return $arr;
        }
-
+       
        /**
         * Outputs the HTML code for a particular field
         * @param $name The name to give the field
index cd0611d08046a7e978369c7fa53b064d911fabed..016a7086b9b079a7aa8f5d6b060a339494f8a3ad 100644 (file)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres71.php,v 1.66 2004/08/03 16:16:02 soranzo Exp $
+ * $Id: Postgres71.php,v 1.67 2004/09/07 14:04:20 jollytoad Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -51,43 +51,6 @@ class Postgres71 extends Postgres {
        // Supported join operations for use with view wizard                                                           
        var $joinOps = array('INNER JOIN' => 'INNER JOIN', 'LEFT JOIN' => 'LEFT JOIN', 'RIGHT JOIN' => 'RIGHT JOIN', 'FULL JOIN' => 'FULL JOIN');
 
-       // Default help URL
-       var $help_base = 'http://www.postgresql.org/docs/7.1/interactive/';
-
-       // Help sub pages (alphabetical order)
-       var $help_page = array(
-               'add_column' => 'sql-altertable.html',
-               'alter_column' => 'sql-altertable.html',
-               'alter_table' => 'sql-altertable.html',
-               'create_table' => 'sql-createtable.html',
-               'drop_column' => 'sql-altertable.html',
-               'drop_table' => 'sql-droptable.html',
-               'insert' => 'sql-insert.html',
-               'select' => 'sql-select.html',
-               'tables' => 'ddl.html#DDL-BASICS',
-               'schemas' => 'ddl-schemas.html',
-               'create_schema' => 'sql-createschema.html',
-               'alter_schema' => 'sql-alterschema.html',
-               'drop_schema' => 'sql-dropschema.html',
-               'runtime_config' => 'runtime-config.html',
-               'processes' => 'monitoring-stats.html#MONITORING-STATS-VIEWS-TABLE',
-               'sql' => 'sql-syntax.html',
-               'views' => 'tutorial-views.html',
-               'create_view' => 'sql-createview.html',
-               'drop_view' => 'sql-dropview.html',
-               'aggregates' => 'xaggr.html',
-               'types' => 'xtypes.html',
-               'create_type' => 'sql-createtype.html',
-               'drop_type' => 'sql-droptype.html',
-               'operators' => 'xoper.html',
-               'managing_databases' => 'managing-databases.html',
-               'users' => 'user-manag.html#DATABASE-USERS',
-               'groups' => 'groups.html',
-               'create_database' => 'sql-createdatabase.html',
-               'drop_database' => 'sql-dropdatabase.html',
-               'constraints' => 'ddl-constraints.html'
-       );
-
        /**
         * Constructor
         * @param $conn The database connection
@@ -96,6 +59,13 @@ class Postgres71 extends Postgres {
                $this->Postgres($conn);
        }
 
+       // Help functions
+       
+       function &getHelpPages() {
+               include_once('./help/PostgresDoc71.php');
+               return $this->help_page;
+       }
+
        /**
         * Sets the client encoding
         * @param $encoding The encoding to for the client
index f77331a02f506ad2523f6b65200408492bd7799e..5f167549c65ec0ad5d0944f9543e831bfa9d1a17 100644 (file)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres72.php,v 1.75 2004/08/04 02:37:43 chriskl Exp $
+ * $Id: Postgres72.php,v 1.76 2004/09/07 14:04:20 jollytoad Exp $
  */
 
 
@@ -26,9 +26,6 @@ class Postgres72 extends Postgres71 {
        // Extra "magic" types.  BIGSERIAL was added in PostgreSQL 7.2.
        var $extraTypes = array('SERIAL', 'BIGSERIAL');
 
-       // Default help URL
-       var $help_base = 'http://www.postgresql.org/docs/7.2/interactive/';
-
        /**
         * Constructor
         * @param $conn The database connection
@@ -41,6 +38,13 @@ class Postgres72 extends Postgres71 {
                $this->codemap['LATIN5'] = 'ISO-8859-9';
        }
 
+       // Help functions
+       
+       function &getHelpPages() {
+               include_once('./help/PostgresDoc72.php');
+               return $this->help_page;
+       }
+
        /**
         * Returns all available process information.
         * @param $database (optional) Find only connections to specified database
index 5af53ccdc9be932e5b95815e9b75de06c29822e3..4663a4c4e21f53abd22b34402645cea8f0fcdfcd 100644 (file)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres73.php,v 1.135 2004/08/10 12:52:21 jollytoad Exp $
+ * $Id: Postgres73.php,v 1.136 2004/09/07 14:04:20 jollytoad Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -44,9 +44,6 @@ class Postgres73 extends Postgres72 {
                                                                        'SIMILAR TO' => 'i', 'NOT SIMILAR TO' => 'i', '~' => 'i', '!~' => 'i', '~*' => 'i', '!~*' => 'i', 'IS NULL' => 'p', 'IS NOT NULL' => 'p',
                                                                        'IN' => 'x', 'NOT IN' => 'x');
 
-       // Default help URL
-       var $help_base = 'http://www.postgresql.org/docs/7.3/interactive/';
-
        /**
         * Constructor
         * @param $conn The database connection
@@ -55,6 +52,13 @@ class Postgres73 extends Postgres72 {
                $this->Postgres72($conn);
        }
 
+       // Help functions
+       
+       function &getHelpPages() {
+               include_once('./help/PostgresDoc73.php');
+               return $this->help_page;
+       }
+
        // Schema functions
        
        /**
index 015d5cc83ee29cc72e763c870f23abb72c2fc2c1..9d9ac0b1df276fe239a4e64b32be62e01c8b239c 100644 (file)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres74.php,v 1.39 2004/08/10 12:52:22 jollytoad Exp $
+ * $Id: Postgres74.php,v 1.40 2004/09/07 14:04:21 jollytoad Exp $
  */
 
 include_once('./classes/database/Postgres73.php');
@@ -16,9 +16,6 @@ class Postgres74 extends Postgres73 {
 
        // Max object name length
        var $_maxNameLen = 63;
-
-       // Default help URL
-       var $help_base = 'http://www.postgresql.org/docs/7.4/interactive/';
        
        /**
         * Constructor
@@ -28,6 +25,13 @@ class Postgres74 extends Postgres73 {
                $this->Postgres73($conn);
        }
 
+       // Help functions
+       
+       function &getHelpPages() {
+               include_once('./help/PostgresDoc74.php');
+               return $this->help_page;
+       }
+
        // Table functions
        
        /**
@@ -482,7 +486,7 @@ class Postgres74 extends Postgres73 {
                
                return $this->endTransaction();
        }
-
+       
        // Capabilities
        function hasGrantOption() { return true; }
        function hasDomainConstraints() { return true; }
index 6387eccbb2942dab0f6be6d8ba4533cc133797a1..c91719032e2e9ac700674cf744dc5e6c7b150b0d 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * PostgreSQL 8.0 support
  *
- * $Id: Postgres80.php,v 1.3 2004/08/10 12:52:22 jollytoad Exp $
+ * $Id: Postgres80.php,v 1.4 2004/09/07 14:04:21 jollytoad Exp $
  */
 
 include_once('./classes/database/Postgres74.php');
@@ -26,9 +26,6 @@ class Postgres80 extends Postgres74 {
        // Last oid assigned to a system object
        var $_lastSystemOID = 17226;
 
-       // Default help URL
-       var $help_base = 'http://developer.postgresql.org/docs/postgres/';
-
        /**
         * Constructor
         * @param $conn The database connection
@@ -37,6 +34,13 @@ class Postgres80 extends Postgres74 {
                $this->Postgres74($conn);
        }
 
+       // Help functions
+       
+       function &getHelpPages() {
+               include_once('./help/PostgresDoc80.php');
+               return $this->help_page;
+       }
+
        // Database functions
 
        /**