*
* On-line help CGI for the Common UNIX Printing System (CUPS).
*
+ * Copyright 2007 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
- * property of Easy Software Products and are protected by Federal
- * copyright law. Distribution and use rights are outlined in the file
- * "LICENSE.txt" which should have been included with this file. If this
- * file is missing or damaged please contact Easy Software Products
- * at:
- *
- * Attn: CUPS Licensing Information
- * Easy Software Products
- * 44141 Airport View Drive, Suite 204
- * Hollywood, Maryland 20636 USA
- *
- * Voice: (301) 373-9600
- * EMail: cups-info@cups.org
- * WWW: http://www.cups.org
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
* Contents:
*
directory[1024]; /* Directory */
cups_file_t *fp; /* Help file */
char line[1024]; /* Line from file */
+ int printable; /* Show printable version? */
/*
cgiInitialize();
+ printable = cgiGetVariable("PRINTABLE") != NULL;
+
/*
* Set the web interface section...
*/
{
perror(filename);
- cgiStartHTML("Help");
+ cgiStartHTML(cgiText(_("Help")));
cgiSetVariable("ERROR", "Unable to load help index!");
cgiCopyTemplateLang("error.tmpl");
cgiEndHTML();
fprintf(stderr, "argv[%d]=\"%s\"\n", i, argv[i]);
if ((helpfile = getenv("PATH_INFO")) != NULL)
+ {
helpfile ++;
- else if (strstr(argv[0], "help.cgi"))
- helpfile = NULL;
- else
- helpfile = argv[0];
+
+ if (!*helpfile)
+ helpfile = NULL;
+ }
if (helpfile)
{
{
perror(filename);
- cgiStartHTML("Help");
+ cgiStartHTML(cgiText(_("Help")));
cgiSetVariable("ERROR", "Unable to access help file!");
cgiCopyTemplateLang("error.tmpl");
cgiEndHTML();
if ((n = helpFindNode(hi, helpfile, NULL)) == NULL)
{
- cgiStartHTML("Help");
+ cgiStartHTML(cgiText(_("Help")));
cgiSetVariable("ERROR", "Help file not in index!");
cgiCopyTemplateLang("error.tmpl");
cgiEndHTML();
cgiSetVariable("HELPFILE", helpfile);
cgiSetVariable("HELPTITLE", n->text);
+ cgiSetVariable("TOPIC", n->section);
/*
* Send a standard page header...
*/
- cgiStartHTML(n->text);
+ if (printable)
+ puts("Content-Type: text/html;charset=utf-8\n");
+ else
+ cgiStartHTML(n->text);
}
else
{
* Send a standard page header...
*/
- cgiStartHTML("Help");
+ cgiStartHTML(cgiText(_("Help")));
}
/*
topic = cgiGetVariable("TOPIC");
si = helpSearchIndex(hi, query, topic, helpfile);
+ fprintf(stderr, "DEBUG: query=\"%s\", topic=\"%s\"\n",
+ query ? query : "(null)", topic ? topic : "(null)");
+
if (si)
{
help_node_t *nn; /* Parent node */
"DEBUG: si=%p, si->sorted=%p, cupsArrayCount(si->sorted)=%d\n", si,
si->sorted, cupsArrayCount(si->sorted));
- for (n = (help_node_t *)cupsArrayFirst(si->sorted);
+ for (i = 0, n = (help_node_t *)cupsArrayFirst(si->sorted);
n;
- n = (help_node_t *)cupsArrayNext(si->sorted))
+ i ++, n = (help_node_t *)cupsArrayNext(si->sorted))
{
if (helpfile && n->anchor)
snprintf(line, sizeof(line), "#%s", n->anchor);
* Show the search and bookmark content...
*/
- cgiCopyTemplateLang("help-header.tmpl");
+ if (!helpfile || !printable)
+ cgiCopyTemplateLang("help-header.tmpl");
+ else
+ cgiCopyTemplateLang("help-printable.tmpl");
/*
* If we are viewing a file, copy it in now...
* Send a standard trailer...
*/
- cgiEndHTML();
+ if (!printable)
+ cgiEndHTML();
+ else
+ puts("</BODY>\n</HTML>");
/*
* Delete the index...