-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass.htdoc.php
372 lines (333 loc) · 19.1 KB
/
class.htdoc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
<?php
require_once('class.jslink.php');
require_once('class.alternatestyles.php');
class HTDoc {
var $_IE;
var $charset, $lang, $media_type, $page_title, $base_title, $title_separator, $domain, $author,
$description, $keywords, $category, $copyright, $org, $xmlns, $profile, $style, $script, $extra, $meta;
var $media = array (
'HTML' => 'text/html',
'XHTML' => 'application/xhtml+xml'
);
/**********************************************************************************************/
/**********************************************************************************************/
function __construct($lang = 'en-US', $char = 'utf-8', $org = null, $domain = null, $base_title = null, $author = null, $page_title = null, $description = null, $keywords = null, $category = null, $title_separator = ' ||| ')
{
$this->_IE = !stristr($_SERVER["HTTP_ACCEPT"], "application/xhtml+xml");
$this->lang = $lang;
$this->charset = $char;
$this->org = $org;
$this->domain = $domain;
$this->base_title = $base_title;
$this->author = $author;
$this->page_title = $page_title;
$this->description = $description;
$this->keywords = $keywords;
$this->category = $category;
$this->title_separator = $title_separator;
$this->xmlns = array();
$this->profile = array();
$this->meta = array();
$this->style = new AlternateStyles();
$this->script = new JSLink();
$this->script->set_dir('scripts/');
$this->script->set_relrootdir('/scripts/');
$this->script->set_indicator('php-include');
}
/**********************************************************************************************/
/**********************************************************************************************/
function add_namespace($prefix, $uri){
$this->xmlns[] = array(prefix=>$prefix, uri=>$uri);
}
/**********************************************************************************************/
/* doctype() -- DOCTYPE HTML 4.01 and XHTML 1.0/1.1 Transitional, Frameset and Strict
also peforms content-type negotiation
(c) Copyright 2004-2005, Douglas W. Clifton, all rights reserved.
for more copyright information visit the following URI:
http://loadaveragezero.com/info/copyright.php */
/**********************************************************************************************/
function doctype($doc = 'xhtml', $type = 'strict', $ver = '1.1') {
$doc = strtoupper($doc);
$type = strtolower($type);
$avail = 'PUBLIC'; // or SYSTEM, but we're not going there yet
// begin FPI
$ISO = '-'; // W3C is not ISO registered [or IETF for that matter]
$OID = 'W3C'; // unique owner ID
$PTC = 'DTD'; // the public text class
// as far as I know the PCL is always English
$PCL = 'EN';
$xlang = 'en'; // this you may want to vary if you're in different locale
// DTDs are all under the Technical Reports (TR) branch @ W3C
$URI = 'http://www.w3.org/TR/';
$doc_top = '<html'; // what comes after the DOCTYPE of course
if ($doc == 'HTML') {
$top = $doc;
$this->media_type = $this->media[$doc];
$PTD = $doc.' 4.01'; // we're only supporting HTML 4.01 here
switch ($type) {
case 'frameset' :
$PTD .= ' '.ucfirst($type);
$URI .= 'html4/frameset.dtd';
break;
case 'transitional' :
$PTD .= ' '.ucfirst($type);
$URI .= 'html4/loose.dtd';
break;
case 'strict' :
default :
$URI .= 'html4/strict.dtd';
}
$doc_top .= ' lang="'.$this->lang.'">'; // no namespaces here
} else {
// must be xhtml then, but catch typos
if ($doc != 'XHTML')
$doc = 'XHTML';
$top = 'html'; // remember XML is lowercase
$doc_top .= ' xmlns="http://www.w3.org/1999/xhtml" xml:lang="'.$this->lang.'"';
foreach($this->xmlns as $ns){
$doc_top .= ' xmlns:' . $ns[prefix] . '="' . $ns[uri] . '"';
}
// return the correct media type header for this document,
// but we should probably make sure the browser groks XML!
// the W3C validator does not send the correct Accept header for this family of documents, sigh
if (stristr($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator'))
$this->media_type = $this->media['XHTML'];
else
$this->media_type = (stristr($_SERVER['HTTP_ACCEPT'], $this->media['XHTML'])) ? $this->media['XHTML'] : $this->media['HTML'];
// do NOT send XHTML 1.1 to browsers that don't accept application/xhtml+xml
// see: labs/PHP/DOCTYPE.php#bug-fix for details and a link to the W3C XHTML
// NOTES on this topic
if ($this->media_type == $this->media['HTML'] and $ver == '1.1')
$ver = '1.0';
if ($ver == '1.1') {
$PTD = implode(' ', array ($doc, $ver));
$URI .= 'xhtml11/DTD/xhtml11.dtd';
} else {
$PTD = implode(' ', array ($doc, '1.0', ucfirst($type)));
$URI .= 'xhtml1/DTD/xhtml1-'.$type.'.dtd';
// for backwards compatibilty
$doc_top .= ' lang="'.$this->lang.'"';
}
$doc_top .= '>'; // close root XHTML tag
// send HTTP headers
header('Content-Type: '.$this->media_type.'; charset='.$this->charset);
header('Content-Language: '.$this->lang);
header('Vary: Accept,Content-Type,Content-Language');
// send the XML declaration before the DOCTYPE, but this
// will put IE into quirks mode which we don't want
if (!$this->_IE)
print '<?xml version="1.0" encoding="'.$this->charset.'"?>'."\n";
}
$FPI = implode('//', array ($ISO, $OID, $PTC.' '.$PTD, $PCL));
echo "<!DOCTYPE " . $top . " " . $avail . " \"" . $FPI . "\" \"" . $URI . "\">\n";
echo $doc_top;
} // doctype()
/**********************************************************************************************/
/**********************************************************************************************/
function add_style($path,$media='',$title='',$alternate=false,$condcom=''){
$m = explode(',',$media);
if(!function_exists('is_naked_day') or !is_naked_day() or (!in_array('all',$m) and !in_array('screen',$m) and !in_array('projection',$m)))
$this->style->add($path,$media,$title,$alternate,$condcom);
}
/**********************************************************************************************/
/**********************************************************************************************/
function add_script($js){
$this->script->request($js);
}
/**********************************************************************************************/
/**********************************************************************************************/
function add_profile($url){
$_PROFILES = array(
'grddl' => 'http://www.w3.org/2003/g/data-view',
'hcard' => 'http://microformats.org/wiki/hcard-profile',
'hcalendar' => 'http://microformats.org/wiki/hcalendar-profile',
'hatom' => 'http://microformats.org/wiki/hatom#XMDP_Profile',
'xoxo' => 'http://microformats.org/wiki/xoxo#The_XOXO_Profile',
'geo' => 'http://geotags.com',//geo is part of hcard
'xfn' => 'http://gmpg.org/xfn/11',
'rel-license' => 'http://microformats.org/wiki/rel-license#XMDP_profile',
'rel-nofollow' => 'http://microformats.org/wiki/rel-nofollow#XMDP_profile',
'rel-tag' => 'http://microformats.org/wiki/rel-tag',
'vote-links' => 'http://microformats.org/wiki/vote-links',
'xmdp' => 'http://microformats.org/wiki/xmdp-profile',
'3am-xmdp' => 'http://3amproductions.net/xmdp'
);
if(is_array($url)){
$this->profile = array_merge($this->profile, array_intersect_key($_PROFILES, array_flip($url)));
} else $this->profile[] = $_PROFILES[$url];
}
/**********************************************************************************************/
/**********************************************************************************************/
function add_extra($x){
$this->extra .= $x;
}
/**********************************************************************************************/
/**********************************************************************************************/
function add_meta($m, $next=null, $prev=null){
// fancy pants
$y = date('Y');
$this->copyright = '© ' . implode('-', array_reverse(array ($y --, $y)));
$this->copyright = implode(', ', array ($this->copyright, $this->author, $this->domain, 'All Rights Reserved'));
$mod_date1 = date('c',filemtime($_SERVER['SCRIPT_FILENAME']));
$mod_date2 = date('l, F jS, Y g:i A T',filemtime($_SERVER['SCRIPT_FILENAME']));
$mod_date3 = date('D, j M Y H:i:s T',filemtime($_SERVER['SCRIPT_FILENAME']));
$uri = $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'];
$nav = array(
'index' => array('href'=>'index', 'title'=>'go to our homepage'),
'approach' => array('href'=>'approach', 'title'=>'follow our web development procedure'),
'about' => array('href'=>'about', 'title'=>'learn more about 3AM'),
'portfolio' => array('href'=>'portfolio', 'title'=>'see some of our previous work'),
'contact' => array('href'=>'contact', 'title'=>'get in touch with us'),
'gilbert' => array('href'=>'gilbert', 'title'=>'see more about Gilbert'),
'jason' => array('href'=>'jason', 'title'=>'see more about Jason'),
'help' => array('href'=>'help', 'title'=>'see more about thesite')
);
$_META = array(
'main' =>
'<!-- Standard HTML Metadata -->'."\n\t".
'<meta http-equiv="Content-Type" content="'.$this->media_type.'; charset='.$this->charset.'" />'."\n\t".
'<meta http-equiv="Content-Language" content="'.$this->lang.'" scheme="RFC3066" />'."\n\t".
'<meta http-equiv="Vary" content="Accept" />'."\n\t".
'<meta http-equiv="Vary" content="Content-Language" />'."\n\t".
'<meta http-equiv="Vary" content="Content-Type" />'."\n\t".
'<meta name="Resource-Type" content="Text" scheme="DCMIType" />'."\n\t".
'<meta name="Description" content="'.$this->description.'" />'."\n\t".
'<meta name="Keywords" content="'.$this->keywords.'" />'."\n\t".
'<meta name="Category" content="'.$this->category.'" />'."\n\t".
'<meta name="Distribution" content="Global" />'."\n\t".
'<meta name="Rating" content="General" />'."\n\t".
'<meta name="Robots" content="index,follow" />'."\n\t".
'<meta name="Author" content="'.$this->author.'" />'."\n\t".
'<meta name="Organization" content="'.$this->org.'" />'."\n\t".
'<meta name="Copyright" content="'.$this->copyright.'" />'."\n\t".
'<meta name="Date" content="'.$mod_date1.'" scheme="W3CDTF" />'."\n\t".
'<meta name="Updated" content="'.$mod_date2.'" scheme="W3CDTF" />'."\n\t",
'dc' =>
'<!-- Dublin Core Metadata - http://dublincore.org/documents/1998/09/dces/# -->'."\n\t".
'<link type="application/rdf+xml" rel="schema.dc" title="Dublin Core Meta Data Schema" href="http://purl.org/dc/elements/1.1/" />'."\n\t".
'<meta name="dc.title" content="'.$this->page_title.'" />'."\n\t".
'<meta name="dc.creator" content="'.$this->author.'" />'."\n\t".
'<meta name="dc.description" content="'.$this->description.'" />'."\n\t".
'<meta name="dc.subject" content="'.$this->keywords.'" />'."\n\t".
'<meta name="dc.publisher" content="'.$this->org.'" />'."\n\t".
'<meta name="dc.contributors" content="'.$this->author.'" />'."\n\t".
'<meta name="dc.date" content="'.$mod_date1.'" scheme="W3CDTF" />'."\n\t".
'<meta name="dc.type" content="Text" scheme="DCMIType" />'."\n\t".
'<meta name="dc.format" content="'.$this->media_type.'" scheme="IMT" />'."\n\t".
'<meta name="dc.identifier" content="'.$uri.'" scheme="URI" />'."\n\t".
// '<!-- <meta name="dc.source" content="" scheme="URI" /> -->'."\n\t".
'<meta name="dc.language" content="'.$this->lang.'" scheme="RFC3066" />'."\n\t".
// '<!-- <meta name="dc.relation" content="URI" /> -->'."\n\t".
'<meta name="dc.coverage" content="Columbus, US-OH" />'."\n\t".
'<meta name="dc.rights" content="'.$this->copyright.'" />'."\n\t",
'dmoz' =>
'<!-- DMOZ Directory - http://dmoz.org/ -->'."\n\t".
'<meta name="dmoz.id" content="'.$this->category.'" />'."\n\t",
'geo' =>
'<!-- GeoURL - http://geourl.org -->'."\n\t".
'<link type="application/rdf+xml" rel="schema.geo meta" title="Geo Meta Data Schema" href="http://www.w3.org/2003/01/geo/wgs84_pos#" />'."\n\t".
'<meta name="geo.position" content="39.9972;-83.048" scheme="GEO" />'."\n\t".
'<meta name="geo.placename" content="1591 Presidential Dr, Apt B1, Columbus, OH 43212" scheme="GEO" />'."\n\t".
'<meta name="geo.region" content="US-OH" scheme="GEO" />'."\n\t".
'<meta name="geo.country" content="US" scheme="ISO3166" />'."\n\t",
'tgn' =>
'<!-- Getty Thesaraus of Geographical Names - http://www.getty.edu/research/conducting_research/vocabularies/tgn -->'."\n\t".
'<meta name="tgn.id" content="7013645" scheme="TGN" />'."\n\t".
'<meta name="tgn.name" content="Columbus" scheme="TGN" />'."\n\t".
'<meta name="tgn.nation" content="United States" scheme="TGN" />'."\n\t",
'icbm' =>
'<!-- - http://geourl.org -->'."\n\t".
'<meta name="ICBM" content="39.997202, -83.048000" scheme="ICBM" />'."\n\t",
'icra' =>
'<!-- Internet Content Rating Association - http://www.icra.org -->'."\n\t".
'<link type="application/rdf+xml" rel="meta" title="ICRA labels" href="/xml/labels.rdf" />'."\n\t",
'foaf' =>
'<!-- Friend Of A Friend - http://www.foaf-project.org -->'."\n\t".
'<link rel="meta" type="application/rdf+xml" title="FOAF" href="/xml/foaf.rdf" />'."\n\t",
'cc' =>
'<!-- Creative Commons Licensing - http://creativecommons.org -->'."\n\t".
// '<link type="application/rdf+xml" rel="meta license cc-license" title="Creative Commons License" href="http://creativecommons.org/licenses/by-nc-sa/2.5/rdf" />'."\n\t".
'<link type="text/html" rel="meta license cc-license" title="Creative Commons License" href="http://creativecommons.org/licenses/by-nc-sa/2.5/" />'."\n\t",
'xmdp' =>
'<!-- Xhtml Meta Data Profiles - http://gmpg.org/xmdp -->'."\n\t".
'<link type="'.$this->media_type.'" rel="alternate meta" title="XMDP: XHTML Metadata Profile" href="/xmdp" />'."\n\t",
'favicon' =>
'<!-- Favicon -->'."\n\t".
'<link type="image/x-icon" rel="shortcut icon" href="/images/favicon.ico" />'."\n\t".
'<link id="logo" class="logo" type="image/gif" rel="icon" href="/images/favicon.gif" />'."\n\t",
'nav' =>
'<!-- Site Navigation Links -->'."\n\t".
'<link type="'.$this->media_type.'" rel="home" title="Home" href="/" />'."\n\t".
'<link type="'.$this->media_type.'" rel="about" title="About" href="/about" />'."\n\t".
'<link type="'.$this->media_type.'" rel="contact" title="Contact" href="/contact" />'."\n\t".
// '<!-- <link type="'.$this->media_type.'" rel="search" title="Search" href="/search" /> -->'."\n\t".
'<link type="'.$this->media_type.'" rel="sitemap" title="Site Map" href="/help" />'."\n\t".
'<link type="'.$this->media_type.'" rel="help" title="Help" href="/help" />'."\n\t".
'<link type="'.$this->media_type.'" rel="copyright" title="Copyright Information" href="/help" />'."\n\t".
(!is_null($next)? '<link type="'.$this->media_type.'" rel="next" title="'.$nav[$next]['title'].'" href="/'.$nav[$next]['href'].'" />'."\n\t" : '').
(!is_null($prev)? '<link type="'.$this->media_type.'" rel="prev" title="'.$nav[$prev]['title'].'" href="/'.$nav[$prev]['href'].'" />'."\n\t" : '')
,
'openid' =>
'<!-- OpenID - http://openid.net -->'."\n\t".
'<link rel="openid.server" href="http://www.myopenid.com/server" />'."\n\t".
'<link rel="openid.delegate" href="http://3am.myopenid.com/" />'."\n\t".
'<meta http-equiv="X-XRDS-Location" content="http://3am.myopenid.com/xrds" />'."\n\t",
'openid-jason' =>
'<!-- OpenID delegation for Jason -->'."\n\t".
'<link rel="openid.server" href="http://www.myopenid.com/server" />'."\n\t".
'<link rel="openid.delegate" href="http://jason.karns.name" />'."\n\t",
'openid-gilbert' =>
'<!-- OpenID delegation for Gilbert -->'."\n\t".
'<link rel="openid.server" href="http://www.myopenid.com/server" />'."\n\t".
'<link rel="openid.delegate" href="http://renegadelatino.myopenid.com/" />'."\n\t".
'<meta http-equiv="X-XRDS-Location" content="http://renegadelatino.myopenid.com/xrds" />'."\n\t",
'microid' =>
'<!-- MicroID - http://microid.org -->'."\n\t".
// [email protected], http://3amproductions.net
'<meta name="microid" content="mailto+http:sha1:3d8dd38eae9553ef9667d67380595d144a980adc" />'."\n\t",
'atom' =>
'<!-- Atom Portfolio Feed - http://intertwingly.net/moin-1.2.1/wiki/cgi-bin/moin.cgi/FrontPage -->'."\n\t".
'<link rel="alternate" type="application/atom+xml" title="3AM Productions: Portfolio (Atom 1.0)" href="/atom" />'."\n\t",
'errorlogfeed' =>
'<!-- Atom Error Log Feed - http://intertwingly.net/moin-1.2.1/wiki/cgi-bin/moin.cgi/FrontPage -->'."\n\t".
'<link rel="alternate" type="application/atom+xml" title="3AM Productions: Error Log" href="/error/feed" />'."\n\t",
'rss' =>
'<!-- RSS Portfolio Feed - http://cyber.law.harvard.edu/rss/rss.html -->'."\n\t".
'<link rel="alternate" type="application/rss+xml" title="3AM Productions: Portfolio (RSS 2.0)" href="/rss" />'."\n\t",
'grddl' =>
'<!-- Gleaning Resource Descriptions from Dialects of Languages - http://www.w3.org/2003/g/data-view-->'."\n\t".
'<link rel="transformation" href="http://www.w3.org/2003/12/rdf-in-xhtml-xslts/grokGeoURL.xsl" title="Extract GeoURL data as RDF" type="application/xslt+xml" />'."\n\t".
'<link rel="transformation" href="http://www.w3.org/2000/06/dc-extract/dc-extract.xsl" title="Extract Dublin Core Metadata as RDF" type="application/xslt+xml" />'."\n\t".
'<link rel="transformation" href="http://www.w3.org/2003/12/rdf-in-xhtml-xslts/grokCC.xsl" title="Extract Creative Commons License data as RDF" type="application/xslt+xml" />'."\n\t".
'<link rel="transformation" href="http://www.w3.org/2003/12/rdf-in-xhtml-xslts/grokFOAF.xsl" title="Extract FOAF data as RDF" type="application/xslt+xml" />'."\n\t".
'<link rel="transformation" href="http://www.w3.org/2006/vcard/hcard2rdf.xsl" title="Extract hCard data as RDF" type="application/xslt+xml" />'."\n\t".
'<link rel="transformation" href="http://www.w3.org/2002/12/cal/glean-hcal.xsl" title="Extract hCalendar data as RDF" type="application/xslt+xml" />'."\n\t",
'sitemap' =>
'<!-- sitemap.xml and ror.xml - http://sitemap.org - http://rorweb.com -->'."\n\t".
'<link rel="sitemap" type="application/xml" title="Sitemap.xml" href="/sitemap.xml" />'."\n\t".
'<link rel="sitemap" type="application/rss+xml" title="ROR Sitemap" href="/ror.xml" />'."\n\t"
);
if(is_array($m)){
$this->meta = array_merge($this->meta, array_intersect_key($_META, array_flip($m)));
} else $this->meta[] = $_META[$m];
}
/**********************************************************************************************/
/**********************************************************************************************/
function head($css = null, $js = null) {
if($this->page_title) $this->page_title = $this->base_title . $this->title_separator . $this->page_title;
else $this->page_title = $this->base_title;
echo "\n".'<head profile="'.implode(" ", $this->profile).'">'."\n\t";
echo "<title>$this->page_title</title>\n\t";
echo implode("", $this->meta);
// print css
$this->style->getPreferredStyles();
$this->style->drop();
// print javascript
echo $this->script->deliver();
// print extra
echo $this->extra;
// end head
print "\n</head>\n";
} // head()
}
?>