]> git.sur5r.net Git - glabels/blob - web/common_php.inc
2008-03-03 Jim Evins <evins@snaught.com>
[glabels] / web / common_php.inc
1 <?php
2   header("Content-Type: text/html; charser=utf-8");
3
4   #-------------------------------------------------------
5   # Globals
6   #-------------------------------------------------------
7   # Complete real path to this file
8   $file = realpath(__FILE__);
9
10   # Complete real path of glabels root directory
11   $root_dir = dirname($file);
12
13   # Server document root
14   $htroot = getenv("DOCUMENT_ROOT");
15
16   # Base URL of the glabels website
17   if ( strncmp($root_dir,$htroot,strlen($htroot)) == 0 ) {
18     $root = substr($root_dir,strlen($htroot));
19   } else {
20     $root = "";
21   }
22
23   #-------------------------------------------------------
24   # Print globals
25   #-------------------------------------------------------
26   function print_globals()
27   {
28     global $file, $root_dir, $htroot, $root;
29
30     print "file = \"$file\"<br>";
31     print "root_dir = \"$root_dir\"<br>";
32     print "htroot = \"$htroot\"<br>";
33     print "root = \"$root\"<br>";
34   }
35
36   #-------------------------------------------------------
37   # Print root URL
38   #-------------------------------------------------------
39   function root()
40   {
41     global $root;
42
43     print $root;
44   }
45
46   #-------------------------------------------------------
47   # Construct and print img tag
48   #-------------------------------------------------------
49   function img($src, $alt)
50   {
51     global $root;
52     global $root_dir;
53
54     if (substr($src,0,1) == "/") {
55       $size = GetImageSize("$root_dir$src");
56       print "<img src=\"$root$src\" $size[3] alt=\"$alt\" />";
57     } else {
58       $size = GetImageSize("$src");
59       print "<img src=\"$src\" $size[3] alt=\"$alt\" />";
60     }
61   }
62
63   #-------------------------------------------------------
64   # Construct and print img tag with explicit size, NULL alt
65   #-------------------------------------------------------
66   function img_size($src, $w, $h)
67   {
68     global $root;
69
70     $alt = "";
71
72     if (substr($src,0,1) == "/") {
73       print "<img src=\"$root$src\" width=\"$w\" height=\"$h\" alt=\"$alt\" />";
74     } else {
75       print "<img src=\"$src\" width=\"$w\" height=\"$h\" alt=\"$alt\" />";
76     }
77   }
78
79   #-------------------------------------------------------
80   # Construct and print link (a) tag
81   #-------------------------------------------------------
82   function a($href, $text)
83   {
84     global $root;
85
86     if (substr($href,0,1) == "/") {
87       print "<a href=\"$root$href\">$text</a>";
88     } else {
89       print "<a href=\"$href\">$text</a>";
90     }
91   }
92
93   #-------------------------------------------------------
94   # Construct and print link (a) tag to a downloadable file
95   #-------------------------------------------------------
96   function a_file($href)
97   {
98     global $root;
99
100     $text = basename($href);
101
102     if (substr($href,0,1) == "/") {
103       print "<a href=\"$root$href\">$text</a>";
104     } else {
105       print "<a href=\"$href\">$text</a>";
106     }
107   }
108
109   #-------------------------------------------------------
110   # Construct and print link (a) tag to a sf dl file
111   #-------------------------------------------------------
112   function a_sfdownload($file)
113   {
114       print "<a href=\"http://downloads.sourceforge.net/glabels/$file\">$file</a>";
115   }
116
117   #-------------------------------------------------------
118   # Construct and print link (a) tag to a web address
119   #-------------------------------------------------------
120   function a_host($host)
121   {
122     global $root;
123
124     print "<a href=\"http://$host/\">$host</a>";
125   }
126
127   #-------------------------------------------------------
128   # Construct and print mailto (a) tag
129   #-------------------------------------------------------
130   function a_mailto($email)
131   {
132       print "<a href=\"mailto:$email\">$email</a>";
133   }
134
135   #-------------------------------------------------------
136   # Common Header and navigation
137   #-------------------------------------------------------
138   function gLabelsHeader($tab)
139   {
140     global $root;
141
142     $tabs["$root/"]             = "home";
143     $tabs["$root/news/"]        = "news";
144     $tabs["$root/screenshots/"] = "screenshots";
145     $tabs["$root/download/"]    = "download";
146     $tabs["$root/doc/"]         = "docs";
147     $tabs["$root/faq/"]         = "FAQ";
148     $tabs["$root/contact/"]     = "contact";
149     $tabs["$root/links/"]       = "links";
150
151     print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
152 ?>
153
154 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
155     "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
156
157 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
158 <head>
159          <meta name="description" content="gLabels: a label and business card program for GNOME" />
160          <meta name="keywords" content="glabels, snaught, label, business card, gnome, linux" />
161
162          <title>gLabels</title>
163
164          <link rel="stylesheet" href="<?root();?>/css/glabels.css" type="text/css" />
165
166 </head>
167
168 <body id="glabels">
169
170         <div id="title">&nbsp;</div>
171
172         <div id="left">
173
174                 <!-- Navigation tabs -->
175                 <div id="nav">
176                         <ul>
177 <?php
178     #
179     # Generate tabs
180     #
181     $key = "";
182     $value = "";
183     while (list($key,$value) = each($tabs))
184     {
185         $value = trim($value);
186         if (strlen($value) >= 8) {$width=90;} else {$width=60;}
187         if ($value == $tab)
188         {
189                 print "\t\t\t<li><span>$tab</span></li>\n";
190         }
191         else
192         {
193                 print "\t\t\t<li><a href=\"$key\">$value</a></li>\n";
194         }
195     }
196 ?>
197
198                         </ul>
199
200                 </div>
201
202                 <div id="sflink">
203                         <a href="http://sourceforge.net"><img class="noborder" src="http://sourceforge.net/sflogo.php?group_id=46122&amp;type=2" width="125" height="37" alt="SourceForge Logo" /></a>
204                 </div>
205
206         </div>
207
208         <div id="main">
209                 <div class="tlcorner">&nbsp;</div>
210                 <div class="trcorner">&nbsp;</div>
211                 <div id="content">
212
213
214 <?php
215 }
216 ?>
217
218
219 <?php
220
221   #-------------------------------------------------------
222   # Common Footer
223   #-------------------------------------------------------
224   function gLabelsFooter()
225   {
226 ?>
227
228
229                 </div>
230                 <div class="blcorner">&nbsp;</div>
231                 <div class="brcorner">&nbsp;</div>
232
233                 <div id="footer">
234                                                       <div id="copy">* Section header icons on this website borrowed from the <a href="http://tango.freedesktop.org">Tango</a> project. (<a href="http://creativecommons.org/licenses/by-sa/2.5/">License</a>)</div>
235
236                         <div id="w3clinks">
237                                 <a href="http://validator.w3.org/check/referer"><img class="noborder" src="http://www.w3.org/Icons/valid-xhtml11" alt="Valid XHTML 1.1!" height="31" width="88" /></a>
238                                 <a href="http://jigsaw.w3.org/css-validator/"><img class="noborder" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" height="31" width="88" /></a>
239                         </div>
240
241                 </div>
242
243         </div>
244
245 </body>
246
247 </html>
248
249 <?php
250   }
251 ?>
252
253