Posted By

nerdfiles on 09/30/09


Tagged

php template xhtml xml rdfa


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

LeeRJohnson


XHTML+RDFa 1.0 Template (for Production)


 / Published in: XHTML
 

URL: http://nerdfiles.net/xhtml+rdfa/

Production status (seriously this time). See URL for output. Set for jQuery and Y! CSS Reset use.

Notes: Uses PHP. XHTML+XML mime-type. FF, Opera, Chrome, Safari, IE7+ compatible.

Warning: Servces"text/html" and "text/javascript" to IE (content negotiation). Breaks in IE6. So? Even Google gave up on that trash.

  1. <?php
  2. function is_ie() {
  3. $agent = '';
  4. // old php user agent can be found here
  5. if (!empty($HTTP_USER_AGENT))
  6. $agent = $HTTP_USER_AGENT;
  7. // newer versions of php do have useragent here.
  8. if (empty($agent) && !empty($_SERVER["HTTP_USER_AGENT"]))
  9. $agent = $_SERVER["HTTP_USER_AGENT"];
  10. if (!empty($agent) && preg_match("/MSIE/si", $agent))
  11. return true;
  12. return false;
  13. }
  14.  
  15. if (is_ie() == 1) {
  16. //$xmldec .= "&lt;&#63;xml-stylesheet type=&quot;text/xsl&quot; href=&quot;ie-xml-fix.xsl&quot;&#63;&gt;\n";
  17. // See here for the fix: http://www.echoofeden.com/digest/mit/2007/03/06/ie-xhtml-bug/
  18. $script_include_close = "type=\"text/javascript\"></script>";
  19. $sic = $script_include_close;
  20. $mime_type = "text/html";
  21. $js_mine_type = "text/javascript";
  22. header( 'Content-type: '.$mime_type.'; charset=utf-8' );
  23. } else {
  24. $xmldec = "&lt;&#63;xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;&#63;&gt;\n";
  25. $xmldec .= "&lt;&#63;xml-stylesheet type=&quot;text/css&quot; href=&quot;http://yui.yahooapis.com/2.7.0/build/reset/reset-min.css&quot;&#63;&gt;\n";
  26. $script_include_close = "type=\"application/x-javascript\" />";
  27. $sic = $script_include_close;
  28. $mime_type = "application/xhtml+xml";
  29. $js_mine_type = "application/x-javascript";
  30. header( 'Content-type: '.$mime_type.'; charset=utf-8' );
  31. echo html_entity_decode( $xmldec );
  32. }
  33. ?>
  34. <!DOCTYPE html PUBLIC
  35. "-//W3C//DTD XHTML+RDFa 1.0//EN"
  36. "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
  37. <html version="XHTML+RDFa 1.0"
  38. xmlns="http://www.w3.org/1999/xhtml"
  39. xmlns:dc="http://purl.org/dc/terms"
  40. xmlns:xhv="http://www.w3.org/1999/xhtml/vocab"
  41. xmlns:media="http://purl.org/media"
  42. xmlns:commerce="http://purl.org/commerce"
  43. xmlns:audio="http://purl.org/media/audio"
  44. xml:lang="en"
  45. lang="en">
  46.  
  47. <head>
  48.  
  49. <meta http-equiv="Content-Type" content="<?=$mime_type?>; charset=utf-8" />
  50.  
  51. <!-- Caching Meta -->
  52. <meta http-equiv="expires" content="#" />
  53. <meta http-equiv="cache-control" content="#" />
  54.  
  55. <!-- Site & Page URL Meta -->
  56. <base href="#" />
  57. <link rel="canonical" href="#" />
  58.  
  59. <!-- Language Meta -->
  60. <meta name="content-language" content="#" />
  61. <meta name="language" content="#" />
  62.  
  63. <!-- Production Meta -->
  64. <meta name="author" content="" />
  65. <meta name="designer" content="" />
  66. <meta name="copyright" content="Copyright. YYYY. All Rights Reserved." />
  67.  
  68. <!-- Site || Page Meta -->
  69. <meta name="keywords" content="" />
  70. <meta name="description" content="" />
  71.  
  72. <!-- Search Engine Meta -->
  73. <meta name="robots" content="noydir,noodp,nosnippet" />
  74. <meta name="googlebot" content="" />
  75. <meta name="msnbot" content="" />
  76. <meta name="slurp" content="" />
  77.  
  78. <title>New XHTML + RDFa Document</title>
  79.  
  80. <!-- Style Resources -->
  81. <link rel="shortcut icon" type="image/png" href="icon.png" />
  82. <?php if (is_ie() == 1) { ?>
  83.  
  84. <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.7.0/build/reset/reset-min.css" />
  85. <?php } ?>
  86.  
  87. <!-- JavaScript Resources -->
  88. <?php if (is_ie() == 1) { ?>
  89.  
  90. <!--[if lt IE 8]>
  91. <script src="http://ie7-js.googlecode.com/svn/version/2.0(beta3)/IE8.js" <?=$sic."\n"?>
  92. <![endif]-->
  93.  
  94. <?php } ?><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" <?=$sic."\n"?>
  95. <script type="<?=$js_mine_type?>">
  96. jQuery.noConflict();
  97. jQuery(document).ready(function() {
  98. //...
  99. });
  100. </script>
  101.  
  102. </head>
  103.  
  104. <body>
  105. <?php if (is_ie() == 1) { ?>
  106. <!--[if lt IE 7]>
  107. <div style='border: 1px solid #F7941D; background: #FEEFDA; text-align: center; clear: both; height: 75px; position: relative;'>
  108. <div style='position: absolute; right: 3px; top: 3px; font-family: courier new; font-weight: bold;'><a href='#' onclick='javascript:this.parentNode.parentNode.style.display="none"; return false;'><img src='http://www.ie6nomore.com/files/theme/ie6nomore-cornerx.jpg' style='border: none;' alt='Close this notice'/></a></div>
  109. <div style='width: 640px; margin: 0 auto; text-align: left; padding: 0; overflow: hidden; color: black;'>
  110. <div style='width: 75px; float: left;'><img src='http://www.ie6nomore.com/files/theme/ie6nomore-warning.jpg' alt='Warning!'/></div>
  111. <div style='width: 275px; float: left; font-family: Arial, sans-serif;'>
  112. <div style='font-size: 14px; font-weight: bold; margin-top: 12px;'>You are using an outdated browser</div>
  113. <div style='font-size: 12px; margin-top: 6px; line-height: 12px;'>For a better experience using this site, please upgrade to a modern web browser.</div>
  114. </div>
  115. <div style='width: 75px; float: left;'><a href='http://www.firefox.com' target='_blank'><img src='http://www.ie6nomore.com/files/theme/ie6nomore-firefox.jpg' style='border: none;' alt='Get Firefox 3.5'/></a></div>
  116. <div style='width: 75px; float: left;'><a href='http://www.browserforthebetter.com/download.html' target='_blank'><img src='http://www.ie6nomore.com/files/theme/ie6nomore-ie8.jpg' style='border: none;' alt='Get Internet Explorer 8'/></a></div>
  117. <div style='width: 73px; float: left;'><a href='http://www.apple.com/safari/download/' target='_blank'><img src='http://www.ie6nomore.com/files/theme/ie6nomore-safari.jpg' style='border: none;' alt='Get Safari 4'/></a></div>
  118. <div style='float: left;'><a href='http://www.google.com/chrome' target='_blank'><img src='http://www.ie6nomore.com/files/theme/ie6nomore-chrome.jpg' style='border: none;' alt='Get Google Chrome'/></a></div>
  119. </div>
  120. </div>
  121. <![endif]-->
  122. <?php } ?>
  123.  
  124. <h1>XHTML + RDFa!</h1>
  125. <p property="dc:created" content="YYYY-MM-DD">I am an XHTML document, extended by RDFa. Hello, world!</p>
  126. <p about="" resource="http://www.w3.org/TR/rdfa-syntax" rel="dct:conformsTo" xmlns:dc="http://purl.org/dc/terms/"><a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml-rdfa-blue" alt="Valid XHTML + RDFa" longdesc="http://validator.w3.org/" /></a></p>
  127.  
  128. </body>
  129.  
  130. </html>

Report this snippet  

You need to login to post a comment.