Location: PHPKode > projects > MaximaPHP > maximaphp/mpxhtml.php
<?php

/**
 * mpxhtml-en.php, MaximaPHP Viewer - xhtml header
 *
 * xhtml header for MaximaPHP viewer.
 * 
 * This file contains xhtml header.
 * @author Neil Crosby <http://www.workingwith.me.uk/articles/scripting/mimetypes>
 * @version 0.1.3
 * @package MaximaPHP
 */

/**************************************************************
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation below,
 * 
 * http://www.gnu.org/licenses/gpl.html#TOC1
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
 * MA  02110-1301, USA.
 *
 **************************************************************/

$charset = "iso-8859-1";
//$mime = "text/html";
$mime = "application/xml";

if(stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml")) 
{
   # if there's a Q value for "application/xhtml+xml" then also 
   # retrieve the Q value for "text/html"
   if(preg_match("/application\/xhtml\+xml;q=0(\.[1-9]+)/i",
                 $_SERVER["HTTP_ACCEPT"], $matches)) 
   {
      $xhtml_q = $matches[1];
      if(preg_match("/text\/html;q=0(\.[1-9]+)/i",
                    $_SERVER["HTTP_ACCEPT"], $matches)) 
      {
         $html_q = $matches[1];
         # if the Q value for XHTML is greater than or equal to that 
         # for HTML then use the "application/xhtml+xml" mimetype
         if($xhtml_q >= $html_q) 
         {
            $mime = "application/xhtml+xml";
         }
      }
   # if there was no Q value, then just use the 
   # "application/xhtml+xml" mimetype
   } 
   else 
   {
      $mime = "application/xhtml+xml";
   }
}

# special check for the W3C_Validator
if (stristr($_SERVER["HTTP_USER_AGENT"],"W3C_Validator")) 
{
   $mime = "application/xhtml+xml";
}

# set the prolog_type according to the mime type which was determined
if($mime == "application/xhtml+xml") 
{
   $prolog_type = '<?xml version="1.0"?>' . "\n";
   $prolog_type .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" "http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd" [<!ENTITY mathml "http://www.w3.org/1998/Math/MathML">]>' . "\n";
   $prolog_type .= '<html xmlns="http://www.w3.org/1999/xhtml">' . "\n<head>";
} 
else 
{
   $prolog_type = '<?xml version="1.0" encoding="iso-8859-1"?>' . "\n";
   $prolog_type .= '<?xml-stylesheet type="text/xsl" href="http://maximaphp.sourceforge.net/mathml.xsl"?>' . "\n";
   $prolog_type .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n";
   $prolog_type .= '<html xmlns="http://www.w3.org/1999/xhtml">' . "\n<head>";
}

# finally, output the mime type and prolog type
header("Content-Type: $mime;charset=$charset");
header("Vary: Accept");
print $prolog_type;

?>
Return current item: MaximaPHP