Skip to content

Commit

Permalink
Keep namespace clean.
Browse files Browse the repository at this point in the history
  • Loading branch information
guyc committed Jul 24, 2012
1 parent 09d88e7 commit c05e9bc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
17 changes: 9 additions & 8 deletions Foml.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
<?php

// PHP 5.4 and beyond supports XML via htmlentities, but for now we will escape manually.
// courtesy of
// http://stackoverflow.com/questions/3957360/generating-xml-document-in-php-escape-characters
function xmlentities($string) {
return str_replace(array("&", "<", ">", "\"", "'"),
array("&amp;", "&lt;", "&gt;", "&quot;", "&apos;"), $string);
}

/*
* If you are NOT using a class autoloader
* you should require_once 'FomlConfig.php'
Expand All @@ -25,6 +17,15 @@ class Foml
static $pdfMimeType = "application/pdf";
static $defaultNamespace = "fo";

// PHP 5.4 and beyond supports XML via htmlentities, but for now we will escape manually.
// courtesy of
// http://stackoverflow.com/questions/3957360/generating-xml-document-in-php-escape-characters
static function XmlEntities($string) {
return str_replace(array("&", "<", ">", "\"", "'"),
array("&amp;", "&lt;", "&gt;", "&quot;", "&apos;"),
$string);
}

static function GeneratePhp($Template)
{
$fomlParser = new FomlParser();
Expand Down
4 changes: 1 addition & 3 deletions FomlEvalNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ function RenderPrefix()
print "print ";
// revisit - would be nice to be able to turn off htmlentities
if ($this->xmlEscape) {
// This depends on PHP 5.4 or later
//print "htmlentities({$this->code},ENT_XML1)";
print "xmlentities({$this->code})";
print "Foml::XmlEntities({$this->code})";
} else {
print $this->code;
}
Expand Down

0 comments on commit c05e9bc

Please sign in to comment.