/[dtapublic]/to_be_filed/webprojs/php_libraries/php_library/fboprime/htmlformat.inc
ViewVC logotype

Contents of /to_be_filed/webprojs/php_libraries/php_library/fboprime/htmlformat.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 35 - (show annotations) (download)
Sat Oct 8 23:35:33 2016 UTC (8 years ago) by dashley
File size: 5730 byte(s)
Initial commit.
1 <?php
2 //$Header: /hl/cvsroots/gpl01/gpl01/webprojs/fboprime/sw/phplib/htmlformat.inc,v 1.4 2006/04/16 20:51:42 dashley Exp $
3 //********************************************************************************
4 //htmlformat.inc--FboPrime HTML Formatting Functions
5 //Copyright (C) 2006 David T. Ashley
6 //
7 //This program is free software; you can redistribute it and/or
8 //modify it under the terms of the GNU General Public License
9 //as published by the Free Software Foundation; either version 2
10 //of the License, or (at your option) any later version.
11 //
12 //This program is distributed in the hope that it will be useful,
13 //but WITHOUT ANY WARRANTY; without even the implied warranty of
14 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 //GNU General Public License for more details.
16 //
17 //You should have received a copy of the GNU General Public License
18 //along with this program; if not, write to the Free Software
19 //Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 //********************************************************************************
21 //This file contains functions that assist in formatting HTML.
22 //--------------------------------------------------------------------------------
23 //The number of spaces per indent level.
24 define("HTMLFORMAT_SPACES_PER_INDENT_LEVEL", 2);
25 //
26 //A constant string of spaces. It has to be long enough to cover the maximum
27 //indent that will be permitted. An indent too large will just cause string
28 //truncation.
29 //
30 define("HTMLFORMAT_SPACE_STRING",
31 " ");
32 //
33 //--------------------------------------------------------------------------------
34 //Outputs the correct number of spaces for the indent level in force.
35 //
36 function HTMLFORMAT_indent_echo()
37 {
38 global $GLOBAL_html_indent_level;
39
40 if (CONFIG_HTML_PRETTY)
41 {
42 echo SubStr(HTMLFORMAT_SPACE_STRING,
43 0,
44 $GLOBAL_html_indent_level * HTMLFORMAT_SPACES_PER_INDENT_LEVEL);
45 }
46 else
47 {
48 echo " ";
49 }
50 }
51 //--------------------------------------------------------------------------------
52 //Echoes a string with the correct indent level applied and no newline.
53 //
54 function HTMLFORMAT_echo_noop_nn($arg)
55 {
56 HTMLFORMAT_indent_echo();
57 echo $arg;
58 }
59 //--------------------------------------------------------------------------------
60 //Echoes a string with the correct indent level applied and a newline.
61 //
62 function HTMLFORMAT_echo_noop_nl($arg)
63 {
64 HTMLFORMAT_indent_echo();
65 echo $arg;
66 echo "\n";
67 }
68 //--------------------------------------------------------------------------------
69 //Echoes a string with the correct indent level applied and no newline,
70 //then increases the indent level. This is suitable for tags that
71 //start a container.
72 //
73 function HTMLFORMAT_echo_push_nn($arg)
74 {
75 global $GLOBAL_html_indent_level;
76
77 HTMLFORMAT_indent_echo();
78 echo $arg;
79 $GLOBAL_html_indent_level++;
80 }
81 //--------------------------------------------------------------------------------
82 //Echoes a string with the correct indent level applied and a newline, then
83 //increases the indent level. This is suitable for tags that start a
84 //container.
85 //
86 function HTMLFORMAT_echo_push_nl($arg)
87 {
88 global $GLOBAL_html_indent_level;
89
90 HTMLFORMAT_indent_echo();
91 echo $arg;
92 echo "\n";
93 $GLOBAL_html_indent_level++;
94 }
95 //--------------------------------------------------------------------------------
96 //Decreases the indent level by one, then echoes a string with the correct
97 //indent level applied and no newline. This is suitable for tags that
98 //end a container.
99 //
100 function HTMLFORMAT_echo_pull_nn($arg)
101 {
102 global $GLOBAL_html_indent_level;
103
104 if ($GLOBAL_html_indent_level > 0)
105 $GLOBAL_html_indent_level--;
106
107 HTMLFORMAT_indent_echo();
108 echo $arg;
109 }
110 //--------------------------------------------------------------------------------
111 //Decreases the indent level by one, then echoes a string with the correct
112 //indent level applied and a newline. This is suitable for tags that end a
113 //container.
114 //
115 function HTMLFORMAT_echo_pull_nl($arg)
116 {
117 global $GLOBAL_html_indent_level;
118
119 if ($GLOBAL_html_indent_level > 0)
120 $GLOBAL_html_indent_level--;
121
122 HTMLFORMAT_indent_echo();
123 echo $arg;
124 echo "\n";
125 }
126 //--------------------------------------------------------------------------------
127 //Provides a string containing exactly the number of spaces appropriate for the
128 //indent level.
129 //
130 function HTMLFORMAT_indent_string()
131 {
132 global $GLOBAL_html_indent_level;
133
134 return(
135 SubStr(HTMLFORMAT_SPACE_STRING,
136 0,
137 $GLOBAL_html_indent_level * HTMLFORMAT_SPACES_PER_INDENT_LEVEL)
138 );
139 }
140 //--------------------------------------------------------------------------------
141 //Increases the indent level by one.
142 //
143 function HTMLFORMAT_indent_push()
144 {
145 global $GLOBAL_html_indent_level;
146
147 $GLOBAL_html_indent_level++;
148 }
149 //--------------------------------------------------------------------------------
150 //Decreases the indent level by one, but not below zero.
151 //
152 function HTMLFORMAT_indent_pop()
153 {
154 global $GLOBAL_html_indent_level;
155
156 if ($GLOBAL_html_indent_level > 0)
157 $GLOBAL_html_indent_level--;
158 }
159 //
160 //--------------------------------------------------------------------------------
161 //End of $RCSfile: htmlformat.inc,v $.
162 //--------------------------------------------------------------------------------
163 ?>

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25