diff options
author | Christian Weber | 2007-09-03 15:04:22 +0000 |
---|---|---|
committer | Christian Weber | 2007-09-03 15:04:22 +0000 |
commit | 294a62e26f0f19d81f4548af5f48f6036e611bbd (patch) | |
tree | 659755784f4a54b4d0c14e1b8ddf99e0558e16e6 | |
parent | d628cd9847b7cd8c27503526007bd4acdffd1d8a (diff) | |
download | itools-294a62e26f0f19d81f4548af5f48f6036e611bbd.tar.gz itools-294a62e26f0f19d81f4548af5f48f6036e611bbd.tar.bz2 itools-294a62e26f0f19d81f4548af5f48f6036e611bbd.zip |
Obsolete. Use it_html instead.
-rw-r--r-- | it_html_form.class | 166 | ||||
-rw-r--r-- | it_html_page.class | 215 |
2 files changed, 0 insertions, 381 deletions
diff --git a/it_html_form.class b/it_html_form.class deleted file mode 100644 index 03497e3..0000000 --- a/it_html_form.class +++ /dev/null @@ -1,166 +0,0 @@ -<?php -/* -** $Id$ -** -** ITools - the Internet Tools Library -** -** Copyright (C) 1995-2003 by the ITools Authors. -** This program is free software; you can redistribute it and/or -** modify it under the terms of either the GNU General Public License -** or the GNU Lesser General Public License, as published by the Free -** Software Foundation. See http://www.gnu.org/licenses/ for details. -** -** class it_html_form - Generic HTML Form -*/ - - -/** - * Functions to facilitate creation of HTML forms - */ -class it_html_form -{ - var $name; /* Name of form */ - -/** - * Constructor: set action, name and method (echo <FORM> tag) - * @param $action the action to be performed by this form or empty for link to self - * @param $name form name (optional) - * @param $method the method used for the action (defaults to 'post') - * @param $target Target frame of the form (optional) - */ -function it_html_form($action='*', $name='', $method='post', $target='') -{ - if ($action == '*') - $action = $_SERVER['PHP_SELF']; - - $this->name = $name; - - echo '<form method="'.$method.'" action="'.$action.'"'; - - if ($target) - echo " target=\"$target\""; - - if ($name) - echo " name=\"$name\""; - - echo '>'; -} - - -/** - * Close the form (echo </FORM> tag) - */ -function close() -{ - echo "</form>"; -} - - -/** - * Add a parameter (as a hidden field) - * @param $name parameter name - * @param $value default (?) value - * @param $return_output if true, output will be returned instaed of echoed - */ -function hidden($name, $value="", $return_output=false) -{ - $output = "<input type=\"hidden\" name=\"$name\" value=\"" . htmlspecialchars($value) . "\">"; - if ($return_output) - return $output; - else - echo $output; -} - - -/** - * Create a text field or a textarea if size is width:height - * @param $name text field name - * @param $size textfield width[:height] in chars - * @param $maxlength maximum length of input - * @param $value text field value - */ -function text($name, $size=8, $maxlength=255, $value="") -{ - if (strchr($size, ":")) - { - list($cols, $rows) = explode(":", $size); - echo "<textarea name=\"$name\" rows=\"$rows\" cols=\"$cols\">".htmlspecialchars($value)."</textarea>"; - } - else - echo "<input type=\"text\" name=\"$name\" size=\"$size\" maxlength=\"$maxlength\" value=\"".htmlspecialchars($value)."\">"; -} - - -/** - * Create a password field (masked characters) - * @param $name text field name - * @param $size textfield width[:height] in chars - * @param $maxlength maximum length of input - * @param $value text field value - */ -function password($name, $size=8, $maxlength=255, $value="") -{ - echo "<input type=\"password\" name=\"$name\" size=\"$size\" maxlength=\"$maxlength\" value=\"".htmlspecialchars($value)."\">"; -} - - -/** - * Create a dropdown menu object - * @param $name dropdown field name - * @param $options array (value => text) of available options or - * string key:val{,key:val} where key will be rawurldecoded so it may contain %2C as comma - * @param $selected currently selected value - */ -function select($name, $options, $selected='') -{ - if (!is_array($options)) - { - $opts = explode(',', $options); - $options = array(); - foreach($opts as $opt) - { - list($key, $value) = explode(':', $opt); - $options[rawurldecode($key)] = $value; - } - } - - echo '<select name="'.$name.'">'; - foreach($options as $value => $text) - { - $sel = ($value == $selected) ? ' selected' : ''; - echo '<option value="'.htmlspecialchars($value).'"'.$sel.'>'.$text.'</option>'; - } - echo '</select>'; -} - - -/** - * Create a filename field with browse button - * @param $name file field name - * @param $label label to be echoed before the field - * @param $size file field width in chars - * @param $maxlength maximum length of input - * @param $value text field value - */ -function file($name, $label="", $size=16, $maxlength=255, $value="filename") -{ - echo $label."<input type=\"file\" name=\"$name\" size=\"$size\" maxlength=\"$maxlength\" value=\"".htmlspecialchars($value)."\">"; -} - -/** - * Create a Submit button - * @param $label button label - * @param $name button name - */ -function submit($label="", $name="") -{ - if (!$label) - $label = T('Button-Save'); - - echo "<input type=\"submit\" value=\"$label\""; - if ($name) echo " name=\"$name\""; - echo ">"; -} - -} /* End class html_form */ -?> diff --git a/it_html_page.class b/it_html_page.class deleted file mode 100644 index 1121017..0000000 --- a/it_html_page.class +++ /dev/null @@ -1,215 +0,0 @@ -<?php -/* -** $Id$ -** -** ITools - the Internet Tools Library -** -** Copyright (C) 1995-2003 by the ITools Authors. -** This program is free software; you can redistribute it and/or -** modify it under the terms of either the GNU General Public License -** or the GNU Lesser General Public License, as published by the Free -** Software Foundation. See http://www.gnu.org/licenses/ for details. -** -** class it_html_page - Fairly generic HTML page Class -*/ - -class it_html_page -{ - /* Public read-only */ - var $title; /* <title> of this page */ - var $doctype; /* Document type, will be reasonably initialized */ - var $encoding; /* If set, generate Content-Type HTTP/meta headers */ - - var $url; /* Site-relative URL of this page, without GET args */ - var $remote_host; /* IP address of caller (can deal with most proxies) */ - - /* Private */ - var $headers; /* Header lines to output in <head> context */ - var $meta_headers = array(); /* <meta name=.. content=..> tags in <head> context */ - var $body_tags = array(); /* array of tags in <body statement */ - var $body_start = ""; /* This is output immediately after <body> */ - var $body_end = ""; /* Output immediately before </body> */ - var $head_sent = 0; /* 1 if <head> area already sent to client */ - var $in_body = 0; /* false=in header, true=in body */ - var $in_input_tr = 0; /* For input_text() */ - - - -/** - * Constructor - * @param $tags optional array of key => value pairs: title, doctype, encoding - */ -function it_html_page($tags='') -{ - /* Set defaults */ - $this->doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">'; - - /* Determine the relative URL of this page for self-reference */ - if (isset($_SERVER['SCRIPT_URL'])) - $this->url = $_SERVER['SCRIPT_URL']; - else - { - list($this->url) = explode("?", $_SERVER['REQUEST_URI']); - $this->url = substr(strrchr($this->url, "/"), 1); /* $$$ what's this?? */ - } - - /* This is needed for POST requests to oneself */ - if ($this->url == "") - $this->url = "./"; - - /* Determine IP address of caller */ - if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && ereg('^([0-9.]{7,15})', $_SERVER['HTTP_X_FORWARDED_FOR'], $regs)) - $this->remote_host = trim($regs[1]); - else - $this->remote_host = $_SERVER['REMOTE_ADDR']; - - /* Is this a good idea? */ - $this->add_meta_header('generator', '$Id$'); - - /* Override defaults with user tags */ - if (is_array($tags)) - foreach($tags as $key => $value) - $this->$key = $value; - - if (isset($this->encoding)) - { - $ct = 'text/html; charset='.$this->encoding; - header('Content-Type: '.$ct); - $this->add_header('<meta http-equiv="Content-Type" content="'.$ct.'">'); - } -} - - -/** - * Set the title of the page - */ -function set_title($title) -{ - $this->title = $title; -} - - -/** - * Add a line to the header area and trim it - */ -function add_header($header) -{ - $this->headers .= trim($header)."\n"; -} - - -/** - * Add a meta header. - * If a header with the same name exists, overwrite it. - */ -function add_meta_header($name, $value) -{ - $this->meta_headers[strtolower($name)] = $value; -} - - -/** - * Add a tag=value pair in <body context. - * If a header with the same name exists, overwrite it. - */ -function add_body_tag($name, $value) -{ - $this->body_tags[strtolower($name)] = $value; -} - - -/** - * Add a line to the body area after other lines that were added - */ -function add_body_start($html) -{ - $this->body_start .= $html; -} - - -/** - * Add a line to the body end area before other lines that were added - */ -function add_body_end($html) -{ - $this->body_end = $html . $this->body_end; -} - - -/** - * Write out HTML <head> section, if not already done. - */ -function head() -{ - /* This function can be called multiple times, no harm is done. */ - if (!$this->head_sent) - { - $lang = $this->language ? " lang='$this->language'" : ""; - - if (!$GLOBALS['SENT_PREAMBLE']) /* RELOAD_MAGIC already sent <html><head> */ - echo $this->doctype, "\n<html$lang>\n<head>\n"; - - # Generate title tag. If empty string, output <title></title> (html-required) - if (isset($this->title)) - echo '<title>'.$this->title."</title>\n"; - - echo $this->headers; - - while (list($name, $content) = each($this->meta_headers)) - echo "<meta name=\"$name\" content=\"$content\">\n"; - - echo "</head>\n"; - $this->head_sent = 1; - } -} - - -/** - * Write out HTML <head> section and body start, if not already done. - * @param ... If parameters are present, output them and call end() - */ -function body() -{ - /* Write out header part */ - $this->head(); - - /* This function can be called multiple times, no harm is done. */ - if (!$this->in_body) - { - echo '<body'; - - while (list($tag, $value) = each($this->body_tags)) - echo " $tag=\"$value\""; - - echo ">\n".$this->body_start; - $this->in_body = 1; - - if ($args = func_get_args()) - { - foreach($args as $arg) - echo $arg; - $this->end(); - } - } -} - - -/** - * End a HTML page. - */ -function end() -{ - $this->head(); - - if ($this->in_body) - { - echo $this->body_end."</body>\n"; - $this->in_body = 0; - } - - echo "</html>\n"; -} - - -} /* End class it_html_page */ -?> |