<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package Output;

#
# Dev-Editor - Module Output
#
# HTML generating routines
#
# Author:        Patrick Canterino &lt;patshaping@gmx.net&gt;
# Last modified: 2003-10-13
#

use strict;

use vars qw(@EXPORT);

use CGI qw(header);
use HTML::Entities;
use Tool;

### Export ###

use base qw(Exporter);

@EXPORT = qw(htmlhead
             htmlfoot
             error
             abort
             error_in_use
             equal_url
             dir_link);

# htmlhead()
#
# Generate the head of a HTML document
# (a text/html HTTP header will also be created)
#
# Params: Title and heading
#
# Return: Head for the HTML document

sub htmlhead($)
{
 my $title = shift;

 my $html = header(-type =&gt; "text/html");

 $html .= &lt;&lt;END;
&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd"&gt;

&lt;html&gt;
&lt;head&gt;
&lt;title&gt;$title&lt;/title&gt;
&lt;meta http-equiv="content-type" content="text/html; charset=iso-8859-1"&gt;
&lt;/head&gt;
&lt;body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"&gt;

&lt;h1&gt;$title&lt;/h1&gt;

END

 return $html;
}

# htmlfoot()
#
# Generate the foot of a HTML document
#
# Params: -nothing-
#
# Return: Foot for the HTML document

sub htmlfoot
{
 return "\n&lt;/body&gt;\n&lt;/html&gt;";
}

# error()
#
# Format an error message
#
# Params: 1. Error message
#         2. Virtual path to which a link should be displayed (optional)
#
# Return: Formatted message (Scalar Reference)

sub error($;$)
{
 my ($message,$path) = @_;

 my $output = htmlhead("Error");
 $output   .= "&lt;p&gt;$message&lt;/p&gt;";

 if($path)
 {
  $path = encode_entities($path);

  $output .= "\n\n";
  $output .= "&lt;p&gt;&lt;a href=\"$ENV{'SCRIPT_NAME'}?command=show&amp;file=$path\"&gt;Back to $path&lt;/a&gt;&lt;/p&gt;";
 }

 $output .= htmlfoot;

 return \$output;
}

# abort()
#
# Print an error message and exit script
# ^^^^^
#
# Params: Error message

sub abort($)
{
 my $output = error(shift);
 print $$output;
 exit;
}

# error_in_use()
#
# Create a message, that a file is currently in use
#
# Params: File, which is in use
#
# Return: Formatted message (Scalar Reference)

sub error_in_use($)
{
 my $file = shift;

 return error("The file '".encode_entities($file)."' is currently editet by someone else.",upper_path($file));
}

# equal_url()
#
# Create an "equals"-link and print it out
#
# Params: 1. HTTP root
#         2. Relative path
#
# Return: Formatted link (String)

sub equal_url($$)
{
 my ($root,$path) = @_;
 my $url;

 $root =~ s!/$!!;
 $path =~ s!^/!!;
 $url  =  $root."/".$path;
 $url  =  encode_entities($url);

 return "&lt;p&gt;(equals &lt;a href=\"$url\" target=\"_blank\"&gt;$url&lt;/a&gt;)&lt;/p&gt;\n\n";
}

# dir_link()
#
# Create the link to the directory of a file and
# print it out
#
# Params: File
#
# Return: Formatted link (String)

sub dir_link($)
{
 my $dir = upper_path(shift);
 $dir    = encode_entities($dir);

 return "&lt;p&gt;&lt;a href=\"$ENV{'SCRIPT_NAME'}?command=show&amp;file=$dir\"&gt;Back to $dir&lt;/a&gt;&lt;/p&gt;\n\n";
}

# it's true, baby ;-)

1;

#
### End ###</pre></body></html>