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