Import of help management page (performs redirection and allows URL choices).
authorjollytoad <jollytoad>
Tue, 7 Sep 2004 13:57:26 +0000 (13:57 +0000)
committerjollytoad <jollytoad>
Tue, 7 Sep 2004 13:57:26 +0000 (13:57 +0000)
help.php [new file with mode: 0644]

diff --git a/help.php b/help.php
new file mode 100644 (file)
index 0000000..3b8d292
--- /dev/null
+++ b/help.php
@@ -0,0 +1,90 @@
+<?php
+
+       /**
+        * Help page redirection/browsing.
+        *
+        * $Id: help.php,v 1.1 2004/09/07 13:57:26 jollytoad Exp $
+        */
+
+       # TODO: Localize messages, improve (or remove) help browser
+        
+        
+       // Include application functions
+       include_once('./libraries/lib.inc.php');
+       
+       $action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : '';
+
+       function doDefault() {
+               global $data;
+               
+               if (isset($_REQUEST['help'])) {
+                       $url = $data->getHelp($_REQUEST['help']);
+                       
+                       if (is_array($url)) {
+                               doChoosePage($url);
+                               return;
+                       }
+                       
+                       if ($url) {
+                               header("Location: $url");
+                               exit;
+                       }
+               }
+               
+               doBrowse('Invalid help page');
+       }
+       
+       function doBrowse($msg = '') {
+               global $misc, $data;
+               
+               $misc->printHeader('Help page browser');
+               $misc->printBody();
+               
+               $misc->printTitle('PostgreSQL and phpPgAdmin Help');
+               
+               echo $misc->printVal($msg);
+               
+               echo "<dl>\n";
+               
+               $pages =& $data->getHelpPages();
+               foreach ($pages as $page => $dummy) {
+                       echo "<dt>{$page}</dt>\n";
+                       
+                       $urls = $data->getHelp($page);
+                       if (!is_array($urls)) $urls = array($urls);
+                       foreach ($urls as $url) {
+                               echo "<dd><a href=\"{$url}\">{$url}</a></dd>\n";
+                       }
+               }
+               
+               echo "</dl>\n";
+               
+               $misc->printFooter();
+       }
+       
+       function doChoosePage($urls) {
+               global $misc;
+               
+               $misc->printHeader('Help page browser');
+               $misc->printBody();
+               
+               $misc->printTitle('Please select a help page');
+               
+               echo "<ul>\n";
+               foreach($urls as $url) {
+                       echo "<li><a href=\"{$url}\">{$url}</a></li>\n";
+               }
+               echo "</ul>\n";
+
+               $misc->printFooter();
+       }
+       
+       switch ($action) {
+               case 'browse':
+                       doBrowse();
+                       break;
+               default:
+                       doDefault();
+                       break;
+       }
+?>