📄 layout_html.inc
字号:
<?php/* * OPTIC TEMPLATE LIBRARY * * Jan 1999-2000 Alexander Aulbach for Main Media * * $Id: layout_html.inc,v 1.2 2000/07/12 18:22:34 kk Exp $ * * This Lib is used for the default representation of a page. * It has to be extended for own layout-design * * The class needs the strings2.inc function-set!! include it with * include("strings2.inc"); * * * This lib was written from the need to implement a user-defined * home page design. The user could choose how the server should looks * for him/her. He/she could choose, for the background color, the * color of the tables, the size of the fonts and so on and so on. * First I thought this would be possible to implement it with Style Sheets * but there is no way to make it as flexible as it needs to. * So the idea was born to make this class, which generates the design * on the fly. * * There is NO NEED to use it for everything. Cause it makes things * more difficult to handle. But it is a great help for some special * kind of use, especially for programming sites, where the user can * choose his layout, like for personalized community pages. * * It's also a great help for programmers of a web site. They can just begin * to make their programs and output tons of lists etc. * They don't have to care about the colors and placement, cause the * layout could be fixed later. * * The advancement to e.g. FastTemplate is, that every little piece of HTML * code has some default representation, which can be changed _dynamically_. * It produces also correct HTML code, if you only use the functions. * * For me especially the doc_picture()-function is a great help, cause * I never have to care about the size of the images (The WIDTH and HEIGHT * attributes). * Our designer says "Oh, Alex, before I forget: I have changes the size * of hugo.gif a little bit, could you fix it in your code?" * And I answer: "It's already fixed. Totaly automatically. :-)" * * The disadvantage is of course, that the pages are generated dynamically, * so it is not fast. * * Best efficency can be achived while using BOTH of them, mixing it * up as you need it. * * * * Ideas for later programming: * - implementing an unsorted list with the originial tags not with tables * * - It would be a nice idea to mix the both advantages of FastTemplate and * Layout. There is just a need for a kind of buffer mechanism. Like this * from "Story Server". If the layout exists and is uptodate, then get * the template and use FastTemplate. If not create template with Layout * and store it for next use. * * - Cause this is a class, you can take care, if the functions are * called in the propper order and closings * */class Layout { ## ## ## var $Debug = false; ## ## these vars are needed for generating an IMG-Tag ## layouturl: s.th. like "http://hugo.bla/" ## layoutpath: if empty it will be set on first call to $DOCUMENT_ROOT ## var $layouturl = ''; var $layoutpath = ''; ## ## In most cases only the following definition-section ## must be changed ## ################################################# BEGIN var $docbegin ='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"><HTML><HEAD>'; ################################################# HTMLHEAD var $htmlhead = ARRAY ( 'TITLE' => "<TITLE>%s</TITLE>\n", 'stylesheet' =>' <style type="text/css"> <!-- body { font-size: 20pt font-family: geneva,Arial,Helvetica,helv,swiss; } td { font-family: geneva,Arial,Helvetica,helv,swiss; } a:visited { text-decoration: none; } a:link { text-decoration: none; } a:active { text-decoration: none; } p { font-size: 20pt ; line-height: 10pt; font-family: geneva,Arial,Helvetica,helv,swiss; fontfamily: geneva,Arial,Helvetica,helv,swiss; } lighthead { font-size: 12pt ; line-height: 10pt; font-family: geneva,Arial,Helvetica,helv,swiss; fontfamily: geneva,Arial,Helvetica,helv,swiss; color: #EEEEEE } --> </style>'); var $htmlhd_def = ARRAY( 'TITLE' => '', 'PRETITLE' => '' ); ## ## For stylesheets we must add ## ID, CLASS, STYLE, LANG and DIR ## to nearly every element! ## The good thing hereby is, that we don't need ## to change the function-calls - ## it is enough to put them here directly into the tag ##/* currently commented as idea for future use * 'metacontent' =>'<META TYPE=content VALUE="%s">', */ ################################################# BODYTAG var $bodytag = ARRAY( 'endhead' => "</HEAD>\n", 'bodytag' => "<BODY%s>\n<P>\n", 'BGCOLOR' => ' BGCOLOR="%s"', 'BACKGROUND' => ' BACKGROUND="%s"', 'TEXT' => ' TEXT="%s"', 'LINK' => ' LINK="%s"', 'VLINK' => ' VLINK="%s"', 'ALINK' => ' ALINK="%s"', 'onLoad' => ' onLoad="%s"', 'endbody' => "%s</P>\n</BODY>\n</HTML>\n" ); var $body_def = ARRAY ( 'BGCOLOR' => '#FFFFFF', 'BACKGROUND' => '', 'TEXT' => '#000000', 'LINK' => '#0000C0', 'VLINK' => '#0000A0', 'ALINK' => '#8000FF' ); ## Default colors for use while configuration ## can be added as usefull var $color_def = ARRAY ( 'color1' => '#AAAAAA', 'color2' => '#444444' ); ################################################# TABLE var $table = ARRAY( 'tabletag' => "<TABLE%s>\n", 'CELLPADDING' => ' CELLPADDING="%s"', 'CELLSPACING' => ' CELLSPACING="%s"', 'BORDER' => ' BORDER="%s"', 'WIDTH' => ' WIDTH="%s"', 'BGCOLOR' => ' BGCOLOR="%s"', 'ALIGN' => ' ALIGN="%s"', 'endtable' => '</TABLE>' ); var $table_def = ARRAY( 'CELLPADDING' => '2', 'CELLSPACING' => '0', 'BORDER' => '0', 'WIDTH' => '100%', 'BGCOLOR' => '', 'ALIGN' => '' ); ################################################# TABROW var $tabrow = ARRAY( 'trtag' => '<TR%s>', 'ALIGN' => ' ALIGN="%s"', 'VALIGN' => ' VALIGN="%s"', 'BGCOLOR' => ' BGCOLOR="%s"', 'endtrtag' => "</TR>\n" ); var $tabrow_def = ARRAY( 'ALIGN' => '', 'VALIGN' => 'top', 'BGCOLOR' => '' ); ################################################# TABCELL var $tabcell = ARRAY( 'tdtag' => '<TD%s>', 'COLSPAN' => ' COLSPAN="%s"', 'ROWSPAN' => ' ROWSPAN="%s"', 'ALIGN' => ' ALIGN="%s"', 'VALIGN' => ' VALIGN="%s"', 'BGCOLOR' => ' BGCOLOR="%s"', 'WIDTH' => ' WIDTH="%s"', 'endtdtag' => "</TD>\n" ); ## not included: HALIGN, AXES, AXIS, NOWRAP var $tabcell_def = ARRAY( 'COLSPAN' => '', 'ROWSPAN' => '', 'ALIGN' => '', 'VALIGN' => '', 'BGCOLOR' => '', 'WIDTH' => '' ); ############################################# UNSORTED LIST## Old Style:## var $ulist = ARRAY(## 'ultag' => '<UL%s>',## 'COMPACT' => ' COMPACT',## 'STYLE' => ' STYLE="%s"',## 'endultag' => '</UL>'## );#### var $ulist_def = ARRAY(## 'COMPACT' => '', # '' (nothing) or '1'## 'STYLE' => '' # DISC|SQUARE|CIRCLE## );## var $uitem = ARRAY(## 'litag' => '<LI> %s%s',## );### New Style - I like this more, but it is of course more code var $ulist = ARRAY( 'ultag' => '<TABLE CELLPADDING=0 BORDER=0%s>', 'CELLSPACING' => ' CELLSPACING=%s', 'endultag' => '</TABLE>' ); var $ulist_def = ARRAY( 'CELLSPACING' => '5' ); var $uitem = ARRAY( 'litag' => "\n<TR VALIGN=top><TD>%s</TD></TR>", 'licont' => '%%s</TD><TD>%s' ); var $uitem_def = ARRAY( 'IMGSRC' => "/pics/arrowright.gif" ); ############################################## ANKER var $anker = ARRAY( 'anker' => '%s<A%s>%s</A>', 'comment' => '%s ', 'HREF' => ' HREF="%s"', 'atext' => '%s', 'TARGET' => ' TARGET="%s"', 'onclick' => ' OnClick="%s"' ); var $anker_def = ARRAY( 'comment' => 'Link:', 'atext' => 'mehr Info' ); ## Missing: TARGET ! ############################################# PICTURE var $picture = ARRAY( 'pictag' => '<IMG SRC="%s"%s>', 'BORDER' => ' BORDER="%s"', 'ALIGN' => ' ALIGN="%s"', 'HVSPACE' => ' HSPACE="%s" VSPACE="%s"', 'ALT' => ' ALT="%s"', 'WIDTH' => ' WIDTH="%s"', 'HEIGHT' => ' HEIGHT="%s"' ); var $picture_def = ARRAY( 'BORDER' => '', 'ALIGN' => '', 'HVSPACE' => '5', 'ALT' => '', 'force' => false ## force output even if image not found ); ############################################ SIMPTEXT var $simptext = ARRAY( 'simptext' => "%s\n%s", 'thead' => '<H%d>%s</H%d>', 'text' => '%s', 'ALIGN' => '<DIV ALIGN="%s">', 'ENDALIGN' => '</DIV>' ); var $simptext_def = ARRAY( 'theadsize' => '2', 'ALIGN' => '' ); ############################################ RULER var $ruler = ARRAY( 'ruler' => '<HR%s>', 'SRC' => '', 'WIDTH' => ' WIDTH="%s"', 'SIZE' => ' SIZE="%s"', 'NOSHADE' => ' NOSHADE' ); var $ruler_def = ARRAY( 'SRC' => '', 'WIDTH' => '', 'SIZE' => '', 'NOSHADE' => '1' ); ############################################ PLACEHOLDER var $placeholder_def= ARRAY( 'SRC' => '/pics/platzhalter.gif' ); ############################################ BOXES var $box_def= ARRAY( 'BOXCOLOR' => '#9999DD', 'BOXPREHEAD' => '<BIG><FONT COLOR="#EEEEEE"> ' ); ################################################# # end of variable-definition ################################################# ## ---------------------------------------------- BEGIN function doc_begin () { return($this->docbegin); } ## ---------------------------------------------- END ## Pseudofunction, thougth for possible downward ## compatibility; this function should check for possible ## syntax errors in generation of HTML-code function doc_end () { } ## ---------------------------------------------- HTMLHEAD function htmlhd ($TITLE='', $meta='',$rest='') { $this->defval($TITLE, $this->htmlhd_def['TITLE']); if (!$TITLE) { $TITLE=$GOLBALS[PHP_SELF]; } $TITLE = $this->htmlhd_def[PRETITLE] . $TITLE; $out=sprintf($this->htmlhead['TITLE'],$TITLE). $this->htmlhead['stylesheet']. $rest; $this->_debug('htmlhd',$out); return($out); } ## ---------------------------------------------- BODYTAG function doc_body ($CONTENT) { return("$CONTENT\n"); } function beg_body ($a='') { $BGCOLOR=$a[BGCOLOR]; $BACKGROUND=$a[BACKGROUND]; $TEXT=$a[TEXT]; $VLINK=$a[VLINK]; $ALINK=$a[ALINK]; $onLoad=$a[onLoad]; $this->defval($BGCOLOR, $this->body_def['BGCOLOR']); $this->defval($BACKGROUND,$this->body_def['BACKGROUND']); $this->defval($TEXT, $this->body_def['TEXT']); $this->defval($LINK, $this->body_def['LINK']); $this->defval($VLINK, $this->body_def['VLINK']); $this->defval($ALINK, $this->body_def['ALINK']); $this->defval($onLoad, $this->body_def['onLoad']); $r=''; $r.=o_iftrue($BGCOLOR, $this->bodytag['BGCOLOR']); $r.=o_iftrue($BACKGROUND, $this->bodytag['BACKGROUND']); $r.=o_iftrue($TEXT, $this->bodytag['TEXT']); $r.=o_iftrue($LINK, $this->bodytag['LINK']); $r.=o_iftrue($VLINK, $this->bodytag['VLINK']); $r.=o_iftrue($ALINK, $this->bodytag['ALINK']); $r.=o_iftrue($onLoad, $this->bodytag['onLoad']); $out=sprintf($this->bodytag['bodytag'],$r); $this->_debug('beg_body',$out); return($out); } function end_body ($rest='') { $this->_debug2('end_body'); return(sprintf($this->bodytag['endbody'],$rest)); } ## ---------------------------------------------- TABLE function doc_table ($CONTENT) { $this->_debug2('doc_table'); return("$CONTENT\n"); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -