mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 12:19:28 +00:00
- testtool fixes
- xslfo2pdf php4 Anpassungen
This commit is contained in:
@@ -236,7 +236,7 @@ else
|
||||
{
|
||||
if($demo) //Demofrage wird angezeigt
|
||||
{
|
||||
$qry = "SELECT frage_id FROM testtool.tbl_frage WHERE gebiet_id='".addslashes($gebiet_id)."' AND gruppe_kurzbz='$gruppe' AND demo=true ORDER BY nummer ASC LIMIT 1";
|
||||
$qry = "SELECT frage_id FROM testtool.tbl_frage WHERE gebiet_id='".addslashes($gebiet_id)."' AND gruppe_kurzbz='$gruppe' AND demo=true ORDER BY nummer DESC LIMIT 1";
|
||||
$result = pg_query($conn, $qry);
|
||||
if($row = pg_fetch_object($result))
|
||||
$frage->load($row->frage_id);
|
||||
@@ -305,11 +305,13 @@ if($frage->frage_id!='')
|
||||
//Antwort laden falls bereits vorhanden
|
||||
$antwort = new antwort($conn);
|
||||
$antwort->getAntwort($_SESSION['pruefling_id'],$frage->frage_id);
|
||||
if(!$demo)
|
||||
{
|
||||
echo "<form action=\"$PHP_SELF?gebiet_id=$gebiet_id&frage_id=$frage->frage_id\" method=\"POST\">";
|
||||
echo "<input type=\"hidden\" name=\"antwort_id\" value=\"$antwort->antwort_id\">";
|
||||
echo "Antwort: <input type=\"text\" size=\"1\" id=\"antwort\" name=\"antwort\" value=\"".htmlentities(addslashes($antwort->antwort))."\"> <input ".($demo?'type="button"':'type="submit"')." name=\"submitantwort\" onclick=\"return checkantwort()\" value=\"Speichern\">";
|
||||
echo "Antwort: <input type=\"text\" size=\"1\" id=\"antwort\" name=\"antwort\" value=\"".htmlentities(addslashes($antwort->antwort))."\"> <input type=\"submit\" name=\"submitantwort\" onclick=\"return checkantwort()\" value=\"Speichern\">";
|
||||
echo "</form>";
|
||||
|
||||
}
|
||||
echo '<br><br><br>';
|
||||
//Fusszeile mit Weiter Button und Sprung direkt zu einer Frage
|
||||
if(!$demo)
|
||||
|
||||
@@ -204,10 +204,16 @@ class frage
|
||||
|
||||
function getNextFrage($gebiet_id, $gruppe_kurzbz, $frage_id, $demo=false)
|
||||
{
|
||||
$qry = "SELECT frage_id FROM testtool.tbl_frage WHERE gebiet_id='".addslashes($gebiet_id)."' AND gruppe_kurzbz='".addslashes($gruppe_kurzbz)."' AND nummer>(SELECT nummer FROM testtool.tbl_frage WHERE frage_id='".addslashes($frage_id)."') ";
|
||||
$qry = "SELECT frage_id FROM testtool.tbl_frage WHERE gebiet_id='".addslashes($gebiet_id)."' AND gruppe_kurzbz='".addslashes($gruppe_kurzbz)."' AND nummer".($demo?'<':'>')."(SELECT nummer FROM testtool.tbl_frage WHERE frage_id='".addslashes($frage_id)."') ";
|
||||
if($demo)
|
||||
{
|
||||
$qry.=" AND demo=true";
|
||||
$qry.=" ORDER BY nummer ASC LIMIT 1";
|
||||
$order = 'DESC';
|
||||
}
|
||||
else
|
||||
$order = 'ASC';
|
||||
|
||||
$qry.=" ORDER BY nummer $order LIMIT 1";
|
||||
|
||||
if($result = pg_query($this->conn, $qry))
|
||||
{
|
||||
|
||||
@@ -182,6 +182,7 @@ class pruefling
|
||||
}
|
||||
else
|
||||
{
|
||||
pg_query($this->conn, 'ROLLBACK');
|
||||
$this->errormsg = 'Fehler beim Speichern der Frage:'.$qry;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ http://xslf2pdf.tegonal.com
|
||||
*/ ?>
|
||||
<?PHP
|
||||
class FO_Block extends FO_LayoutObject{
|
||||
private static $CHILDNODES = array(
|
||||
static $CHILDNODES = array(
|
||||
//FO_BidiOverride,
|
||||
//FO_Character,
|
||||
'FO_ExternalGraphic', /*oesi - uncomment for ExternalGraphic Support*/
|
||||
@@ -41,16 +41,16 @@ class FO_Block extends FO_LayoutObject{
|
||||
'FO_ListBlock'
|
||||
);
|
||||
|
||||
protected function getChildNodes() {
|
||||
function getChildNodes() {
|
||||
return self::$CHILDNODES;
|
||||
}
|
||||
|
||||
protected function initAttributes($node) {
|
||||
function initAttributes($node) {
|
||||
$this->initAttribute($node, "text-align");
|
||||
$this->initAttribute($node, "content-width");
|
||||
}
|
||||
|
||||
protected function processContent($text) {
|
||||
function processContent($text) {
|
||||
$talign = $this->getContext("text-align");
|
||||
//oesi - add attribute content-width
|
||||
$colwidth = $this->getContext("content-width");
|
||||
@@ -90,7 +90,7 @@ class FO_Block extends FO_LayoutObject{
|
||||
$this->setLocalContext("sy", $sy);
|
||||
}
|
||||
|
||||
protected function postParseContent($content) {
|
||||
function postParseContent($content) {
|
||||
$this->setContext("startx", $this->getContext("lx"));
|
||||
$this->setContext("y", $this->getContext("ly"));
|
||||
$pdf = $this->getPdf();
|
||||
@@ -102,7 +102,7 @@ class FO_Block extends FO_LayoutObject{
|
||||
}
|
||||
}
|
||||
|
||||
protected function postParse(FO_Object $obj) {
|
||||
function postParse(FO_Object $obj) {
|
||||
if (!$obj instanceof FO_Inline) {
|
||||
return parent::postParse($obj);
|
||||
}
|
||||
@@ -116,14 +116,14 @@ class FO_Block extends FO_LayoutObject{
|
||||
}
|
||||
}
|
||||
|
||||
private function escape($text) {
|
||||
function escape($text) {
|
||||
return str_replace('\t', '', preg_replace('/\s+/', ' ', $text));
|
||||
}
|
||||
}
|
||||
|
||||
class FO_Inline extends FO_Block {
|
||||
|
||||
protected function processContent($text) {
|
||||
function processContent($text) {
|
||||
// echo "show inline content:$text<br>";
|
||||
return parent::processContent($text);
|
||||
}
|
||||
@@ -131,12 +131,12 @@ class FO_Inline extends FO_Block {
|
||||
}
|
||||
|
||||
class FO_BasicLink extends FO_Block {
|
||||
protected function initAttributes($node) {
|
||||
function initAttributes($node) {
|
||||
$this->initLocalAttribute($node, "internal-destination");
|
||||
$this->initLocalAttribute($node, "external-destination");
|
||||
}
|
||||
|
||||
protected function processContent($text) {
|
||||
function processContent($text) {
|
||||
parent::processContent($text);
|
||||
$width = $this->getContext("content_width");
|
||||
$height = $this->getContext("content_height");
|
||||
@@ -166,7 +166,7 @@ class FO_BasicLink extends FO_Block {
|
||||
//oesi - add ExternalGraphics
|
||||
class FO_ExternalGraphic extends FO_Block
|
||||
{
|
||||
protected function initAttributes($node)
|
||||
function initAttributes($node)
|
||||
{
|
||||
$this->initLocalAttribute($node, "src");
|
||||
$this->initLocalAttribute($node, "width");
|
||||
@@ -175,7 +175,7 @@ class FO_ExternalGraphic extends FO_Block
|
||||
$this->initLocalAttribute($node, "posy");
|
||||
}
|
||||
|
||||
protected function processContent($text)
|
||||
function processContent($text)
|
||||
{
|
||||
parent::processContent($text);
|
||||
|
||||
|
||||
@@ -22,43 +22,43 @@ http://xslf2pdf.tegonal.com
|
||||
*/ ?>
|
||||
<?PHP
|
||||
class FO_Container {
|
||||
private $_refs = array();
|
||||
var $_refs = array();
|
||||
|
||||
public function addReference($category, $name, $ref) {
|
||||
function addReference($category, $name, $ref) {
|
||||
$_refs[$category][$name] = $ref;
|
||||
}
|
||||
|
||||
public function resolveReference($category, $name) {
|
||||
function resolveReference($category, $name) {
|
||||
return (isset($_refs)?$_refs[$category][$name]:'');
|
||||
}
|
||||
}
|
||||
|
||||
class FO_Context {
|
||||
public $_context;
|
||||
var $_context;
|
||||
|
||||
function __contruct() {
|
||||
$this->_context = array();
|
||||
}
|
||||
|
||||
public function get($key) {
|
||||
function get($key) {
|
||||
if(isset($this->_context[$key]))
|
||||
return $this->_context[$key];
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public function set($key, $val) {
|
||||
function set($key, $val) {
|
||||
$this->_context[$key] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
abstract class FO_Object {
|
||||
private $_children;
|
||||
private $_container;
|
||||
private $_context;
|
||||
private $_localContext;
|
||||
private $_pdf;
|
||||
private $_parent;
|
||||
var $_children;
|
||||
var $_container;
|
||||
var $_context;
|
||||
var $_localContext;
|
||||
var $_pdf;
|
||||
var $_parent;
|
||||
|
||||
const NODE_TYPE_ELEMENT = 1;
|
||||
const NODE_TYPE_TEXT = 3;
|
||||
@@ -76,7 +76,7 @@ abstract class FO_Object {
|
||||
* Check unit of value and scale to internal value, if needed
|
||||
* Internal values are stored in mm
|
||||
**/
|
||||
protected function calcInternalValue($value, $to = "mm", $from="mm") {
|
||||
function calcInternalValue($value, $to = "mm", $from="mm") {
|
||||
sscanf($value, "%f%s", $value, $unit);
|
||||
if (!$unit) {
|
||||
$unit = $from;
|
||||
@@ -144,21 +144,21 @@ abstract class FO_Object {
|
||||
}
|
||||
}
|
||||
|
||||
public function addReference($category, $name) {
|
||||
function addReference($category, $name) {
|
||||
if ($category && $name) {
|
||||
$this->_container->addReference($category, $name, $this);
|
||||
}
|
||||
}
|
||||
|
||||
public function resolveReference($category, $name) {
|
||||
function resolveReference($category, $name) {
|
||||
return $this->_container->resolveReference($category, $name);
|
||||
}
|
||||
|
||||
protected function setParent($parent) {
|
||||
function setParent($parent) {
|
||||
$this->_parent = $parent;
|
||||
}
|
||||
|
||||
protected function handleEvent($event) {
|
||||
function handleEvent($event) {
|
||||
if ($event == "sync-position") {
|
||||
$pdf = $this->getPdf();
|
||||
$this->setContext("y", $pdf->GetY());
|
||||
@@ -172,7 +172,7 @@ abstract class FO_Object {
|
||||
/**
|
||||
* Get from current context informations
|
||||
*/
|
||||
protected function getContext($key) {
|
||||
function getContext($key) {
|
||||
$val = $this->_localContext->get($key);
|
||||
if (!$val) {
|
||||
$val = $this->_context->get($key);
|
||||
@@ -183,22 +183,22 @@ abstract class FO_Object {
|
||||
/**
|
||||
* Set a context information for child nodes and current node as well
|
||||
*/
|
||||
protected function setContext($key, $value) {
|
||||
function setContext($key, $value) {
|
||||
$this->_context->set($key, $value);
|
||||
}
|
||||
|
||||
protected function setLocalContext($key, $value) {
|
||||
function setLocalContext($key, $value) {
|
||||
$this->_localContext->set($key, $value);
|
||||
}
|
||||
|
||||
protected function getAttribute(DOMNode $node, $key) {
|
||||
function getAttribute(DOMNode $node, $key) {
|
||||
if($node->attributes->getNamedItem($key)!=null)
|
||||
return $node->attributes->getNamedItem($key)->nodeValue;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getSizeAttribute(DOMNode $node, $key, $to="mm", $from="mm") {
|
||||
function getSizeAttribute(DOMNode $node, $key, $to="mm", $from="mm") {
|
||||
if($node->attributes->getNamedItem($key)!=null)
|
||||
$val = $node->attributes->getNamedItem($key)->nodeValue;
|
||||
else
|
||||
@@ -206,41 +206,41 @@ abstract class FO_Object {
|
||||
return $this->calcInternalValue($val, $to, $from);
|
||||
}
|
||||
|
||||
protected function initSizeAttribute(DOMNode $node, $key, $to="mm", $from="mm") {
|
||||
function initSizeAttribute(DOMNode $node, $key, $to="mm", $from="mm") {
|
||||
$val = $this->getSizeAttribute($node, $key, $to, $from);
|
||||
if ($val) {
|
||||
$this->setContext($key, $val);
|
||||
}
|
||||
}
|
||||
|
||||
protected function initAttribute(DOMNode $node, $key) {
|
||||
function initAttribute(DOMNode $node, $key) {
|
||||
$val = $this->getAttribute($node, $key);
|
||||
if ($val) {
|
||||
$this->setContext($key, $val);
|
||||
}
|
||||
}
|
||||
|
||||
protected function initLocalSizeAttribute(DOMNode $node, $key, $to="mm", $from="mm"){
|
||||
function initLocalSizeAttribute(DOMNode $node, $key, $to="mm", $from="mm"){
|
||||
$val = $this->getSizeAttribute($node, $key, $to, $from);
|
||||
if ($val) {
|
||||
$this->_localContext->set($key, $val);
|
||||
}
|
||||
}
|
||||
|
||||
protected function initLocalAttribute(DOMNode $node, $key) {
|
||||
function initLocalAttribute(DOMNode $node, $key) {
|
||||
$val = $this->getAttribute($node, $key);
|
||||
if ($val) {
|
||||
$this->_localContext->set($key, $val);
|
||||
}
|
||||
}
|
||||
|
||||
protected function processChildNodes(DOMNode $node, $filter) {
|
||||
function processChildNodes(DOMNode $node, $filter) {
|
||||
foreach($node->childNodes as $child) {
|
||||
$this->processChildNode($child, $filter);
|
||||
}
|
||||
}
|
||||
|
||||
protected function processChildNode(DOMNode $node, $filter) {
|
||||
function processChildNode(DOMNode $node, $filter) {
|
||||
$subcontext = clone $this->_context;
|
||||
$next =
|
||||
FO_Factory::createFOObject($node, $this->_container,
|
||||
@@ -255,16 +255,16 @@ abstract class FO_Object {
|
||||
}
|
||||
}
|
||||
|
||||
protected function initFOObject(FO_Object $obj) {
|
||||
function initFOObject(FO_Object $obj) {
|
||||
}
|
||||
|
||||
protected function preParse(FO_Object $obj) {
|
||||
function preParse(FO_Object $obj) {
|
||||
}
|
||||
|
||||
protected function postParse(FO_Object $obj) {
|
||||
function postParse(FO_Object $obj) {
|
||||
}
|
||||
|
||||
protected function processContents(DOMNode $node) {
|
||||
function processContents(DOMNode $node) {
|
||||
foreach($node->childNodes as $child) {
|
||||
if ($child->nodeType == self::NODE_TYPE_TEXT) {
|
||||
$this->processContent($child->textContent);
|
||||
@@ -272,19 +272,19 @@ abstract class FO_Object {
|
||||
}
|
||||
}
|
||||
|
||||
protected function processContent($content) {
|
||||
function processContent($content) {
|
||||
//do nothing per default
|
||||
}
|
||||
|
||||
protected function getPdf() {
|
||||
function getPdf() {
|
||||
return $this->_pdf;
|
||||
}
|
||||
|
||||
protected function NotYetSupported($msg=0) {
|
||||
function NotYetSupported($msg=0) {
|
||||
echo "Not Yet Supported[".get_class($this)."]:$msg<br>";
|
||||
}
|
||||
|
||||
protected function children() {
|
||||
function children() {
|
||||
return $this->_children;
|
||||
}
|
||||
|
||||
@@ -292,7 +292,7 @@ abstract class FO_Object {
|
||||
* Parse the color from either xml attribute value or FPDF
|
||||
* internal representation
|
||||
**/
|
||||
protected function parseColor($color) {
|
||||
function parseColor($color) {
|
||||
if (sscanf($color, "#%2x%2x%2x", $r, $g, $b) == 3) {
|
||||
//parse RGB color
|
||||
$r = sprintf("%d", $r);
|
||||
@@ -338,7 +338,9 @@ abstract class FO_Object {
|
||||
return array($r, $g, $b);
|
||||
}
|
||||
|
||||
public abstract function parse(DOMNode $node);
|
||||
function parse(DOMNode $node)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -354,18 +356,18 @@ class FO_Root extends FO_Object{
|
||||
$this->setContext("acceptPageBreak", true);
|
||||
}
|
||||
|
||||
private static $CHILDNODES = array (
|
||||
static $CHILDNODES = array (
|
||||
'FO_LayoutMasterSet',
|
||||
'FO_PageSequence'
|
||||
);
|
||||
|
||||
public function parse(DOMNode $node) {
|
||||
function parse(DOMNode $node) {
|
||||
//no attrbutes which concerns us
|
||||
$_children[$node->nodeName] =
|
||||
$this->processChildNodes($node, self::$CHILDNODES);
|
||||
}
|
||||
|
||||
public function setContext($key, $value) {
|
||||
function setContext($key, $value) {
|
||||
parent::setContext($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,15 +24,15 @@ http://xslf2pdf.tegonal.com
|
||||
require_once("fo_svg.php");
|
||||
class FO_InstreamForeignObject extends FO_Object {
|
||||
|
||||
private static $CHILDNODES = array(
|
||||
static $CHILDNODES = array(
|
||||
'FO_SVG'
|
||||
);
|
||||
|
||||
public function parse(DOMNode $node) {
|
||||
function parse(DOMNode $node) {
|
||||
$this->processChildNodes($node, self::$CHILDNODES);
|
||||
}
|
||||
|
||||
protected function postParse(FO_Object $obj) {
|
||||
function postParse(FO_Object $obj) {
|
||||
$this->setLocalContext("width", $obj->getContext("width"));
|
||||
$this->setLocalContext("height", $this->getContext("height")+
|
||||
$obj->getContext("height"));
|
||||
|
||||
@@ -22,13 +22,13 @@ http://xslf2pdf.tegonal.com
|
||||
*/ ?>
|
||||
<?PHP
|
||||
|
||||
abstract class FO_LayoutObject extends FO_FlowContainer {
|
||||
private $_oldFont;
|
||||
private $_oldFontStyle;
|
||||
private $_oldColor;
|
||||
private $_buffer;
|
||||
class FO_LayoutObject extends FO_FlowContainer {
|
||||
var $_oldFont;
|
||||
var $_oldFontStyle;
|
||||
var $_oldColor;
|
||||
var $_buffer;
|
||||
|
||||
private function initDefaultAttributes($node) {
|
||||
function initDefaultAttributes($node) {
|
||||
//read attributes
|
||||
$this->initLocalAttribute($node, "border-top-style");
|
||||
$this->initLocalAttribute($node, "border-right-style");
|
||||
@@ -66,13 +66,13 @@ abstract class FO_LayoutObject extends FO_FlowContainer {
|
||||
}
|
||||
|
||||
//oesi - convertiert die daten von utf8 nach latin1 und ersetzt 'EURO' durch das eurosymbol
|
||||
public function convert($str)
|
||||
function convert($str)
|
||||
{
|
||||
//echo str_replace('EURO',chr(128),utf8_decode($str));
|
||||
return str_replace('EURO',chr(128),utf8_decode($str));
|
||||
}
|
||||
|
||||
public function parse(DOMNode $node) {
|
||||
function parse(DOMNode $node) {
|
||||
//set default attributes
|
||||
$this->initDefaultAttributes($node);
|
||||
$this->initAttributes($node);
|
||||
@@ -160,37 +160,37 @@ abstract class FO_LayoutObject extends FO_FlowContainer {
|
||||
/**
|
||||
* Initialize additional attributes
|
||||
**/
|
||||
protected function initAttributes(DOMNode $node) {
|
||||
function initAttributes(DOMNode $node) {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
protected function preParseContent($content) {
|
||||
function preParseContent($content) {
|
||||
}
|
||||
|
||||
protected function postParseContent($textcontent) {
|
||||
function postParseContent($textcontent) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw borders and backgrounds according to the positions
|
||||
* May be overwritten to specify behaviour
|
||||
*/
|
||||
protected function drawBordersAndBackground($pos) {
|
||||
function drawBordersAndBackground($pos) {
|
||||
list($x, $y, $width, $height) = $pos[1];
|
||||
$this->drawBackground($x, $y, $width, $height);
|
||||
$this->drawBorders($x, $y, $width, $height);
|
||||
}
|
||||
|
||||
protected function getChildNodes() {
|
||||
function getChildNodes() {
|
||||
//no child nodes per default
|
||||
return array();
|
||||
}
|
||||
|
||||
protected function initialize() {
|
||||
function initialize() {
|
||||
$break_before = $this->getContext("break-before");
|
||||
$this->handleBreak($break_before);
|
||||
}
|
||||
|
||||
protected function closeDown() {
|
||||
function closeDown() {
|
||||
$pdf = $this->getPdf();
|
||||
if ($this->_oldFont) {
|
||||
$pdf->SetFont($this->_oldFont, $this->_oldFontStyle,
|
||||
@@ -214,7 +214,7 @@ abstract class FO_LayoutObject extends FO_FlowContainer {
|
||||
$this->handleBreak($break_after);
|
||||
}
|
||||
|
||||
protected function startCapture() {
|
||||
function startCapture() {
|
||||
if ($this->_buffer) {
|
||||
echo "Already captureing<br>";
|
||||
return;
|
||||
@@ -222,7 +222,7 @@ abstract class FO_LayoutObject extends FO_FlowContainer {
|
||||
$this->_buffer = $this->getPdf()->startCapture();
|
||||
}
|
||||
|
||||
protected function endCapture() {
|
||||
function endCapture() {
|
||||
if (!$this->_buffer) {
|
||||
return;
|
||||
}
|
||||
@@ -231,7 +231,7 @@ abstract class FO_LayoutObject extends FO_FlowContainer {
|
||||
return $partBuffer;
|
||||
}
|
||||
|
||||
protected function appendBuffer($buffer) {
|
||||
function appendBuffer($buffer) {
|
||||
if (!$buffer) {
|
||||
//echo "Nothing to append<br>";
|
||||
return;
|
||||
@@ -239,7 +239,7 @@ abstract class FO_LayoutObject extends FO_FlowContainer {
|
||||
$this->getPdf()->appendBuffer($buffer);
|
||||
}
|
||||
|
||||
protected function getPosition() {
|
||||
function getPosition() {
|
||||
$space_before = $this->getContext("space-before.optimum");
|
||||
$height = $this->getContext("line-height");
|
||||
$pdf = $this->getPdf();
|
||||
@@ -294,7 +294,7 @@ abstract class FO_LayoutObject extends FO_FlowContainer {
|
||||
array($xx-$wl, $yy-$wr, $width, $height));
|
||||
}
|
||||
|
||||
protected function setColor() {
|
||||
function setColor() {
|
||||
$pdf = $this->getPdf();
|
||||
$this->_oldColor = $pdf->GetTextColor();
|
||||
$color = $this->getContext("color");
|
||||
@@ -303,7 +303,7 @@ abstract class FO_LayoutObject extends FO_FlowContainer {
|
||||
}
|
||||
}
|
||||
|
||||
protected function setFont() {
|
||||
function setFont() {
|
||||
$pdf = $this->getPdf();
|
||||
$this->_oldFont = $pdf->GetFontFamily();
|
||||
$this->_oldFontStyle = $pdf->GetFontStyle();
|
||||
@@ -347,7 +347,7 @@ abstract class FO_LayoutObject extends FO_FlowContainer {
|
||||
}
|
||||
}
|
||||
|
||||
protected function drawBorders($x, $y, $width, $height) {
|
||||
function drawBorders($x, $y, $width, $height) {
|
||||
$bs_top = $this->getContext("border-top-style");
|
||||
$bs_left = $this->getContext("border-left-style");
|
||||
$bs_right = $this->getContext("border-right-style");
|
||||
@@ -401,7 +401,7 @@ abstract class FO_LayoutObject extends FO_FlowContainer {
|
||||
$bs_right, $bc_right,$bw_right, $pdf);
|
||||
}
|
||||
|
||||
protected function drawBackground($x, $y, $width, $height) {
|
||||
function drawBackground($x, $y, $width, $height) {
|
||||
$pdf = $this->GetPdf();
|
||||
$bg_c = $this->getContext("background-color");
|
||||
$bg_img = $this->getContext("background-image");
|
||||
@@ -418,7 +418,7 @@ abstract class FO_LayoutObject extends FO_FlowContainer {
|
||||
}
|
||||
}
|
||||
|
||||
private function drawLine($x, $y, $x2, $y2, $style, $color, $width, &$pdf) {
|
||||
function drawLine($x, $y, $x2, $y2, $style, $color, $width, &$pdf) {
|
||||
$oldColor = $pdf->GetDrawColor();
|
||||
$oldLineWidth = $pdf->GetLineWidth();
|
||||
if ($width) {
|
||||
@@ -456,7 +456,7 @@ abstract class FO_LayoutObject extends FO_FlowContainer {
|
||||
$this->setLineWidth($oldLineWidth);
|
||||
}
|
||||
|
||||
private function setDrawColor($color, &$pdf) {
|
||||
function setDrawColor($color, &$pdf) {
|
||||
if ($color == '') {
|
||||
return;
|
||||
}
|
||||
@@ -464,7 +464,7 @@ abstract class FO_LayoutObject extends FO_FlowContainer {
|
||||
$pdf->SetDrawColor($r, $g, $b);
|
||||
}
|
||||
|
||||
private function setTextColor($color, &$pdf) {
|
||||
function setTextColor($color, &$pdf) {
|
||||
if ($color == '') {
|
||||
return;
|
||||
}
|
||||
@@ -472,7 +472,7 @@ abstract class FO_LayoutObject extends FO_FlowContainer {
|
||||
$pdf->SetTextColor($r, $g, $b);
|
||||
}
|
||||
|
||||
protected function handleBreak($break) {
|
||||
function handleBreak($break) {
|
||||
if (!$break) {
|
||||
return;
|
||||
}
|
||||
@@ -489,20 +489,20 @@ abstract class FO_LayoutObject extends FO_FlowContainer {
|
||||
}
|
||||
|
||||
class FO_LayoutMasterSet extends FO_Object {
|
||||
private $name;
|
||||
var $name;
|
||||
|
||||
public function parse(DOMNode $node) {
|
||||
function parse(DOMNode $node) {
|
||||
$this->name = $node->attributes->getNamedItem("master-name");
|
||||
$this->addReference($this, $this->name);
|
||||
}
|
||||
}
|
||||
|
||||
class FO_PageSequence extends FO_Object {
|
||||
private static $CHILDNODES = array(
|
||||
static $CHILDNODES = array(
|
||||
'FO_Flow'
|
||||
);
|
||||
|
||||
public function parse(DOMNode $node) {
|
||||
function parse(DOMNode $node) {
|
||||
$masterRef = $node->attributes->getNamedItem("master-reference");
|
||||
if ($masterRef) {
|
||||
$master = $this->resolveReference('FO_LayoutMasterSet', $masterRef);
|
||||
@@ -515,9 +515,9 @@ class FO_PageSequence extends FO_Object {
|
||||
}
|
||||
}
|
||||
|
||||
abstract class FO_FlowContainer extends FO_Object {
|
||||
class FO_FlowContainer extends FO_Object {
|
||||
|
||||
protected function postParse(FO_Object $obj) {
|
||||
function postParse(FO_Object $obj) {
|
||||
$acceptPageBreak = $this->getContext("acceptPageBreak");
|
||||
$this->setLocalContext("width", $obj->getContext("width"));
|
||||
$height = $this->getContext("height")+$obj->getContext("height");
|
||||
@@ -541,7 +541,7 @@ abstract class FO_FlowContainer extends FO_Object {
|
||||
}
|
||||
|
||||
class FO_Flow extends FO_FlowContainer {
|
||||
private static $CHILDNODES = array(
|
||||
static $CHILDNODES = array(
|
||||
'FO_Block',
|
||||
'FO_Table',
|
||||
'FO_BlockContainer',
|
||||
@@ -549,21 +549,21 @@ class FO_Flow extends FO_FlowContainer {
|
||||
'FO_ListBlock'
|
||||
);
|
||||
|
||||
public function parse(DOMNode $node) {
|
||||
function parse(DOMNode $node) {
|
||||
//TODO: use attributes
|
||||
$this->processChildNodes($node, self::$CHILDNODES);
|
||||
}
|
||||
}
|
||||
|
||||
class FO_BlockContainer extends FO_LayoutObject {
|
||||
private static $CHILDNODES = array(
|
||||
static $CHILDNODES = array(
|
||||
'FO_Block',
|
||||
'FO_BlockContainer',
|
||||
'FO_TableAndCaption',
|
||||
'FO_Table',
|
||||
'FO_ListBlock');
|
||||
|
||||
protected function initAttributes(DOMNode $node) {
|
||||
function initAttributes(DOMNode $node) {
|
||||
$this->initLocalSizeAttribute($node, "position");
|
||||
$this->initLocalSizeAttribute($node, "top");
|
||||
$this->initLocalSizeAttribute($node, "left");
|
||||
@@ -571,11 +571,11 @@ class FO_BlockContainer extends FO_LayoutObject {
|
||||
$this->initLocalSizeAttribute($node, "width");
|
||||
}
|
||||
|
||||
protected function getChildNodes() {
|
||||
function getChildNodes() {
|
||||
return self::$CHILDNODES;
|
||||
}
|
||||
|
||||
public function parse(DOMNode $node) {
|
||||
function parse(DOMNode $node) {
|
||||
$this->initAttributes($node);
|
||||
$position = $this->getContext("position");
|
||||
if ($position == "absolute"){
|
||||
|
||||
@@ -21,8 +21,8 @@ mike.toggweiler@tegonal.com
|
||||
http://xslf2pdf.tegonal.com
|
||||
*/ ?>
|
||||
<?PHP
|
||||
abstract class SVG_Object extends FO_Object {
|
||||
protected function initLocalStyleAttribute(DOMNode $node) {
|
||||
class SVG_Object extends FO_Object {
|
||||
function initLocalStyleAttribute(DOMNode $node) {
|
||||
$st = $this->getAttribute($node, "style");
|
||||
|
||||
$styles = explode(";", $st);
|
||||
@@ -32,7 +32,7 @@ abstract class SVG_Object extends FO_Object {
|
||||
}
|
||||
}
|
||||
|
||||
protected function initStyleAttribute(DOMNode $node) {
|
||||
function initStyleAttribute(DOMNode $node) {
|
||||
$st = $this->getAttribute($node, "style");
|
||||
|
||||
$styles = explode(";", $st);
|
||||
@@ -43,29 +43,29 @@ abstract class SVG_Object extends FO_Object {
|
||||
}
|
||||
}
|
||||
|
||||
abstract class SVG_StyleObject extends SVG_Object {
|
||||
class SVG_StyleObject extends SVG_Object {
|
||||
|
||||
protected function initLocalSizeAttribute(DOMNode $node, $key, $to="mm", $from="pt"){
|
||||
function initLocalSizeAttribute(DOMNode $node, $key, $to="mm", $from="pt"){
|
||||
parent::initLocalSizeAttribute($node, $key, $to, $from);
|
||||
}
|
||||
|
||||
protected function initSizeAttribute(DOMNode $node, $key, $to="mm", $from="pt"){
|
||||
function initSizeAttribute(DOMNode $node, $key, $to="mm", $from="pt"){
|
||||
parent::initSizeAttribute($node, $key, $to, $from);
|
||||
}
|
||||
|
||||
protected function getLocalSizeAttribute(DOMNode $node, $key, $to="mm", $from="pt"){
|
||||
function getLocalSizeAttribute(DOMNode $node, $key, $to="mm", $from="pt"){
|
||||
return parent::getLocalSizeAttribute($node, $key, $to, $from);
|
||||
}
|
||||
|
||||
protected function getSizeAttribute(DOMNode $node, $key, $to="mm", $from="pt"){
|
||||
function getSizeAttribute(DOMNode $node, $key, $to="mm", $from="pt"){
|
||||
return parent::getSizeAttribute($node, $key, $to, $from);
|
||||
}
|
||||
|
||||
protected function calcInternalValue($value, $to = "mm", $from="pt") {
|
||||
function calcInternalValue($value, $to = "mm", $from="pt") {
|
||||
return parent::calcInternalValue($value, $to, $from);
|
||||
}
|
||||
|
||||
public function parse(DOMNode $node) {
|
||||
function parse(DOMNode $node) {
|
||||
$pdf = $this->getPdf();
|
||||
$buf = $pdf->startCapture();
|
||||
$this->initStyleAttribute($node);
|
||||
@@ -121,12 +121,14 @@ abstract class SVG_StyleObject extends SVG_Object {
|
||||
//echo get_class($this).":$buf<br>";
|
||||
$pdf->appendBuffer($buf);
|
||||
}
|
||||
protected abstract function process(DOMNode $node, $sargs="");
|
||||
function process(DOMNode $node, $sargs="")
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class FO_SVG extends SVG_Object {
|
||||
|
||||
public static $CHILDNODES = array(
|
||||
static $CHILDNODES = array(
|
||||
SVG_Circle,
|
||||
SVG_Rect,
|
||||
SVG_Ellipse,
|
||||
@@ -137,7 +139,7 @@ class FO_SVG extends SVG_Object {
|
||||
SVG_Path
|
||||
);
|
||||
|
||||
public function parse(DOMNode $node) {
|
||||
function parse(DOMNode $node) {
|
||||
$this->initLocalSizeAttribute($node, "width", "mm", "pt");
|
||||
$this->initLocalSizeAttribute($node, "height", "mm", "pt");
|
||||
$this->setContext("xOrig", $this->getContext("x"));
|
||||
|
||||
@@ -66,38 +66,38 @@ http://xslf2pdf.tegonal.com
|
||||
|
||||
class FO_TableAndCaption extends FO_Object {
|
||||
|
||||
private static $CHILDNODES = array(
|
||||
static $CHILDNODES = array(
|
||||
'FO_Table',
|
||||
'FO_TableCaption'
|
||||
);
|
||||
|
||||
public function parse(DOMNode $node) {
|
||||
function parse(DOMNode $node) {
|
||||
$this->processChildNodes($node, self::$CHILDNODES);
|
||||
}
|
||||
}
|
||||
|
||||
class FO_Table extends FO_LayoutObject {
|
||||
private $colCount = 0;
|
||||
var $colCount = 0;
|
||||
|
||||
private static $CHILDNODES = array(
|
||||
static $CHILDNODES = array(
|
||||
'FO_TableColumn',
|
||||
'FO_TableHeader',
|
||||
'FO_TableFooter',
|
||||
'FO_TableBody'
|
||||
);
|
||||
|
||||
protected function getChildNodes() {
|
||||
function getChildNodes() {
|
||||
return self::$CHILDNODES;
|
||||
}
|
||||
|
||||
protected function initFOObject(FO_Object $col) {
|
||||
function initFOObject(FO_Object $col) {
|
||||
if (!$col instanceof FO_TableColumn) {
|
||||
return;
|
||||
}
|
||||
$col->setContext("column", $this->colCount++);
|
||||
}
|
||||
|
||||
protected function postParse(FO_Object $obj) {
|
||||
function postParse(FO_Object $obj) {
|
||||
if ($obj instanceof FO_TableHeader) {
|
||||
$this->setLocalContext("width", $obj->getContext("width"));
|
||||
$this->setLocalContext("height", $this->getContext("height")+
|
||||
@@ -121,22 +121,22 @@ class FO_Table extends FO_LayoutObject {
|
||||
|
||||
class FO_TableCaption extends FO_Object {
|
||||
|
||||
private static $CHILDNODES = array(
|
||||
static $CHILDNODES = array(
|
||||
'FO_Block',
|
||||
'FO_BlockContainer',
|
||||
'FO_ListBlock'
|
||||
);
|
||||
|
||||
public function parse(DOMNode $node) {
|
||||
function parse(DOMNode $node) {
|
||||
$this->processChildNodes($node, self::$CHILDNODES);
|
||||
}
|
||||
}
|
||||
|
||||
class FO_TableColumn extends FO_Object {
|
||||
|
||||
private static $CHILDNODES = array();
|
||||
static $CHILDNODES = array();
|
||||
|
||||
public function parse(DOMNode $node) {
|
||||
function parse(DOMNode $node) {
|
||||
$width = $this->getSizeAttribute($node, "column-width");
|
||||
//calc internal width
|
||||
$this->setContext("width", $width);
|
||||
@@ -146,24 +146,24 @@ class FO_TableColumn extends FO_Object {
|
||||
|
||||
class FO_TableRow extends FO_LayoutObject {
|
||||
|
||||
private $colIndex = 0;
|
||||
var $colIndex = 0;
|
||||
|
||||
private static $CHILDNODES = array(
|
||||
static $CHILDNODES = array(
|
||||
'FO_TableCell'
|
||||
);
|
||||
|
||||
protected function getChildNodes() {
|
||||
function getChildNodes() {
|
||||
return self::$CHILDNODES;
|
||||
}
|
||||
|
||||
protected function initFOObject(FO_Object $col) {
|
||||
function initFOObject(FO_Object $col) {
|
||||
if (!$col instanceof FO_TableCell) {
|
||||
return;
|
||||
}
|
||||
$col->setContext("column", $this->colIndex++);
|
||||
}
|
||||
|
||||
protected function postParse(FO_Object $obj) {
|
||||
function postParse(FO_Object $obj) {
|
||||
if ($obj instanceof FO_TableCell) {
|
||||
$this->setContext("x", $this->getContext("x")+
|
||||
$obj->getContext("width"));
|
||||
@@ -184,41 +184,41 @@ class FO_TableRow extends FO_LayoutObject {
|
||||
}
|
||||
|
||||
class FO_TableHeader extends FO_TableRow {
|
||||
|
||||
private static $CHILDNODES = array(
|
||||
//oesi - set to _1 to work with php4
|
||||
static $CHILDNODES_1 = array(
|
||||
'FO_TableCell',
|
||||
'FO_TableRow'
|
||||
);
|
||||
|
||||
protected function getChildNodes() {
|
||||
return self::$CHILDNODES;
|
||||
function getChildNodes() {
|
||||
return self::$CHILDNODES_1;
|
||||
}
|
||||
}
|
||||
|
||||
class FO_TableFooter extends FO_LayoutObject {
|
||||
|
||||
private static $CHILDNODES = array(
|
||||
static $CHILDNODES = array(
|
||||
'FO_TableCell',
|
||||
'FO_TableRow'
|
||||
);
|
||||
|
||||
protected function getChildNodes() {
|
||||
function getChildNodes() {
|
||||
return self::$CHILDNODES;
|
||||
}
|
||||
}
|
||||
|
||||
class FO_TableBody extends FO_LayoutObject {
|
||||
|
||||
private static $CHILDNODES = array(
|
||||
static $CHILDNODES = array(
|
||||
'FO_TableCell',
|
||||
'FO_TableRow'
|
||||
);
|
||||
|
||||
protected function getChildNodes() {
|
||||
function getChildNodes() {
|
||||
return self::$CHILDNODES;
|
||||
}
|
||||
|
||||
protected function postParse(FO_Object $obj) {
|
||||
function postParse(FO_Object $obj) {
|
||||
if ($obj instanceof FO_TableRow) {
|
||||
$this->setLocalContext("width", $obj->getContext("width"));
|
||||
$this->setLocalContext("height", $this->getContext("height")+
|
||||
@@ -231,7 +231,7 @@ class FO_TableBody extends FO_LayoutObject {
|
||||
|
||||
class FO_TableCell extends FO_LayoutObject {
|
||||
|
||||
private static $CHILDNODES = array(
|
||||
static $CHILDNODES = array(
|
||||
'FO_Block',
|
||||
'FO_BlockContainer',
|
||||
'FO_ListBlock',
|
||||
@@ -240,11 +240,11 @@ class FO_TableCell extends FO_LayoutObject {
|
||||
);
|
||||
|
||||
|
||||
protected function getChildNodes() {
|
||||
function getChildNodes() {
|
||||
return self::$CHILDNODES;
|
||||
}
|
||||
|
||||
public function parse(DOMNode $node) {
|
||||
function parse(DOMNode $node) {
|
||||
$col = $this->getContext("column");
|
||||
$width = $this->getContext("column-$col-width");
|
||||
$this->setLocalContext("width", $width);
|
||||
@@ -256,7 +256,7 @@ class FO_TableCell extends FO_LayoutObject {
|
||||
* Overlap borders that the total width isn't larger than the
|
||||
* specified
|
||||
*/
|
||||
protected function drawBordersAndBackground($pos) {
|
||||
function drawBordersAndBackground($pos) {
|
||||
list($x1, $y1, $width1, $height1) = $pos[0];
|
||||
list($x2, $y2, $width2, $height2) = $pos[1];
|
||||
$xd = ($x1-$x2)/2;
|
||||
@@ -267,7 +267,7 @@ class FO_TableCell extends FO_LayoutObject {
|
||||
$this->drawBorders($x2, $y2, $width2+$wd, $height2+$hd);
|
||||
}
|
||||
|
||||
protected function postParse(FO_Object $obj) {
|
||||
function postParse(FO_Object $obj) {
|
||||
$this->setLocalContext("height", $this->getContext("height")+
|
||||
$obj->getContext("height")+0.5); // oesi - add +0.5 for tablespace
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ require_once("svg_text.php");
|
||||
require_once("svg_path.php");
|
||||
|
||||
class XslFo2PDF {
|
||||
public function generatePdf($xml, $name="out.pdf", $dest='') {
|
||||
function generatePdf($xml, $name="out.pdf", $dest='') {
|
||||
$doc = DOMDocument::loadXML($xml);
|
||||
if ($doc === false) {
|
||||
echo "failed loading dom<br>";
|
||||
@@ -71,7 +71,7 @@ class XslFo2PDF {
|
||||
return true;
|
||||
}
|
||||
|
||||
private function initDefaults(FPDF $pdf, FO_Root $root) {
|
||||
function initDefaults(FPDF $pdf, FO_Root $root) {
|
||||
$pdf->SetFont('Arial','',14);
|
||||
$pdf->SetAutoPageBreak(true);
|
||||
$root->setContext("page-width", "21");
|
||||
@@ -79,7 +79,7 @@ class XslFo2PDF {
|
||||
}
|
||||
|
||||
class FO_Factory {
|
||||
private static $factory = array("fo:layout-master-set" => 'FO_LayoutMasterSet',
|
||||
static $factory = array("fo:layout-master-set" => 'FO_LayoutMasterSet',
|
||||
"fo:block" => 'FO_Block',
|
||||
"fo:page-sequence" => 'FO_PageSequence',
|
||||
"fo:flow" => 'FO_Flow',
|
||||
@@ -111,9 +111,9 @@ class FO_Factory {
|
||||
"svg:path" => 'SVG_Path'
|
||||
);
|
||||
|
||||
private static $names = NULL;
|
||||
static $names = NULL;
|
||||
|
||||
public static function createFOObject(DOMNode $node, FO_Container $container,
|
||||
static function createFOObject(DOMNode $node, FO_Container $container,
|
||||
FPDF $pdf, FO_Context &$context,
|
||||
$filter)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user