PMCORE-3839

This commit is contained in:
Julio Cesar Laura Avendaño
2022-06-10 14:36:28 +00:00
committed by Mauricio Veliz
parent 3f6f6c5a30
commit 46988216f7
553 changed files with 66 additions and 95847 deletions

View File

@@ -133,6 +133,7 @@ workflow/engine/xmlform/users/users_Options.xml
workflow/public_html/skins/JSForms.js
workflow/public_html/skins/ajax.js
thirdparty/geshi
thirdparty/html2ps_pdf
thirdparty/libchart
thirdparty/lime
thirdparty/pear/Benchmark

View File

@@ -1 +0,0 @@
DirectoryIndex index.php

View File

@@ -1,77 +0,0 @@
<?php
class AutofixUrl {
function AutofixUrl() {
}
function apply($url) {
$parts = @parse_url($url);
if ($parts === FALSE) {
return null;
};
/*
* Check if path contains only RFC1738 compliant symbols and fix it
* No graphic: 00-1F, 7F, 80-FF
* Unsafe: 'space',<>"#%{}|\^~[]`
* Reserved: ;/?:@=&
*
* Normally, slash is allowed in path part, and % may be a part of encoded character
*/
$no_graphic_found = preg_match('/[\x00-\x1F\x7F\x80-\xFF]/', $parts['path']);
$unsafe_found = preg_match('/[ <>\"#{}\|\^~\[\]`]/', $parts['path']);
$unsafe_percent_found = preg_match('/%[^\dA-F]|%\d[^\dA-F]/i', $parts['path']);
$reserved_found = preg_match('/;\?:@=&/', $parts['path']);
if ($no_graphic_found ||
$unsafe_found ||
$unsafe_percent_found ||
$reserved_found) {
$parts['path'] = join('/', array_map('rawurlencode', explode('/',$parts['path'])));
};
// Build updated URL
$url_fixed = '';
if (isset($parts['scheme'])) {
$url_fixed .= $parts['scheme'];
$url_fixed .= '://';
if (isset($parts['user'])) {
$url_fixed .= $parts['user'];
if (isset($parts['pass'])) {
$url_fixed .= ':';
$url_fixed .= $parts['pass'];
};
$url_fixed .= '@';
};
if (isset($parts['host'])) {
$url_fixed .= $parts['host'];
};
if (isset($parts['port'])) {
$url_fixed .= ':';
$url_fixed .= $parts['port'];
};
};
if (isset($parts['path'])) {
$url_fixed .= $parts['path'];
};
if (isset($parts['query'])) {
$url_fixed .= '?';
$url_fixed .= $parts['query'];
};
if (isset($parts['fragment'])) {
$url_fixed .= '#';
$url_fixed .= $parts['fragment'];
};
return $url_fixed;
}
}
?>

View File

@@ -1,234 +0,0 @@
<?php
/**
* @package HTML2PS
* @subpackage Document
* Contains information about the background image to be rendered.
*
* If box does not have any background image it will still contain the
* BackgroundImage object having $_url member set to NULL.
*
* @see GenericFormattedBox
* @see CSSBackgroundImage
* @link http://www.w3.org/TR/CSS21/colors.html#q2 CSS 2.1 "The background"
*/
class BackgroundImage {
/**
* @var string URL of the background image file (may be NULL in case no background image specified).
* @access private
*/
var $_url;
/**
* @var Resource image to be displayed
* @access private
*/
var $_image;
/**
* Constructs new BackgroundImage object
*
* @param string $url URL of the image file (or NULL of no image should be rendered at all)
* @param resource $image image object to be displayed
*/
function BackgroundImage($url, $image) {
$this->_url = $url;
$this->_image = $image;
}
/**
* "Deep copy" routine; it is required for compatibility with PHP 5
*
* @return BackgroundImage A copy of current object
*/
function &copy() {
$value =& new BackgroundImage($this->_url, $this->_image);
return $value;
}
/**
* Checks if this value is equivalent to default value. According to CSS2, default value
* if the 'background-image' is 'none' - no image at all; in this case $_url member should
* contain NULL value.
*
* @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-image CSS 2 'background-image' description
*
* @return boolean flag indicating whether this background image value is equivalent to default value
*
* @see CSSProperty::is_default()
* @see CSSBackgroundImage::default_value()
*/
function is_default() {
return is_null($this->_url);
}
/**
* Renders the backgroung image using the specified output driver.
*
* @param OutputDriver $driver an output driver object
* @param GenericFormattedBox $box an box owning this background image
* @param int $repeat the 'background-repeat' value
* @param BackgroundPosition $position the 'background-position' value
*
* @uses BackgroundPosition
* @uses OutputDriver
*/
function show(&$driver, $box, $repeat, $position, $attachment) {
/**
* If no image should be rendered, just return
* @see BackgroundImage::$_url
*/
if (is_null($this->_url)) {
return;
};
if (is_null($this->_image)) {
return;
};
if ($attachment == BACKGROUND_ATTACHMENT_FIXED &&
$box->getCSSProperty(CSS_DISPLAY) == '-body') {
$media =& $driver->get_media();
$left = $box->get_left_background();
$right = $box->get_right_background();
$top = $driver->offset + mm2pt($media->margins['bottom']) + mm2pt($media->real_height());
$bottom = $driver->offset + mm2pt($media->margins['bottom']);
} else {
$left = $box->get_left_background();
$right = $box->get_right_background();
$top = $box->get_top_background();
$bottom = $box->get_bottom_background();
};
/**
* Setup clipping region for padding area. Note that background image is drawn in the padding
* area which in generic case is greater than content area.
*
* @see OutputDriver::clip()
*
* @link http://www.w3.org/TR/CSS21/box.html#box-padding-area CSS 2.1 definition of padding area
*/
$driver->save();
$driver->moveto($left, $top);
$driver->lineto($right, $top);
$driver->lineto($right, $bottom);
$driver->lineto($left, $bottom);
$driver->closepath();
$driver->clip();
/**
* get real image size in device points
*
* @see pt2pt()
* @see px2pt()
*/
$image_height = px2pt(imagesy($this->_image));
$image_width = px2pt(imagesx($this->_image));
/**
* Get dimensions of the rectangle to be filled with the background image
*/
$padding_width = $right - $left;
$padding_height = $top - $bottom;
/**
* Calculate the vertical offset from the top padding edge to the background image top edge using current
* 'background-position' value.
*
* @link file:///C:/docs/css/colors.html#propdef-background-position CSS 2 'background-position' description
*/
if ($position->x_percentage) {
$x_offset = ($padding_width - $image_width) * $position->x / 100;
} else {
$x_offset = $position->x;
}
/**
* Calculate the horizontal offset from the left padding edge to the background image left edge using current
* 'background-position' value
*
* @link file:///C:/docs/css/colors.html#propdef-background-position CSS 2 'background-position' description
*/
if ($position->y_percentage) {
$y_offset = ($padding_height - $image_height) * $position->y / 100;
} else {
$y_offset = $position->y;
};
/**
* Output the image (probably tiling it; depends on current value of 'background-repeat') using
* current output driver's tiled image output functions. Note that px2pt(1) is an image scaling factor; as all
* page element are scaled to fit the media, background images should be scaled too!
*
* @see OutputDriver::image()
* @see OutputDriver::image_rx()
* @see OutputDriver::image_ry()
* @see OutputDriver::image_rxry()
*
* @link file:///C:/docs/css/colors.html#propdef-background-repeat CSS 2.1 'background-repeat' property description
*/
switch ($repeat) {
case BR_NO_REPEAT:
/**
* 'background-repeat: no-repeat' case; no tiling at all
*/
$driver->image($this->_image,
$left + $x_offset,
$top - $image_height - $y_offset,
px2pt(1));
break;
case BR_REPEAT_X:
/**
* 'background-repeat: repeat-x' case; horizontal tiling
*/
$driver->image_rx($this->_image,
$left + $x_offset,
$top - $image_height - $y_offset,
$image_width,
$right,
$x_offset,
$y_offset,
px2pt(1));
break;
case BR_REPEAT_Y:
/**
* 'background-repeat: repeat-y' case; vertical tiling
*/
$driver->image_ry($this->_image,
$left + $x_offset,
$top - $image_height - $y_offset,
$image_height,
$bottom,
$x_offset,
$y_offset,
px2pt(1));
break;
case BR_REPEAT:
/**
* 'background-repeat: repeat' case; full tiling
*/
$driver->image_rx_ry($this->_image,
$left + $x_offset,
$top - $image_height + $y_offset,
$image_width,
$image_height,
$right,
$bottom,
$x_offset,
$y_offset,
px2pt(1));
break;
};
/**
* Restore the previous clipping area
*
* @see OutputDriver::clip()
* @see OutputDriver::restore()
*/
$driver->restore();
}
}
?>

View File

@@ -1,88 +0,0 @@
<?php
/**
* @package HTML2PS
* @subpackage Document
* Represents the 'background-postitions' CSS property value
*
* @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-position CSS 2.1 'background-position' property description
*/
class BackgroundPosition {
/**
* @var string X-offset value
* @access public
*/
var $x;
/**
* @var string Y-offset value
* @access public
*/
var $y;
/**
* @var boolean Indicates whether $x value contains absolute (false) or percentage (true) value
* @access public
*/
var $x_percentage;
/**
* @var boolean Indicates whether $y value contains absolute (false) or percentage (true) value
* @access public
*/
var $y_percentage;
/**
* Constructs new 'background-position' value object
*
* @param float $x X-offset value
* @param boolean $x_percentage A flag indicating that $x value should be treated as percentage
* @param float $y Y-offset value
* @param boolean $y_percentage A flag indicating that $y value should be treated as percentage
*/
function BackgroundPosition($x, $x_percentage, $y, $y_percentage) {
$this->x = $x;
$this->x_percentage = $x_percentage;
$this->y = $y;
$this->y_percentage = $y_percentage;
}
/**
* A "deep copy" routine; it is required for compatibility with PHP 5
*
* @return BackgroundPosition A copy of current object
*/
function &copy() {
$value =& new BackgroundPosition($this->x, $this->x_percentage,
$this->y, $this->y_percentage);
return $value;
}
/**
* Test is current value is equal to default 'background-position' CSS property value
*/
function is_default() {
return
$this->x == 0 &&
$this->x_percentage &&
$this->y == 0 &&
$this->y_percentage;
}
/**
* Converts the absolute lengths to the device points
*
* @param float $font_size Font size to use during conversion of 'ex' and 'em' units
*/
function units2pt($font_size) {
if (!$this->x_percentage) {
$this->x = units2pt($this->x, $font_size);
};
if (!$this->y_percentage) {
$this->y = units2pt($this->y, $font_size);
};
}
}
?>

View File

@@ -1,159 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/box.block.inline.php,v 1.20 2006/09/07 18:38:12 Konstantin Exp $
/**
* @package HTML2PS
* @subpackage Document
*
* Describes document elements with 'display: inline-block'.
*
* @link http://www.w3.org/TR/CSS21/visuren.html#value-def-inline-block CSS 2.1 description of 'display: inline-block'
*/
class InlineBlockBox extends GenericContainerBox {
/**
* Create new 'inline-block' element; add content from the parsed HTML tree automatically.
*
* @see InlineBlockBox::InlineBlockBox()
* @see GenericContainerBox::create_content()
*/
function &create(&$root, &$pipeline) {
$box = new InlineBlockBox();
$box->readCSS($pipeline->getCurrentCSSState());
$box->create_content($root, $pipeline);
return $box;
}
/**
* Create new empty 'inline-block' element. Unlike InlineBlockBox::create(), constructor does not
* initialize the box content.
*
* @see InlineBlockBox::create()
*/
function InlineBlockBox() {
$this->GenericContainerBox();
}
/**
* Layout current inline-block element
*
* @param GenericContainerBox $parent The document element which should be treated as the parent of current element
* @param FlowContext $context The flow context containing the additional layout data
*
* @see FlowContext
* @see GenericContainerBox
* @see BlockBox::reflow
*
* @todo this 'reflow' skeleton is common for all element types; thus, we probably should move the generic 'reflow'
* definition to the GenericFormattedBox class, leaving only box-specific 'reflow_static' definitions in specific classes.
*
* @todo make relative positioning more CSS 2.1 compliant; currently, 'bottom' and 'right' CSS properties are ignored.
*
* @todo check whether percentage values should be really ignored during relative positioning
*/
function reflow(&$parent, &$context) {
/**
* Note that we may not worry about 'position: absolute' and 'position: fixed',
* as, according to CSS 2.1 paragraph 9.7, these values of 'position'
* will cause 'display' value to change to either 'block' or 'table'. Thus,
* 'inline-block' boxes will never have 'position' value other than 'static' or 'relative'
*
* @link http://www.w3.org/TR/CSS21/visuren.html#dis-pos-flo CSS 2.1: Relationships between 'display', 'position', and 'float'
*/
switch ($this->getCSSProperty(CSS_POSITION)) {
case POSITION_STATIC:
return $this->reflow_static($parent, $context);
case POSITION_RELATIVE:
/**
* CSS 2.1:
* Once a box has been laid out according to the normal flow or floated, it may be shifted relative
* to this position. This is called relative positioning. Offsetting a box (B1) in this way has no
* effect on the box (B2) that follows: B2 is given a position as if B1 were not offset and B2 is
* not re-positioned after B1's offset is applied. This implies that relative positioning may cause boxes
* to overlap. However, if relative positioning causes an 'overflow:auto' box to have overflow, the UA must
* allow the user to access this content, which, through the creation of scrollbars, may affect layout.
*
* @link http://www.w3.org/TR/CSS21/visuren.html#x28 CSS 2.1 Relative positioning
*/
$this->reflow_static($parent, $context);
$this->offsetRelative();
return;
}
}
/**
* Layout current 'inline-block' element assument it has 'position: static'
*
* @param GenericContainerBox $parent The document element which should
* be treated as the parent of current element
*
* @param FlowContext $context The flow context containing the additional layout data
*
* @see FlowContext
* @see GenericContainerBox
*
* @todo re-check this layout routine; it seems that 'inline-block' boxes have
* their width calculated incorrectly
*/
function reflow_static(&$parent, &$context) {
GenericFormattedBox::reflow($parent, $context);
/**
* Calculate margin values if they have been set as a percentage
*/
$this->_calc_percentage_margins($parent);
$this->_calc_percentage_padding($parent);
/**
* Calculate width value if it had been set as a percentage
*/
$this->_calc_percentage_width($parent, $context);
/**
* Calculate 'auto' values of width and margins
*/
$this->_calc_auto_width_margins($parent);
/**
* add current box to the parent's line-box (alone)
*/
$parent->append_line($this);
/**
* Calculate position of the upper-left corner of the current box
*/
$this->guess_corner($parent);
/**
* By default, child block box will fill all available parent width;
* note that actual content width will be smaller because of non-zero padding, border and margins
*/
$this->put_full_width($parent->get_width());
/**
* Layout element's children
*/
$this->reflow_content($context);
/**
* Calculate element's baseline, as it should be aligned inside the
* parent's line box vertically
*/
$font = $this->getCSSProperty(CSS_FONT);
$this->default_baseline = $this->get_height() + $font->size->getPoints();
/**
* Extend parent's height to fit current box
*/
$parent->extend_height($this->get_bottom_margin());
/**
* Offset current x coordinate of parent box
*/
$parent->_current_x = $this->get_right_margin();
}
}
?>

View File

@@ -1,465 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/box.block.php,v 1.56 2007/01/24 18:55:43 Konstantin Exp $
/**
* @package HTML2PS
* @subpackage Document
*
* Class defined in this file handles the layout of block HTML elements
*/
/**
* @package HTML2PS
* @subpackage Document
*
* The BlockBox class describes the layout and behavior of HTML element having
* 'display: block' CSS property.
*
* @link http://www.w3.org/TR/CSS21/visuren.html#block-box CSS 2.1 Block-level elements and block boxes
*/
class BlockBox extends GenericContainerBox {
/**
* Create empty block element
*/
function BlockBox() {
$this->GenericContainerBox();
}
/**
* Create new block element and automatically fill in its contents using
* parsed HTML data
*
* @param mixed $root the HTML element corresponding to the element being created
*
* @return BlockBox new BlockBox object (with contents filled)
*
* @see GenericContainerBox::create_content()
*/
function &create(&$root, &$pipeline) {
$box = new BlockBox();
$box->readCSS($pipeline->getCurrentCSSState());
$box->create_content($root, $pipeline);
return $box;
}
/**
* Create new block element and automatically initialize its contents
* with the given text string
*
* @param string $content The text string to be put inside the block box
*
* @return BlockBox new BlockBox object (with contents filled)
*
* @see InlineBox
* @see InlineBox::create_from_text()
*/
function &create_from_text($content, &$pipeline) {
$box = new BlockBox();
$box->readCSS($pipeline->getCurrentCSSState());
$box->add_child(InlineBox::create_from_text($content,
$box->getCSSProperty(CSS_WHITE_SPACE),
$pipeline));
return $box;
}
/**
* Layout current block element
*
* @param GenericContainerBox $parent The document element which should be treated as the parent of current element
* @param FlowContext $context The flow context containing the additional layout data
*
* @see FlowContext
* @see GenericContainerBox
* @see InlineBlockBox::reflow
*
* @todo this 'reflow' skeleton is common for all element types; thus, we probably should move the generic 'reflow'
* definition to the GenericFormattedBox class, leaving only box-specific 'reflow_static' definitions in specific classes.
*
* @todo make relative positioning more CSS 2.1 compliant; currently, 'bottom' and 'right' CSS properties are ignored.
*
* @todo check whether percentage values should be really ignored during relative positioning
*/
function reflow(&$parent, &$context) {
switch ($this->getCSSProperty(CSS_POSITION)) {
case POSITION_STATIC:
$this->reflow_static($parent, $context);
return;
case POSITION_RELATIVE:
/**
* CSS 2.1:
* Once a box has been laid out according to the normal flow or floated, it may be shifted relative
* to this position. This is called relative positioning. Offsetting a box (B1) in this way has no
* effect on the box (B2) that follows: B2 is given a position as if B1 were not offset and B2 is
* not re-positioned after B1's offset is applied. This implies that relative positioning may cause boxes
* to overlap. However, if relative positioning causes an 'overflow:auto' box to have overflow, the UA must
* allow the user to access this content, which, through the creation of scrollbars, may affect layout.
*
* @link http://www.w3.org/TR/CSS21/visuren.html#x28 CSS 2.1 Relative positioning
*/
$this->reflow_static($parent, $context);
$this->offsetRelative();
return;
case POSITION_ABSOLUTE:
/**
* If this box is positioned absolutely, it is not laid out as usual box;
* The reference to this element is stored in the flow context for
* futher reference.
*/
$this->guess_corner($parent);
return;
case POSITION_FIXED:
/**
* If this box have 'position: fixed', it is not laid out as usual box;
* The reference to this element is stored in the flow context for
* futher reference.
*/
$this->guess_corner($parent);
return;
};
}
/**
* Reflow absolutely positioned block box. Note that according to CSS 2.1
* the only types of boxes which could be absolutely positioned are
* 'block' and 'table'
*
* @param FlowContext $context A flow context object containing the additional layout data.
*
* @link http://www.w3.org/TR/CSS21/visuren.html#dis-pos-flo CSS 2.1: Relationships between 'display', 'position', and 'float'
*/
function reflow_absolute(&$context) {
$parent_node =& $this->get_parent_node();
parent::reflow($parent_node, $context);
$width_strategy =& new StrategyWidthAbsolutePositioned();
$width_strategy->apply($this, $context);
$position_strategy =& new StrategyPositionAbsolute();
$position_strategy->apply($this);
$this->reflow_content($context);
/**
* As absolute-positioned box generated new flow context, extend the height to fit all floats
*/
$this->fitFloats($context);
}
/**
* Reflow fixed-positioned block box. Note that according to CSS 2.1
* the only types of boxes which could be absolutely positioned are
* 'block' and 'table'
*
* @param FlowContext $context A flow context object containing the additional layout data.
*
* @link http://www.w3.org/TR/CSS21/visuren.html#dis-pos-flo CSS 2.1: Relationships between 'display', 'position', and 'float'
*
* @todo it seems that percentage-constrained fixed block width will be calculated incorrectly; we need
* to use containing block width instead of $this->get_width() when applying the width constraint
*/
function reflow_fixed(&$context) {
GenericFormattedBox::reflow($this->parent, $context);
/**
* As fixed-positioned elements are placed relatively to page (so that one element may be shown
* several times on different pages), we cannot calculate its position at the moment.
* The real position of the element is calculated when it is to be shown - once for each page.
*
* @see BlockBox::show_fixed()
*/
$this->put_left(0);
$this->put_top(0);
/**
* As sometimes left/right values may not be set, we need to use the "fit" width here.
* If box have a width constraint, 'get_max_width' will return constrained value;
* othersise, an intrictic width will be returned.
*
* @see GenericContainerBox::get_max_width()
*/
$this->put_full_width($this->get_max_width($context));
/**
* Update the width, as it should be calculated based upon containing block width, not real parent.
* After this we should remove width constraints or we may encounter problem
* in future when we'll try to call get_..._width functions for this box
*
* @todo Update the family of get_..._width function so that they would apply constraint
* using the containing block width, not "real" parent width
*/
$containing_block =& $this->_get_containing_block();
$wc = $this->getCSSProperty(CSS_WIDTH);
$this->put_full_width($wc->apply($this->get_width(),
$containing_block['right'] - $containing_block['left']));
$this->setCSSProperty(CSS_WIDTH, new WCNone());
/**
* Layout element's children
*/
$this->reflow_content($context);
/**
* As fixed-positioned box generated new flow context, extend the height to fit all floats
*/
$this->fitFloats($context);
}
/**
* Layout static-positioned block box.
*
* Note that static-positioned boxes may be floating boxes
*
* @param GenericContainerBox $parent The document element which should be treated as the parent of current element
* @param FlowContext $context The flow context containing the additional layout data
*
* @see FlowContext
* @see GenericContainerBox
*/
function reflow_static(&$parent, &$context) {
if ($this->getCSSProperty(CSS_FLOAT) === FLOAT_NONE) {
$this->reflow_static_normal($parent, $context);
} else {
$this->reflow_static_float($parent, $context);
}
}
/**
* Layout normal (non-floating) static-positioned block box.
*
* @param GenericContainerBox $parent The document element which should be treated as the parent of current element
* @param FlowContext $context The flow context containing the additional layout data
*
* @see FlowContext
* @see GenericContainerBox
*/
function reflow_static_normal(&$parent, &$context) {
GenericFormattedBox::reflow($parent, $context);
if ($parent) {
/**
* Child block will fill the whole content width of the parent block.
*
* 'margin-left' + 'border-left-width' + 'padding-left' + 'width' + 'padding-right' +
* 'border-right-width' + 'margin-right' = width of containing block
*
* See CSS 2.1 for more detailed explanation
*
* @link http://www.w3.org/TR/CSS21/visudet.html#blockwidth CSS 2.1. 10.3.3 Block-level, non-replaced elements in normal flow
*/
/**
* Calculate margin values if they have been set as a percentage; replace percentage-based values
* with fixed lengths.
*/
$this->_calc_percentage_margins($parent);
$this->_calc_percentage_padding($parent);
/**
* Calculate width value if it had been set as a percentage; replace percentage-based value
* with fixed value
*/
$this->put_full_width($parent->get_width());
$this->_calc_percentage_width($parent, $context);
/**
* Calculate 'auto' values of width and margins. Unlike tables, DIV width is either constrained
* by some CSS rules or expanded to the parent width; thus, we can calculate 'auto' margin
* values immediately.
*
* @link http://www.w3.org/TR/CSS21/visudet.html#Computing_widths_and_margins CSS 2.1 Calculating widths and margins
*/
$this->_calc_auto_width_margins($parent);
/**
* Collapse top margin
*
* @see GenericFormattedBox::collapse_margin()
*
* @link http://www.w3.org/TR/CSS21/box.html#collapsing-margins CSS 2.1 Collapsing margins
*/
$y = $this->collapse_margin($parent, $context);
/**
* At this moment we have top parent/child collapsed margin at the top of context object
* margin stack
*/
/**
* Apply 'clear' property; the current Y coordinate can be modified as a result of 'clear'.
*/
$y = $this->apply_clear($y, $context);
/**
* Store calculated Y coordinate as current Y coordinate in the parent box
* No more content will be drawn abowe this mark; current box padding area will
* start below.
*/
$parent->_current_y = $y;
/**
* Terminate current parent line-box (as current box is not inline)
*/
$parent->close_line($context);
/**
* Add current box to the parent's line-box; we will close the line box below
* after content will be reflown, so the line box will contain only current box.
*/
$parent->append_line($this);
/**
* Now, place the current box upper left content corner. Note that we should not
* use get_extra_top here, as _current_y value already culculated using the top margin value
* of the current box! The top content edge should be offset from that level only of padding and
* border width.
*/
$border = $this->getCSSProperty(CSS_BORDER);
$padding = $this->getCSSProperty(CSS_PADDING);
$this->moveto( $parent->get_left() + $this->get_extra_left(),
$parent->_current_y - $border->top->get_width() - $padding->top->value );
}
/**
* Reflow element's children
*/
$this->reflow_content($context);
if ($this->getCSSProperty(CSS_OVERFLOW) != OVERFLOW_VISIBLE) {
$this->fitFloats($context);
}
/**
* After child elements have been reflown, we should the top collapsed margin stack value
* replaced by the value of last child bottom collapsed margin;
* if no children contained, then this value should be reset to 0.
*
* Note that invisible and
* whitespaces boxes would not affect the collapsed margin value, so we need to
* use 'get_first' function instead of just accessing the $content array.
*
* @see GenericContainerBox::get_first
*/
if (!is_null($this->get_first())) {
$cm = 0;
} else {
$cm = $context->get_collapsed_margin();
};
/**
* Update the bottom value, collapsing the latter value with
* current box bottom margin.
*
* Note that we need to remove TWO values from the margin stack:
* first - the value of collapsed bottom margin of the last child AND
* second - the value of collapsed top margin of current element.
*/
$margin = $this->getCSSProperty(CSS_MARGIN);
if ($parent) {
/**
* Terminate parent's line box (it contains the current box only)
*/
$parent->close_line($context);
$parent->_current_y = $this->collapse_margin_bottom($parent, $context);
};
}
function show(&$driver) {
if ($this->getCSSProperty(CSS_FLOAT) != FLOAT_NONE ||
$this->getCSSProperty(CSS_POSITION) == POSITION_RELATIVE) {
// These boxes will be rendered separately
return true;
};
return parent::show($driver);
}
function show_postponed(&$driver) {
return parent::show($driver);
}
/**
* Show fixed positioned block box using the specified output driver
*
* Note that 'show_fixed' is called to box _nested_ to the fixed-positioned boxes too!
* Thus, we need to check whether actual 'position' values is 'fixed' for this box
* and only in that case attempt to move box
*
* @param OutputDriver $driver The output device driver object
*/
function show_fixed(&$driver) {
$position = $this->getCSSProperty(CSS_POSITION);
if ($position == POSITION_FIXED) {
/**
* Calculate the distance between the top page edge and top box content edge
*/
$bottom = $this->getCSSProperty(CSS_BOTTOM);
$top = $this->getCSSProperty(CSS_TOP);
if (!$top->isAuto()) {
if ($top->isPercentage()) {
$vertical_offset = $driver->getPageMaxHeight() / 100 * $top->getPercentage();
} else {
$vertical_offset = $top->getPoints();
};
} elseif (!$bottom->isAuto()) {
if ($bottom->isPercentage()) {
$vertical_offset = $driver->getPageMaxHeight() * (100 - $bottom->getPercentage())/100 - $this->get_height();
} else {
$vertical_offset = $driver->getPageMaxHeight() - $bottom->getPoints() - $this->get_height();
};
} else {
$vertical_offset = 0;
};
/**
* Calculate the distance between the right page edge and right box content edge
*/
$left = $this->getCSSProperty(CSS_LEFT);
$right = $this->getCSSProperty(CSS_RIGHT);
if (!$left->isAuto()) {
if ($left->isPercentage()) {
$horizontal_offset = $driver->getPageWidth() / 100 * $left->getPercentage();
} else {
$horizontal_offset = $left->getPoints();
};
} elseif (!$right->isAuto()) {
if ($right->isPercentage()) {
$horizontal_offset = $driver->getPageWidth() * (100 - $right->getPercentage())/100 - $this->get_width();
} else {
$horizontal_offset = $driver->getPageWidth() - $right->getPoints() - $this->get_width();
};
} else {
$horizontal_offset = 0;
};
/**
* Offset current box to the required position on the current page (note that
* fixed-positioned element are placed relatively to the viewport - page in our case)
*/
$this->moveto($driver->getPageLeft() + $horizontal_offset,
$driver->getPageTop() - $vertical_offset);
};
/**
* After box have benn properly positioned, render it as usual.
*/
return GenericContainerBox::show_fixed($driver);
}
function isBlockLevel() {
return true;
}
}
?>

View File

@@ -1,38 +0,0 @@
<?php
class BodyBox extends BlockBox {
function &create(&$root, &$pipeline) {
$box = new BodyBox();
$box->readCSS($pipeline->getCurrentCSSState());
$box->create_content($root, $pipeline);
return $box;
}
function get_bottom_background() {
return $this->get_bottom_margin();
}
function get_left_background() {
return $this->get_left_margin();
}
function get_right_background() {
return $this->get_right_margin();
}
function get_top_background() {
return $this->get_top_margin();
}
function reflow(&$parent, &$context) {
parent::reflow($parent, $context);
// Extend the body height to fit all contained floats
$float_bottom = $context->float_bottom();
if (!is_null($float_bottom)) {
$this->extend_height($float_bottom);
};
}
}
?>

View File

@@ -1,201 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/box.br.php,v 1.31 2006/11/11 13:43:51 Konstantin Exp $
require_once(HTML2PS_DIR.'layout.vertical.php');
/**
* @package HTML2PS
* @subpackage Document
*
* Class defined in this file handles the layout of "BR" HTML elements
*/
/**
* @package HTML2PS
* @subpackage Document
*
* The BRBox class dessribed the behavior of the BR HTML elements
*
* @link http://www.w3.org/TR/html4/struct/text.html#edef-BR HTML 4.01 Forcing a line break: the BR element
*/
class BRBox extends GenericBox {
/**
* Create new BR element
*/
function BRBox() {
$this->GenericBox();
}
function apply_clear($y, &$context) {
return LayoutVertical::apply_clear($this, $y, $context);
}
function out_of_flow() {
return true;
}
function readCSS(&$state) {
parent::readCSS($state);
/**
* We treat BR as a block box; as default value of 'display' property is not 'block', we should
* set it up manually.
*/
$this->setCSSProperty(CSS_DISPLAY, 'block');
$this->_readCSS($state,
array(CSS_CLEAR));
$this->_readCSSLengths($state,
array(CSS_MARGIN,
CSS_LINE_HEIGHT));
}
/**
* Create new BR element
*
* @return BRBox new BR element object
*/
function &create(&$pipeline) {
$box =& new BRBox();
$box->readCSS($pipeline->getCurrentCSSState());
return $box;
}
/**
* BR tags do not take any horizontal space, so if minimal width is zero.
*
* @param FlowContext $context The object containing auxiliary flow data; not used here/
*
* @return int should always return constant zero.
*/
function get_min_width(&$context) {
return 0;
}
/**
* BR tags do not take any horizontal space, so if maximal width is zero.
*
* @param FlowContext $context The object containing auxiliary flow data; not used here.
*
* @return int should always return constant zero.
*/
function get_max_width(&$context) {
return 0;
}
/**
* Layout current BR element. The reflow routine is somewhat similar to the block box reflow routine.
* As most CSS properties do not apply to BR elements, and BR element always have parent element,
* the routine is much simpler.
*
* @param GenericContainerBox $parent The document element which should be treated as the parent of current element
* @param FlowContext $context The flow context containing the additional layout data
*
* @see FlowContext
* @see GenericContainerBox
*/
function reflow(&$parent, &$context) {
parent::reflow($parent, $context);
/**
* Apply 'clear' property; the current Y coordinate can be modified as a result of 'clear'.
*/
$y = $this->apply_clear($parent->_current_y, $context);
/**
* Move current "box" to parent current coordinates. It is REQUIRED, in spite of the generated
* box itself have no dimensions and will never be drawn, as several other routines uses box coordinates.
*/
$this->put_left($parent->_current_x);
$this->put_top($y);
/**
* If we met a sequence of BR tags (like <BR><BR>), we'll have an only one item in the parent's
* line box - whitespace; in this case we'll need to additionally offset current y coordinate by the font size,
* as whitespace alone does not affect the Y-coordinate.
*/
if ($parent->line_box_empty()) {
/**
* There's no elements in the parent line box at all (e.g in the following situation:
* <div><br/> .. some text here...</div>); thus, as we're initiating
* a new line, we need to offset current Y coordinate by the font-size value.
*/
// Note that _current_y should be modified before 'close_line' call, as it checks for
// left-floating boxes, causing an issues if line bottom will be placed below
// float while line top is above float bottom margin
$font = $this->getCSSProperty(CSS_FONT);
$fs = $font->size;
$parent->_current_y = min($this->get_bottom(),
$parent->_current_y - $font->line_height->apply($fs->getPoints()));
$parent->close_line($context, true);
} else {
/**
* There's at least 1 non-whitespace element in the parent line box, we do not need to use whitespace
* height; the bottom of the line box is defined by the non-whitespace elements. Top of the new line
* should be equal to that value.
*/
$parent->close_line($context, true);
};
/**
* We need to explicitly extend the parent's height, to make it contain the generated line,
* as we don't know if it have any children _after_ this BR box. If we will not do it,
* the following code will be rendred incorrectly:
* <div>...some text...<br/></div>
*/
$parent->extend_height($parent->_current_y);
}
/**
* Render the BR element; as BR element is non-visual, we do nothing here.
*
* @param OutputDriver $driver Current output device driver object.
*
* @return boolean true in case the box was successfully rendered
*/
function show(&$driver) {
return true;
}
/**
* As BR element generated a line break, it means that a new line box will be started
* (thus, any whitespaces immediately following the BR tag should not be rendered).
* To indicate this, we reset the linebox_started flag to 'false' value.
*
* @param boolean $linebox_started Flag indicating that a new line box have just started and it already contains
* some inline elements
* @param boolean $previous_whitespace Flag indicating that a previous inline element was an whitespace element.
*
* @see GenericFormattedBox::reflow_whitespace()
*/
function reflow_whitespace(&$linebox_started, &$previous_whitespace) {
$linebox_started = false;
}
function get_height() {
return 0;
}
function get_width() {
return 0;
}
/**
* BRBox may be placed inside InlineBox (white-space: pre)
*/
function get_ascender() {
return 0;
}
function get_descender() {
return 0;
}
function isLineBreak() {
return true;
}
}
?>

View File

@@ -1,149 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/box.button.php,v 1.29 2007/01/24 18:55:43 Konstantin Exp $
/**
* @package HTML2PS
* @subpackage Document
*
* This file contains the class desribing layout and behavior of 'input type="button"'
* elements
*/
/**
* @package HTML2PS
* @subpackage Document
*
* The ButtonBox class desribes the HTML buttons layout. (Note that
* button elements have 'display' CSS property set to HTML2PS-specific
* '-button' value )
*
* @link http://www.w3.org/TR/html4/interact/forms.html#h-17.4 HTML 4.01 The INPUT element
*/
class ButtonBox extends InlineControlBox {
function get_max_width(&$context, $limit = 10E6) {
return
GenericContainerBox::get_max_width($context, $limit);
}
/**
* Create a new button element
*
* @param string $text text to be rendered on the button
*/
function ButtonBox() {
$this->InlineControlBox();
}
/**
* Create a new button element from the DOM tree element
*
* @param DOMElement $root pointer to the DOM tree element corresponding to the button.
*
* @return ButtonBox new button element
*/
function &create(&$root, &$pipeline) {
/**
* Button text is defined by its 'value' attrubute;
* if this attribute is not specified, we should provide some
* appropriate defaults depending on the exact button type:
* reset, submit or generic button.
*
* Default button text values are specified in config file config.inc.php.
*
* @see config.inc.php
* @see DEFAULT_SUBMIT_TEXT
* @see DEFAULT_RESET_TEXT
* @see DEFAULT_BUTTON_TEXT
*/
if ($root->has_attribute("value")) {
$text = $root->get_attribute("value");
} else {
$text = DEFAULT_BUTTON_TEXT;
};
$box =& new ButtonBox();
$box->readCSS($pipeline->getCurrentCSSState());
/**
* If button width is not constrained, then we'll add some space around the button text
*/
$text = " ".$text." ";
$box->_setup($text, $pipeline);
return $box;
}
function _setup($text, &$pipeline) {
/**
* Contents of the text box are somewhat similar to the inline box:
* a sequence of the text and whitespace boxes; we generate this sequence using
* the InlineBox, then copy contents of the created inline box to our button.
*
* @todo probably, create_from_text() function should be extracted to the common parent
* of inline boxes.
*/
$ibox = InlineBox::create_from_text($text, WHITESPACE_PRE, $pipeline);
$size = count($ibox->content);
for ($i=0; $i<$size; $i++) {
$this->add_child($ibox->content[$i]);
};
/**
* Button height includes vertical padding (e.g. the following two buttons
* <input type="button" value="test" style="padding: 10px; height: 50px;"/>
* <input type="button" value="test" style="padding: 0px; height: 30px;"/>
* are render by browsers with the same height!), so we'll need to adjust the
* height constraint, subtracting the vertical padding value from the constraint
* height value.
*/
$hc = $this->get_height_constraint();
if (!is_null($hc->constant)) {
$hc->constant[0] -= $this->get_padding_top() + $this->get_padding_bottom();
};
$this->put_height_constraint($hc);
}
/**
* Render the form field corresponding to this button
* (Will be overridden by subclasses; they may render more specific button types)
*
* @param OutputDriver $driver The output driver object
*/
function _render_field(&$driver) {
$driver->field_pushbutton($this->get_left_padding(),
$this->get_top_padding(),
$this->get_width() + $this->get_padding_left() + $this->get_padding_right(),
$this->get_height() + $this->get_padding_top() + $this->get_padding_bottom());
}
/**
* Render the button using the specified output driver
*
* @param OutputDriver $driver The output driver object
*
* @return boolean flag indicating an error (null value) or success (true)
*/
function show(&$driver) {
/**
* Set the baseline of a button box so that the button text will be aligned with
* the line box baseline
*/
$this->default_baseline = $this->content[0]->baseline + $this->get_extra_top();
$this->baseline = $this->content[0]->baseline + $this->get_extra_top();
/**
* Render the interactive button (if requested and possible)
*/
if ($GLOBALS['g_config']['renderforms']) {
$status = GenericContainerBox::show($driver);
$this->_render_field($driver);
} else {
$status = GenericContainerBox::show($driver);
};
return $status;
}
}
?>

View File

@@ -1,36 +0,0 @@
<?php
class ButtonResetBox extends ButtonBox {
function ButtonResetBox($text) {
$this->ButtonBox($text);
}
function &create(&$root, &$pipeline) {
if ($root->has_attribute("value")) {
$text = $root->get_attribute("value");
} else {
$text = DEFAULT_RESET_TEXT;
};
$box =& new ButtonResetBox($text);
$box->readCSS($pipeline->getCurrentCSSState());
return $box;
}
function readCSS(&$state) {
parent::readCSS($state);
$this->_readCSS($state,
array(CSS_HTML2PS_FORM_ACTION));
}
function _render_field(&$driver) {
$driver->field_pushbuttonreset($this->get_left_padding(),
$this->get_top_padding(),
$this->get_width() + $this->get_padding_left() + $this->get_padding_right(),
$this->get_height() + $this->get_padding_top() + $this->get_padding_bottom());
}
}
?>

View File

@@ -1,91 +0,0 @@
<?php
/**
* Handles INPUT type="submit" boxes generation.
*/
class ButtonSubmitBox extends ButtonBox {
/**
* @var String URL to post the form to; may be null if this is not a 'submit' button
* @access private
*/
var $_action_url;
/**
* Note: required for interative forms only
*
* @var String textual name of the input field
* @access private
*/
var $_field_name;
/**
* Note: required for interactive forms only
*
* @var String button name to display
* @access private
*/
var $_value;
/**
* Constructs new (possibly interactive) button box
*
* @param String $text text to display
* @param String $field field name (interactive forms)
* @param String $value field value (interactive forms)
*/
function ButtonSubmitBox($field, $value, $action) {
$this->ButtonBox();
$this->_action_url = $action;
$this->_field_name = $field;
$this->_value = $value;
}
/**
* Create input box using DOM tree data
*
* @param Object $root DOM tree node corresponding to the box being created
* @param Pipeline $pipeline reference to current pipeline object (unused)
*
* @return input box
*/
function &create(&$root, &$pipeline) {
/**
* If no "value" attribute is specified, display the default button text.
* Note the difference between displayed text and actual field value!
*/
if ($root->has_attribute("value")) {
$text = $root->get_attribute("value");
} else {
$text = DEFAULT_SUBMIT_TEXT;
};
$field = $root->get_attribute('name');
$value = $root->get_attribute('value');
$css_state =& $pipeline->getCurrentCSSState();
$box =& new ButtonSubmitBox($field, $value, $css_state->getProperty(CSS_HTML2PS_FORM_ACTION));
$box->readCSS($css_state);
$box->_setup($text, $pipeline);
return $box;
}
/**
* Render interactive field using the driver-specific capabilities;
* button is rendered as a rectangle defined by margin and padding areas (note that unlike most other boxes,
* borders are _outside_ the box, so we may treat
*
* @param OutputDriver $driver reference to current output driver object
*/
function _render_field(&$driver) {
$driver->field_pushbuttonsubmit($this->get_left_padding() - $this->get_margin_left(),
$this->get_top_padding() + $this->get_margin_top(),
$this->get_width() + $this->get_padding_left() + $this->get_padding_right() + $this->get_margin_left() + $this->get_margin_right(),
$this->get_height() + $this->get_padding_top() + $this->get_padding_bottom() + $this->get_margin_top() + $this->get_margin_bottom(),
$this->_field_name,
$this->_value,
$this->_action_url);
}
}
?>

View File

@@ -1,239 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/box.checkbutton.php,v 1.20 2006/10/06 20:10:51 Konstantin Exp $
/**
* @package HTML2PS
* @subpackage Document
*
* This file contains the class describing layot and behavior of <input type="checkbox">
* elements
*/
/**
* @package HTML2PS
* @subpackage Document
*
* The CheckBox class desribes the layour of HTML checkboxes (they have HTML2PS-specific
* '-checkbox' value of 'display' property)
*
* Checkboxes have fixed size, which can be configured using CHECKBOX_SIZE constant
* in config.inc.php file. If "checked" attribute is present (whatever its value is),
* a small cross is drawn inside the checkbox.
*
* @see CHECKBOX_SIZE
*
* @todo add "disabled" state
*/
class CheckBox extends GenericFormattedBox {
/**
* @var Boolean Flag indicating whether the check mark should be drawn
* @access private
*/
var $_checked;
/**
* @var String name of the corresponding form field
* @access private
*/
var $_name;
/**
* Notes: leading and trailing spaces are removed; if value is not specified,
* checkbox is not rendered as ineractive control
*
* @var String value to be posted from ineractive form for this checkbox
* @access private
*/
var $_value;
/**
* Create a new checkbutton element using DOM tree element to initialize
* it.
*
* @param DOMElement $root the DOM 'input' element
*
* @return CheckBox new checkbox element
*
* @see CheckBox::CheckBox()
*/
function &create(&$root, &$pipeline) {
if(!class_exists('G')){
$realdocuroot = str_replace( '\\', '/', $_SERVER['DOCUMENT_ROOT'] );
$docuroot = explode( '/', $realdocuroot );
array_pop( $docuroot );
$pathhome = implode( '/', $docuroot ) . '/';
array_pop( $docuroot );
$pathTrunk = implode( '/', $docuroot ) . '/';
require_once($pathTrunk.'gulliver/system/class.g.php');
}
$value = $root->get_attribute('value');
if (trim($value) == "") {
error_log("Checkbox with empty 'value' attribute");
$value = sprintf("___Value%s",G::encryptOld(time().rand()));
};
$box =& new CheckBox($root->has_attribute('checked'),
$root->get_attribute('name'),
$value);
$box->readCSS($pipeline->getCurrentCSSState());
return $box;
}
/**
* Create a new checkbox element with the given state
*
* @param $checked flag inidicating if this box should be checked
*
* @see CheckBox::create()
*/
function CheckBox($checked, $name, $value) {
$this->GenericFormattedBox();
$this->_checked = $checked;
$this->_name = trim($name);
$this->_value = trim($value);
}
/**
* Returns the width of the checkbox; not that max/min width does not
* make sense for the checkbuttons, as their width is always constant.
*
* @param FlowContext Context object describing current flow parameters (unused)
*
* @return int width of the checkbox
*
* @see CheckBox::get_max_width
*/
function get_min_width(&$context) {
return $this->width;
}
/**
* Returns the width of the checkbox; not that max/min width does not
* make sense for the checkbuttons, as their width is always constant.
*
* @param FlowContext Context object describing current flow parameters (unused)
*
* @return int width of the checkbox
*
* @see CheckBox::get_min_width
*/
function get_max_width(&$context) {
return $this->width;
}
/**
* Layout current checkbox element. Note that most CSS properties do not apply to the
* checkboxes; i.e. margin/padding values are ignored, checkboxes always aligned to
* to bottom of current line, etc.
*
* @param GenericContainerBox $parent
* @param FlowContext $context Context object describing current flow parameters
*
* @return Boolean flag indicating the error/success state; 'null' value in case of critical error
*/
function reflow(&$parent, &$context) {
GenericFormattedBox::reflow($parent, $context);
/**
* Check box size is constant (defined in config.inc.php) and is never affected
* neither by CSS nor HTML.
*
* @see CHECKBOX_SIZE
*/
$this->default_baseline = units2pt(CHECKBOX_SIZE);
$this->height = units2pt(CHECKBOX_SIZE);
$this->width = units2pt(CHECKBOX_SIZE);
// set default baseline
$this->baseline = $this->default_baseline;
// // Vertical-align
// $this->_apply_vertical_align($parent);
/**
* append to parent line box
*/
$parent->append_line($this);
/**
* Determine coordinates of upper-left margin corner
*/
$this->guess_corner($parent);
/**
* Offset parent current X coordinate
*/
$parent->_current_x += $this->get_full_width();
/**
* Extend parents height to fit the checkbox
*/
$parent->extend_height($this->get_bottom_margin());
}
/**
* Render the checkbox using the specified output driver
*
* @param OutputDriver $driver The output device driver object
*/
function show(&$driver) {
/**
* Get the coordinates of the check mark
*/
$x = ($this->get_left() + $this->get_right()) / 2;
$y = ($this->get_top() + $this->get_bottom()) / 2;
/**
* Calculate checkmark size; it looks nice when it takes
* 1/3 of the box size
*/
$size = $this->get_width() / 3;
/**
* Draw the box
*/
$driver->setrgbcolor(0,0,0);
$driver->setlinewidth(0.25);
$driver->moveto($x - $size, $y + $size);
$driver->lineto($x + $size, $y + $size);
$driver->lineto($x + $size, $y - $size);
$driver->lineto($x - $size, $y - $size);
$driver->closepath();
$driver->stroke();
/**
* Render the interactive button (if requested and possible)
* Also, field should be rendered only if name is not empty
*/
global $g_config;
if ($g_config['renderforms'] && $this->_name != "" && $this->_value != "") {
$driver->field_checkbox($x - $size,
$y + $size,
2*$size,
2*$size,
$this->_name,
$this->_value,
$this->_checked);
} else {
/**
* Draw check mark if needed
*/
if ($this->_checked) {
$check_size = $this->get_width() / 6;
$driver->moveto($x - $check_size, $y + $check_size);
$driver->lineto($x + $check_size, $y - $check_size);
$driver->stroke();
$driver->moveto($x + $check_size, $y + $check_size);
$driver->lineto($x - $check_size, $y - $check_size);
$driver->stroke();
}
};
return true;
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -1,81 +0,0 @@
<?php
class BoxTextFieldPageNo extends TextBoxString {
function BoxTextFieldPageNo() {
$this->TextBoxString("", "iso-8859-1");
}
function from_box(&$box) {
$field = new BoxTextFieldPageNo;
$field->copy_style($box);
$field->words = array("000");
$field->encodings = array("iso-8859-1");
$field->_left = $box->_left;
$field->_top = $box->_top;
$field->baseline = $box->baseline;
return $field;
}
function show(&$viewport) {
$font = $this->getCSSProperty(CSS_FONT);
$this->words[0] = sprintf("%d", $viewport->current_page);
$field_width = $this->width;
$field_left = $this->_left;
if ($font->size->getPoints() > 0) {
$value_width = $viewport->stringwidth($this->words[0],
$this->_get_font_name($viewport,0),
$this->encodings[0],
$font->size->getPoints());
if (is_null($value_width)) { return null; };
} else {
$value_width = 0;
};
$this->width = $value_width;
$this->_left += ($field_width - $value_width) / 2;
if (is_null(TextBoxString::show($viewport))) {
return null;
};
$this->width = $field_width;
$this->_left = $field_left;
return true;
}
function show_fixed(&$viewport) {
$font = $this->getCSSProperty(CSS_FONT);
$this->words[0] = sprintf("%d", $viewport->current_page);
$field_width = $this->width;
$field_left = $this->_left;
if ($font->size->getPoints() > 0) {
$value_width = $viewport->stringwidth($this->words[0],
$this->_get_font_name($viewport, 0),
$this->encodings[0],
$font->size->getPoints());
if (is_null($value_width)) { return null; };
} else {
$value_width = 0;
};
$this->width = $value_width;
$this->_left += ($field_width - $value_width) / 2;
if (is_null(TextBoxString::show_fixed($viewport))) {
return null;
};
$this->width = $field_width;
$this->_left = $field_left;
return true;
}
}
?>

View File

@@ -1,89 +0,0 @@
<?php
/**
* Handles the '##PAGES##' text field.
*
*/
class BoxTextFieldPages extends TextBoxString {
function BoxTextFieldPages() {
$this->TextBoxString("", "iso-8859-1");
}
function from_box(&$box) {
$field = new BoxTextFieldPages;
$field->copy_style($box);
$field->words = array("000");
$field->encodings = array("iso-8859-1");
$field->_left = $box->_left;
$field->_top = $box->_top;
$field->baseline = $box->baseline;
return $field;
}
function show(&$viewport) {
$font = $this->getCSSProperty(CSS_FONT);
$this->words[0] = sprintf("%d", $viewport->expected_pages);
$field_width = $this->width;
$field_left = $this->_left;
if ($font->size->getPoints() > 0) {
$value_width = $viewport->stringwidth($this->words[0],
$this->_get_font_name($viewport, 0),
$this->encodings[0],
$font->size->getPoints());
if (is_null($value_width)) {
return null;
};
} else {
$value_width = 0;
};
$this->width = $value_width;
$this->_left += ($field_width - $value_width) / 2;
if (is_null(TextBoxString::show($viewport))) {
return null;
};
$this->width = $field_width;
$this->_left = $field_left;
return true;
}
function show_fixed(&$viewport) {
$font = $this->getCSSProperty(CSS_FONT);
$this->words[0] = sprintf("%d", $viewport->expected_pages);
$field_width = $this->width;
$field_left = $this->_left;
if ($font->size->getPoints() > 0) {
$value_width = $viewport->stringwidth($this->words[0],
$this->_get_font_name($viewport, 0),
$this->encodings[0],
$font->size->getPoints());
if (is_null($value_width)) {
return null;
};
} else {
$value_width = 0;
};
$this->width = $value_width;
$this->_left += ($field_width - $value_width) / 2;
if (is_null(TextBoxString::show_fixed($viewport))) {
return null;
};
$this->width = $field_width;
$this->_left = $field_left;
return true;
}
}
?>

View File

@@ -1,40 +0,0 @@
<?php
class FormBox extends BlockBox {
/**
* @var String form name; it will be used as a prefix for field names when submitting forms
* @access private
*/
var $_name;
function show(&$driver) {
global $g_config;
if ($g_config['renderforms']) {
$driver->new_form($this->_name);
};
return parent::show($driver);
}
function &create(&$root, &$pipeline) {
if ($root->has_attribute('name')) {
$name = $root->get_attribute('name');
} elseif ($root->has_attribute('id')) {
$name = $root->get_attribute('id');
} else {
$name = "";
};
$box = new FormBox($name);
$box->readCSS($pipeline->getCurrentCSSState());
$box->create_content($root, $pipeline);
return $box;
}
function FormBox($name) {
$this->BlockBox();
$this->_name = $name;
}
}
?>

View File

@@ -1,304 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/box.frame.php,v 1.24 2007/02/18 09:55:10 Konstantin Exp $
class FrameBox extends GenericContainerBox {
function &create(&$root, &$pipeline) {
$box =& new FrameBox($root, $pipeline);
$box->readCSS($pipeline->getCurrentCSSState());
return $box;
}
function reflow(&$parent, &$context) {
// If frame contains no boxes (for example, the src link is broken)
// we just return - no further processing will be done
if (count($this->content) == 0) { return; };
// First box contained in a frame should always fill all its height
$this->content[0]->put_full_height($this->get_height());
$hc = new HCConstraint(array($this->get_height(), false),
array($this->get_height(), false),
array($this->get_height(), false));
$this->content[0]->put_height_constraint($hc);
$context->push_collapsed_margin(0);
$context->push_container_uid($this->uid);
$this->reflow_content($context);
$context->pop_collapsed_margin();
$context->pop_container_uid();
}
/**
* Reflow absolutely positioned block box. Note that according to CSS 2.1
* the only types of boxes which could be absolutely positioned are
* 'block' and 'table'
*
* @param FlowContext $context A flow context object containing the additional layout data.
*
* @link http://www.w3.org/TR/CSS21/visuren.html#dis-pos-flo CSS 2.1: Relationships between 'display', 'position', and 'float'
*/
function reflow_absolute(&$context) {
GenericFormattedBox::reflow($this->parent, $context);
$position_strategy =& new StrategyPositionAbsolute();
$position_strategy->apply($this);
/**
* As sometimes left/right values may not be set, we need to use the "fit" width here.
* If box have a width constraint, 'get_max_width' will return constrained value;
* othersise, an intrictic width will be returned.
*
* Note that get_max_width returns width _including_ external space line margins, borders and padding;
* as we're setting the "internal" - content width, we must subtract "extra" space width from the
* value received
*
* @see GenericContainerBox::get_max_width()
*/
$this->put_width($this->get_max_width($context) - $this->_get_hor_extra());
/**
* Update the width, as it should be calculated based upon containing block width, not real parent.
* After this we should remove width constraints or we may encounter problem
* in future when we'll try to call get_..._width functions for this box
*
* @todo Update the family of get_..._width function so that they would apply constraint
* using the containing block width, not "real" parent width
*/
$wc = $this->getCSSProperty(CSS_WIDTH);
$containing_block =& $this->_get_containing_block();
$this->put_width($wc->apply($this->get_width(),
$containing_block['right'] - $containing_block['left']));
$this->setCSSProperty(CSS_WIDTH, new WCNone());
/**
* Layout element's children
*/
$this->reflow_content($context);
/**
* As absolute-positioned box generated new flow contexy, extend the height to fit all floats
*/
$this->fitFloats($context);
/**
* If element have been positioned using 'right' or 'bottom' property,
* we need to offset it, as we assumed it had zero width and height at
* the moment we placed it
*/
$right = $this->getCSSProperty(CSS_RIGHT);
$left = $this->getCSSProperty(CSS_LEFT);
if ($left->isAuto() && !$right->isAuto()) {
$this->offset(-$this->get_width(), 0);
};
$bottom = $this->getCSSProperty(CSS_BOTTOM);
$top = $this->getCSSProperty(CSS_TOP);
if ($top->isAuto() && !$bottom->isAuto()) {
$this->offset(0, $this->get_height());
};
}
function FrameBox(&$root, &$pipeline) {
$css_state =& $pipeline->getCurrentCSSState();
// Inherit 'border' CSS value from parent (FRAMESET tag), if current FRAME
// has no FRAMEBORDER attribute, and FRAMESET has one
$parent = $root->parent();
if (!$root->has_attribute('frameborder') &&
$parent->has_attribute('frameborder')) {
$parent_border = $css_state->getPropertyOnLevel(CSS_BORDER, CSS_PROPERTY_LEVEL_PARENT);
$css_state->setProperty(CSS_BORDER, $parent_border->copy());
}
$this->GenericContainerBox($root);
// If NO src attribute specified, just return.
if (!$root->has_attribute('src')) { return; };
// Determine the fullly qualified URL of the frame content
$src = $root->get_attribute('src');
$url = $pipeline->guess_url($src);
$data = $pipeline->fetch($url);
/**
* If framed page could not be fetched return immediately
*/
if (is_null($data)) { return; };
/**
* Render only iframes containing HTML only
*
* Note that content-type header may contain additional information after the ';' sign
*/
$content_type = $data->get_additional_data('Content-Type');
$content_type_array = explode(';', $content_type);
if ($content_type_array[0] != "text/html") { return; };
$html = $data->get_content();
// Remove control symbols if any
$html = preg_replace('/[\x00-\x07]/', "", $html);
$converter = Converter::create();
$html = $converter->to_utf8($html, $data->detect_encoding());
$html = html2xhtml($html);
$tree = TreeBuilder::build($html);
// Save current stylesheet, as each frame may load its own stylesheets
//
$pipeline->pushCSS();
$css =& $pipeline->getCurrentCSS();
$css->scan_styles($tree, $pipeline);
$frame_root = traverse_dom_tree_pdf($tree);
$box_child =& create_pdf_box($frame_root, $pipeline);
$this->add_child($box_child);
// Restore old stylesheet
//
$pipeline->popCSS();
$pipeline->pop_base_url();
}
/**
* Note that if both top and bottom are 'auto', box will use vertical coordinate
* calculated using guess_corder in 'reflow' method which could be used if this
* box had 'position: static'
*/
function _positionAbsoluteVertically($containing_block) {
$bottom = $this->getCSSProperty(CSS_BOTTOM);
$top = $this->getCSSProperty(CSS_TOP);
if (!$top->isAuto()) {
if ($top->isPercentage()) {
$top_value = ($containing_block['top'] - $containing_block['bottom']) / 100 * $top->getPercentage();
} else {
$top_value = $top->getPoints();
};
$this->put_top($containing_block['top'] - $top_value - $this->get_extra_top());
} elseif (!$bottom->isAuto()) {
if ($bottom->isPercentage()) {
$bottom_value = ($containing_block['top'] - $containing_block['bottom']) / 100 * $bottom->getPercentage();
} else {
$bottom_value = $bottom->getPoints();
};
$this->put_top($containing_block['bottom'] + $bottom_value + $this->get_extra_bottom());
};
}
/**
* Note that if both 'left' and 'right' are 'auto', box will use
* horizontal coordinate calculated using guess_corder in 'reflow'
* method which could be used if this box had 'position: static'
*/
function _positionAbsoluteHorizontally($containing_block) {
$left = $this->getCSSProperty(CSS_LEFT);
$right = $this->getCSSProperty(CSS_RIGHT);
if (!$left->isAuto()) {
if ($left->isPercentage()) {
$left_value = ($containing_block['right'] - $containing_block['left']) / 100 * $left->getPercentage();
} else {
$left_value = $left->getPoints();
};
$this->put_left($containing_block['left'] + $left_value + $this->get_extra_left());
} elseif (!$right->isAuto()) {
if ($right->isPercentage()) {
$right_value = ($containing_block['right'] - $containing_block['left']) / 100 * $right->getPercentage();
} else {
$right_value = $right->getPoints();
};
$this->put_left($containing_block['right'] - $right_value - $this->get_extra_right());
};
}
}
class FramesetBox extends GenericContainerBox {
var $rows;
var $cols;
function &create(&$root, &$pipeline) {
$box =& new FramesetBox($root, $pipeline);
$box->readCSS($pipeline->getCurrentCSSState());
return $box;
}
function FramesetBox(&$root, $pipeline) {
$this->GenericContainerBox($root);
$this->create_content($root, $pipeline);
// Now determine the frame layout inside the frameset
$this->rows = $root->has_attribute('rows') ? $root->get_attribute('rows') : "100%";
$this->cols = $root->has_attribute('cols') ? $root->get_attribute('cols') : "100%";
}
function reflow(&$parent, &$context) {
$viewport =& $context->get_viewport();
// Frameset always fill all available space in viewport
$this->put_left($viewport->get_left() + $this->get_extra_left());
$this->put_top($viewport->get_top() - $this->get_extra_top());
$this->put_full_width($viewport->get_width());
$this->setCSSProperty(CSS_WIDTH, new WCConstant($viewport->get_width()));
$this->put_full_height($viewport->get_height());
$this->put_height_constraint(new WCConstant($viewport->get_height()));
// Parse layout-control values
$rows = guess_lengths($this->rows, $this->get_height());
$cols = guess_lengths($this->cols, $this->get_width());
// Now reflow all frames in frameset
$cur_col = 0;
$cur_row = 0;
for ($i=0; $i < count($this->content); $i++) {
// Had we run out of cols/rows?
if ($cur_row >= count($rows)) {
// In valid HTML we never should get here, but someone can provide less frame cells
// than frames. Extra frames will not be rendered at all
return;
}
$frame =& $this->content[$i];
/**
* Depending on the source HTML, FramesetBox may contain some non-frame boxes;
* we'll just ignore them
*/
if (!is_a($frame, "FramesetBox") &&
!is_a($frame, "FrameBox")) {
continue;
};
// Guess frame size and position
$frame->put_left($this->get_left() + array_sum(array_slice($cols, 0, $cur_col)) + $frame->get_extra_left());
$frame->put_top($this->get_top() - array_sum(array_slice($rows, 0, $cur_row)) - $frame->get_extra_top());
$frame->put_full_width($cols[$cur_col]);
$frame->setCSSProperty(CSS_WIDTH, new WCConstant($frame->get_width()));
$frame->put_full_height($rows[$cur_row]);
$frame->put_height_constraint(new WCConstant($frame->get_height()));
// Reflow frame contents
$context->push_viewport(FlowViewport::create($frame));
$frame->reflow($this, $context);
$context->pop_viewport();
// Move to the next frame position
// Next columns
$cur_col ++;
if ($cur_col >= count($cols)) {
// Next row
$cur_col = 0;
$cur_row ++;
}
}
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -1,112 +0,0 @@
<?php
class GenericInlineBox extends GenericContainerBox {
function GenericInlineBox() {
$this->GenericContainerBox();
}
// @todo this code is duplicated in box.block.php
//
function reflow(&$parent, &$context) {
switch ($this->getCSSProperty(CSS_POSITION)) {
case POSITION_STATIC:
return $this->reflow_static($parent, $context);
case POSITION_RELATIVE:
/**
* CSS 2.1:
* Once a box has been laid out according to the normal flow or floated, it may be shifted relative
* to this position. This is called relative positioning. Offsetting a box (B1) in this way has no
* effect on the box (B2) that follows: B2 is given a position as if B1 were not offset and B2 is
* not re-positioned after B1's offset is applied. This implies that relative positioning may cause boxes
* to overlap. However, if relative positioning causes an 'overflow:auto' box to have overflow, the UA must
* allow the user to access this content, which, through the creation of scrollbars, may affect layout.
*
* @link http://www.w3.org/TR/CSS21/visuren.html#x28 CSS 2.1 Relative positioning
*/
$this->reflow_static($parent, $context);
$this->offsetRelative();
return;
}
}
// Checks if current inline box should cause a line break inside the parent box
//
// @param $parent reference to a parent box
// @param $content flow context
// @return true if line break occurred; false otherwise
//
function maybe_line_break(&$parent, &$context) {
if (!$parent->line_break_allowed()) {
return false;
};
// Calculate the x-coordinate of this box right edge
$right_x = $this->get_full_width() + $parent->_current_x;
$need_break = false;
// Check for right-floating boxes
// If upper-right corner of this inline box is inside of some float, wrap the line
if ($context->point_in_floats($right_x, $parent->_current_y)) {
$need_break = true;
};
// No floats; check if we had run out the right edge of container
// TODO: nobr-before, nobr-after
if (($right_x > $parent->get_right() + EPSILON)) {
// Now check if parent line box contains any other boxes;
// if not, we should draw this box unless we have a floating box to the left
$first = $parent->get_first();
// FIXME: what's this? This condition is invariant!
$text_indent = $parent->getCSSProperty(CSS_TEXT_INDENT);
$indent_offset = ($first->uid == $this->uid || 1) ? $text_indent->calculate($parent) : 0;
if ($parent->_current_x > $parent->get_left() + $indent_offset + EPSILON) {
$need_break = true;
};
}
// As close-line will not change the current-Y parent coordinate if no
// items were in the line box, we need to offset this explicitly in this case
//
if ($parent->line_box_empty() && $need_break) {
$parent->_current_y -= $this->get_height();
};
if ($need_break) {
$parent->close_line($context);
// Check if parent inline boxes have left padding/margins and add them to current_x
$element = $this->parent;
while (!is_null($element) && is_a($element,"GenericInlineBox")) {
$parent->_current_x += $element->get_extra_left();
$element = $element->parent;
};
};
return $need_break;
}
function get_ascender() {
$first =& $this->get_first();
if (is_null($first)) { return 0; };
return $first->get_ascender();
}
function get_baseline() {
$first =& $this->get_first();
if (is_null($first)) { return 0; };
return $first->get_baseline();
}
function get_descender() {
$first =& $this->get_first();
if (is_null($first)) { return 0; };
return $first->get_descender();
}
}
?>

View File

@@ -1,454 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/box.generic.php,v 1.72 2007/01/24 18:55:44 Konstantin Exp $
require_once(HTML2PS_DIR.'globals.php');
class GenericBox {
var $_cache;
var $_css;
var $_left;
var $_top;
var $_parent;
var $baseline;
var $default_baseline;
var $_cached_base_font_size;
function GenericBox() {
$this->_cache = array();
$this->_css = array();
$this->_cached_base_font_size = null;
$this->_left = 0;
$this->_top = 0;
$this->_parent = null;
$this->baseline = 0;
$this->default_baseline = 0;
/**
* Assign an unique box identifier
*/
$GLOBALS['g_box_uid']++;
$this->uid = $GLOBALS['g_box_uid'];
}
function destroy() {
unset($this->_cache);
unset($this->_css);
unset($this->_left);
unset($this->_top);
unset($this->_parent);
unset($this->baseline);
unset($this->default_baseline);
}
/**
* see getProperty for optimization description
*/
function setCSSProperty($code, $value) {
static $cache = array();
if (!isset($cache[$code])) {
$cache[$code] =& CSS::get_handler($code);
};
$cache[$code]->replace_array($value, $this->_css);
}
/**
* Optimization: this function is called very often,
* so even a slight overhead for CSS::get_handler call
* accumulates in a significiant processing delay.
*/
function &getCSSProperty($code) {
static $cache = array();
if (!isset($cache[$code])) {
$cache[$code] =& CSS::get_handler($code);
};
$value =& $cache[$code]->get($this->_css);
return $value;
}
function show_postponed(&$driver) {
$this->show($driver);
}
function copy_style(&$box) {
// TODO: object references
$this->_css = $box->_css;
}
/**
* Optimization: _readCSSLength is usually called several times
* while initializing box object. $base_font_size cound be calculated
* only once and stored in a static variable.
*/
function _readCSSLengths($state, $property_list) {
if (is_null($this->_cached_base_font_size)) {
$font =& $this->getCSSProperty(CSS_FONT);
$this->_cached_base_font_size = $font->size->getPoints();
};
foreach ($property_list as $property) {
$value =& $state->getProperty($property);
if ($value === CSS_PROPERTY_INHERIT) {
$value =& $state->getInheritedProperty($property);
};
if (is_object($value)) {
$value =& $value->copy();
$value->doInherit($state);
$value->units2pt($this->_cached_base_font_size);
};
$this->setCSSProperty($property, $value);
}
}
function _readCSS($state, $property_list) {
foreach ($property_list as $property) {
$value = $state->getProperty($property);
// Note that order is important; composite object-value could be inherited and
// object itself could contain subvalues with 'inherit' value
if ($value === CSS_PROPERTY_INHERIT) {
$value = $state->getInheritedProperty($property);
};
if (is_object($value)) {
$value = $value->copy();
$value->doInherit($state);
};
$this->setCSSProperty($property, $value);
}
}
function readCSS(&$state) {
/**
* Determine font size to be used in this box (required for em/ex units)
*/
$value = $state->getProperty(CSS_FONT);
if ($value === CSS_PROPERTY_INHERIT) {
$value = $state->getInheritedProperty(CSS_FONT);
};
$base_font_size = $state->getBaseFontSize();
if (is_object($value)) {
$value = $value->copy();
$value->doInherit($state);
$value->units2pt($base_font_size);
};
$this->setCSSProperty(CSS_FONT, $value);
/**
* Continue working with other properties
*/
$this->_readCSS($state,
array(CSS_COLOR,
CSS_DISPLAY,
CSS_VISIBILITY));
$this->_readCSSLengths($state,
array(CSS_VERTICAL_ALIGN));
// '-html2ps-link-destination'
global $g_config;
if ($g_config["renderlinks"]) {
$this->_readCSS($state,
array(CSS_HTML2PS_LINK_DESTINATION));
};
// Save ID attribute value
$id = $state->getProperty(CSS_HTML2PS_LINK_DESTINATION);
if (!empty($id)) {
if (!isset($GLOBALS['__html_box_id_map'][$id])) {
$GLOBALS['__html_box_id_map'][$id] =& $this;
};
};
}
function show(&$driver) {
// If debugging mode is on, draw the box outline
global $g_config;
if ($g_config['debugbox']) {
// Copy the border object of current box
$driver->setlinewidth(0.1);
$driver->setrgbcolor(0,0,0);
$driver->rect($this->get_left(), $this->get_top(), $this->get_width(), -$this->get_height());
$driver->stroke();
}
// Set current text color
// Note that text color is used not only for text drawing (for example, list item markers
// are drawn with text color)
$color = $this->getCSSProperty(CSS_COLOR);
$color->apply($driver);
}
/**
* Render box having position: fixed or contained in such box
* (Default behaviour)
*/
function show_fixed(&$driver) {
return $this->show($driver);
}
function pre_reflow_images() {}
function offset($dx, $dy) {
$this->_left += $dx;
$this->_top += $dy;
}
// Calculate the content upper-left corner position in curent flow
function guess_corner(&$parent) {
$this->put_left($parent->_current_x + $this->get_extra_left());
$this->put_top($parent->_current_y - $this->get_extra_top());
}
function put_left($value) {
$this->_left = $value;
}
function put_top($value) {
$this->_top = $value + $this->getBaselineOffset();
}
/**
* Get Y coordinate of the top content area edge
*/
function get_top() {
return
$this->_top -
$this->getBaselineOffset();
}
function get_right() {
return $this->get_left() + $this->get_width();
}
function get_left() {
return $this->_left;
}
function get_bottom() {
return $this->get_top() - $this->get_height();
}
function getBaselineOffset() {
return $this->baseline - $this->default_baseline;
}
function reflow_anchors(&$driver, &$anchors) {
if ($this->is_null()) {
return;
};
$link_destination = $this->getCSSProperty(CSS_HTML2PS_LINK_DESTINATION);
if ($link_destination !== "") {
/**
* Y=0 designates the bottom edge of the first page (without margins)
* Y axis is oriented to the bottom.
*
* Here we calculate the offset from the bottom edge of first page PRINTABLE AREA
* to the bottom edge of the current box
*/
$y2 = $this->get_bottom() - mm2pt($driver->media->margins['bottom']);
/**
* Now let's calculate the number of the page corresponding to this offset.
* Note that $y2>0 for the first page and $y2<0 on all subsequent pages
*/
$page_fraction = $y2 / mm2pt($driver->media->real_height());
/**
* After the last operation we've got the "page fraction" between
* bottom of the first page and box bottom edge;
*
* it will be equal to:
* 1 for the top of the first page,
* 0 for the bottom of the first page
* -Epsilon for the top of the first page
* -1 for the bottom of the second page
* -n+1 for the bottom of the N-th page.
*/
$page_fraction2 = -$page_fraction+1;
/**
* Here:
* 0 for the top of the first page,
* 1 for the bottom of the first page
* 1+Epsilon for the top of the first page
* 2 for the bottom of the second page
* n for the bottom of the N-th page.
*
* Keeping in mind said above, we may calculate the real page number,
* rounding it UP after calculation. The reason of rounding UP is simple:
* pages are numbered starting at 1.
*/
$page = ceil($page_fraction2);
/**
* Now let's calculate the coordinates on this particular page
*
* X coordinate calculation is pretty straight forward (and, actually, unused, as it would be
* a bad idea to scroll PDF horiaontally).
*/
$x = $this->get_left();
/**
* Y coordinate should be calculated relatively to the bottom page edge
*/
$y = mm2pt($driver->media->real_height()) * ($page - $page_fraction2) + mm2pt($driver->media->margins['bottom']);
$anchors[$link_destination] = new Anchor($link_destination,
$page,
$x,
$y);
};
}
function reflow(&$parent, &$context) {}
function reflow_inline() { }
function out_of_flow() {
return false;
}
function get_bottom_margin() { return $this->get_bottom(); }
function get_top_margin() {
return $this->get_top();
}
function get_full_height() { return $this->get_height(); }
function get_width() { return $this->width; }
function get_full_width() {
return $this->width;
}
function get_height() {
return $this->height;
}
function get_baseline() {
return $this->baseline;
}
function is_container() { return false; }
function isVisibleInFlow() { return true; }
function reflow_text() { return true; }
/**
* Note that linebox is started by any non-whitespace inline element; all whitespace elements before
* that moment should be ignored.
*
* @param boolean $linebox_started Flag indicating that a new line box have just started and it already contains
* some inline elements
* @param boolean $previous_whitespace Flag indicating that a previous inline element was an whitespace element.
*/
function reflow_whitespace(&$linebox_started, &$previous_whitespace) {
return;
}
function is_null() {
return false;
}
function isCell() {
return false;
}
function isTableRow() {
return false;
}
function isTableSection() {
return false;
}
// CSS 2.1:
// 9.2.1 Block-level elements and block boxes
// Block-level elements are those elements of the source document that are formatted visually as blocks
// (e.g., paragraphs). Several values of the 'display' property make an element block-level:
// 'block', 'list-item', 'compact' and 'run-in' (part of the time; see compact and run-in boxes), and 'table'.
//
function isBlockLevel() {
return false;
}
function hasAbsolutePositionedParent() {
if (is_null($this->parent)) {
return false;
};
return
$this->parent->getCSSProperty(CSS_POSITION) == POSITION_ABSOLUTE ||
$this->parent->hasAbsolutePositionedParent();
}
function hasFixedPositionedParent() {
if (is_null($this->parent)) {
return false;
};
return
$this->parent->getCSSProperty(CSS_POSITION) == POSITION_FIXED ||
$this->parent->hasFixedPositionedParent();
}
/**
* Box can be expanded if it has no width constrains and
* all it parents has no width constraints
*/
function mayBeExpanded() {
$wc = $this->getCSSProperty(CSS_WIDTH);
if (!$wc->isNull()) { return false; };
if ($this->getCSSProperty(CSS_FLOAT) <> FLOAT_NONE) {
return true;
};
if ($this->getCSSProperty(CSS_POSITION) <> POSITION_STATIC &&
$this->getCSSProperty(CSS_POSITION) <> POSITION_RELATIVE) {
return true;
};
if (is_null($this->parent)) {
return true;
};
return $this->parent->mayBeExpanded();
}
function isLineBreak() {
return false;
}
function get_min_width_natural($context) {
return $this->get_min_width($context);
}
function is_note_call() {
return isset($this->note_call);
}
/* DOM compatibility */
function &get_parent_node() {
return $this->parent;
}
}
?>

View File

@@ -1,76 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/box.iframe.php,v 1.14 2006/12/18 19:44:21 Konstantin Exp $
class IFrameBox extends InlineBlockBox {
function &create(&$root, &$pipeline) {
$box =& new IFrameBox($root, $pipeline);
$box->readCSS($pipeline->getCurrentCSSState());
return $box;
}
// Note that IFRAME width is NOT determined by its content, thus we need to override 'get_min_width' and
// 'get_max_width'; they should return the constrained frame width.
function get_min_width(&$context) {
return $this->get_max_width($context);
}
function get_max_width(&$context) {
return $this->get_width();
}
function IFrameBox(&$root, $pipeline) {
$this->InlineBlockBox();
// If NO src attribute specified, just return.
if (!$root->has_attribute('src') ||
trim($root->get_attribute('src')) == '') {
return;
};
// Determine the fullly qualified URL of the frame content
$src = $root->get_attribute('src');
$url = $pipeline->guess_url($src);
$data = $pipeline->fetch($url);
/**
* If framed page could not be fetched return immediately
*/
if (is_null($data)) { return; };
/**
* Render only iframes containing HTML only
*
* Note that content-type header may contain additional information after the ';' sign
*/
$content_type = $data->get_additional_data('Content-Type');
$content_type_array = explode(';', $content_type);
if ($content_type_array[0] != "text/html") { return; };
$html = $data->get_content();
// Remove control symbols if any
$html = preg_replace('/[\x00-\x07]/', "", $html);
$converter = Converter::create();
$html = $converter->to_utf8($html, $data->detect_encoding());
$html = html2xhtml($html);
$tree = TreeBuilder::build($html);
// Save current stylesheet, as each frame may load its own stylesheets
//
$pipeline->pushCSS();
$css =& $pipeline->getCurrentCSS();
$css->scan_styles($tree, $pipeline);
$frame_root = traverse_dom_tree_pdf($tree);
$box_child =& create_pdf_box($frame_root, $pipeline);
$this->add_child($box_child);
// Restore old stylesheet
//
$pipeline->popCSS();
$pipeline->pop_base_url();
}
}
?>

View File

@@ -1,347 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/box.img.php,v 1.49 2007/03/15 18:37:29 Konstantin Exp $
define('SCALE_NONE',0);
define('SCALE_WIDTH',1);
define('SCALE_HEIGHT',2);
class GenericImgBox extends GenericInlineBox {
function GenericImgBox() {
$this->GenericInlineBox();
}
function get_max_width_natural(&$context) {
return $this->get_full_width($context);
}
function get_min_width(&$context) {
return $this->get_full_width();
}
function get_max_width(&$context) {
return $this->get_full_width();
}
function is_null() {
return false;
}
function pre_reflow_images() {
switch ($this->scale) {
case SCALE_WIDTH:
// Only 'width' attribute given
$size =
$this->src_width/$this->src_height*
$this->get_width();
$this->put_height($size);
// Update baseline according to constrained image height
$this->default_baseline = $this->get_full_height();
break;
case SCALE_HEIGHT:
// Only 'height' attribute given
$size =
$this->src_height/$this->src_width*
$this->get_height();
$this->put_width($size);
$this->setCSSProperty(CSS_WIDTH, new WCConstant($size));
$this->default_baseline = $this->get_full_height();
break;
};
}
function readCSS(&$state) {
parent::readCSS($state);
// '-html2ps-link-target'
global $g_config;
if ($g_config["renderlinks"]) {
$this->_readCSS($state,
array(CSS_HTML2PS_LINK_TARGET));
};
}
function reflow_static(&$parent, &$context) {
$this->pre_reflow_images();
GenericFormattedBox::reflow($parent, $context);
// Check if we need a line break here
$this->maybe_line_break($parent, $context);
// set default baseline
$this->baseline = $this->default_baseline;
// append to parent line box
$parent->append_line($this);
// Move box to the parent current point
$this->guess_corner($parent);
// Move parent's X coordinate
$parent->_current_x += $this->get_full_width();
// Extend parent height
$parent->extend_height($this->get_bottom_margin());
}
function _get_font_name(&$driver, $subword_index) {
if (isset($this->_cache[CACHE_TYPEFACE][$subword_index])) {
return $this->_cache[CACHE_TYPEFACE][$subword_index];
};
$font_resolver =& $driver->get_font_resolver();
$font = $this->getCSSProperty(CSS_FONT);
$typeface = $font_resolver->getTypefaceName($font->family,
$font->weight,
$font->style,
'iso-8859-1');
$this->_cache[CACHE_TYPEFACE][$subword_index] = $typeface;
return $typeface;
}
function reflow_text(&$driver) {
// In XHTML images are treated as a common inline elements; they are affected by line-height and font-size
global $g_config;
if ($g_config['mode'] == 'xhtml') {
/**
* A simple assumption is made: fonts used for different encodings
* have equal ascender/descender values (while they have the same
* typeface, style and weight).
*/
$font_name = $this->_get_font_name($driver, 0);
/**
* Get font vertical metrics
*/
$ascender = $driver->font_ascender($font_name, 'iso-8859-1');
if (is_null($ascender)) {
error_log("ImgBox::reflow_text: cannot get font ascender");
return null;
};
$descender = $driver->font_descender($font_name, 'iso-8859-1');
if (is_null($descender)) {
error_log("ImgBox::reflow_text: cannot get font descender");
return null;
};
/**
* Setup box size
*/
$font = $this->getCSSProperty(CSS_FONT_SIZE);
$font_size = $font->getPoints();
$this->ascender = $ascender * $font_size;
$this->descender = $descender * $font_size;
} else {
$this->ascender = $this->get_height();
$this->descender = 0;
};
return true;
}
// Image boxes are regular inline boxes; whitespaces after images should be rendered
//
function reflow_whitespace(&$linebox_started, &$previous_whitespace) {
$linebox_started = true;
$previous_whitespace = false;
return;
}
function show_fixed(&$driver) {
return $this->show($driver);
}
}
class BrokenImgBox extends GenericImgBox {
var $alt;
function BrokenImgBox($width, $height, $alt) {
$this->scale = SCALE_NONE;
$this->encoding = DEFAULT_ENCODING;
// Call parent constructor
$this->GenericImgBox();
$this->alt = $alt;
}
function show(&$driver) {
$driver->save();
// draw generic box
GenericFormattedBox::show($driver);
$driver->setlinewidth(0.1);
$driver->moveto($this->get_left(), $this->get_top());
$driver->lineto($this->get_right(), $this->get_top());
$driver->lineto($this->get_right(), $this->get_bottom());
$driver->lineto($this->get_left(), $this->get_bottom());
$driver->closepath();
$driver->stroke();
$driver->moveto($this->get_left(), $this->get_top());
$driver->lineto($this->get_right(), $this->get_top());
$driver->lineto($this->get_right(), $this->get_bottom());
$driver->lineto($this->get_left(), $this->get_bottom());
$driver->closepath();
$driver->clip();
// Output text with the selected font
$size = pt2pt(BROKEN_IMAGE_ALT_SIZE_PT);
$status = $driver->setfont("Times-Roman", "iso-8859-1", $size);
if (is_null($status)) {
return null;
};
$driver->show_xy($this->alt,
$this->get_left() + $this->width/2 - $driver->stringwidth($this->alt,
"Times-Roman",
"iso-8859-1",
$size)/2,
$this->get_top() - $this->height/2 - $size/2);
$driver->restore();
$strategy =& new StrategyLinkRenderingNormal();
$strategy->apply($this, $driver);
return true;
}
}
class ImgBox extends GenericImgBox {
function &create(&$root, &$pipeline) {
// Open image referenced by HTML tag
// Some crazy HTML writers add leading and trailing spaces to SRC attribute value - we need to remove them
//
$url_autofix = new AutofixUrl();
$src = $url_autofix->apply(trim($root->get_attribute("src")));
$image_url = $pipeline->guess_url($src);
$src_img = Image::get($image_url, $pipeline);
if (is_null($src_img)) {
// image could not be opened, use ALT attribute
if ($root->has_attribute('width')) {
$width = px2pt($root->get_attribute('width'));
} else {
$width = px2pt(BROKEN_IMAGE_DEFAULT_SIZE_PX);
};
if ($root->has_attribute('height')) {
$height = px2pt($root->get_attribute('height'));
} else {
$height = px2pt(BROKEN_IMAGE_DEFAULT_SIZE_PX);
};
$alt = $root->get_attribute('alt');
$box =& new BrokenImgBox($width, $height, $alt);
$box->readCSS($pipeline->getCurrentCSSState());
$box->put_width($width);
$box->put_height($height);
$box->default_baseline = $box->get_full_height();
$box->src_height = $box->get_height();
$box->src_width = $box->get_width();
return $box;
} else {
$box =& new ImgBox($src_img);
$box->readCSS($pipeline->getCurrentCSSState());
$box->_setupSize();
return $box;
}
}
function _setupSize() {
$this->put_width(px2pt(imagesx($this->image)));
$this->put_height(px2pt(imagesy($this->image)));
$this->default_baseline = $this->get_full_height();
$this->src_height = imagesx($this->image);
$this->src_width = imagesy($this->image);
$wc = $this->getCSSProperty(CSS_WIDTH);
$hc = $this->get_height_constraint();
// Proportional scaling
if ($hc->is_null() && !$wc->isNull()) {
$this->scale = SCALE_WIDTH;
// Only 'width' attribute given
$size =
$this->src_width/$this->src_height*
$this->get_width();
$this->put_height($size);
// Update baseline according to constrained image height
$this->default_baseline = $this->get_full_height();
} elseif (!$hc->is_null() && $wc->isNull()) {
$this->scale = SCALE_HEIGHT;
// Only 'height' attribute given
$size =
$this->src_height/$this->src_width*
$this->get_height();
$this->put_width($size);
$this->setCSSProperty(CSS_WIDTH, new WCConstant($size));
$this->default_baseline = $this->get_full_height();
};
}
function ImgBox($img) {
$this->encoding = DEFAULT_ENCODING;
$this->scale = SCALE_NONE;
// Call parent constructor
$this->GenericImgBox();
// Store image for further processing
$this->image = $img;
}
function show(&$driver) {
// draw generic box
GenericFormattedBox::show($driver);
// Check if "designer" set the height or width of this image to zero; in this there will be no reason
// in drawing the image at all
//
if ($this->get_width() < EPSILON ||
$this->get_height() < EPSILON) {
return true;
};
$driver->image_scaled($this->image,
$this->get_left(), $this->get_bottom(),
$this->get_width() / imagesx($this->image), $this->get_height() / imagesy($this->image));
$strategy =& new StrategyLinkRenderingNormal();
$strategy->apply($this, $driver);
return true;
}
}
?>

View File

@@ -1,69 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/box.inline.control.php,v 1.7 2006/09/07 18:38:12 Konstantin Exp $
class InlineControlBox extends InlineBox {
// get_max_width is inherited from GenericContainerBox
function get_min_width(&$context, $limit = 10E6) {
return $this->get_max_width($context, $limit);
}
function get_max_width(&$context, $limit = 10E6) {
return
GenericContainerBox::get_max_width($context, $limit) -
$this->_get_hor_extra();
}
function show(&$viewport) {
// Now set the baseline of a button box to align it vertically when flowing isude the
// text line
$this->default_baseline = $this->content[0]->baseline + $this->get_extra_top();
$this->baseline = $this->content[0]->baseline + $this->get_extra_top();
return GenericContainerBox::show($viewport);
}
function line_break_allowed() { return false; }
function reflow_static(&$parent, &$context) {
GenericFormattedBox::reflow($parent, $context);
// Determine the box width
$this->_calc_percentage_width($parent, $context);
$this->put_full_width($this->get_min_width($context, $parent->get_width()));
$this->setCSSProperty(CSS_WIDTH, new WCNone());
// Check if we need a line break here
$this->maybe_line_break($parent, $context);
// append to parent line box
$parent->append_line($this);
// Determine coordinates of upper-left _margin_ corner
$this->guess_corner($parent);
$this->reflow_content($context);
/**
* After text content have been reflown, we may determine the baseline of the control item itself;
*
* As there will be some extra whitespace on the top of the control box, we must add this whitespace
* to the calculated baseline value, so text before and after control item will be aligned
* with the text inside the box.
*/
$this->default_baseline = $this->content[0]->baseline + $this->get_extra_top();
$this->baseline = $this->content[0]->baseline + $this->get_extra_top();
// center the button text vertically inside the button
$text =& $this->content[0];
$delta = ($text->get_top() - $text->get_height()/2) - ($this->get_top() - $this->get_height()/2);
$text->offset(0,-$delta);
// Offset parent current X coordinate
$parent->_current_x += $this->get_full_width();
// Extends parents height
$parent->extend_height($this->get_bottom_margin());
}
}
?>

View File

@@ -1,498 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/box.inline.php,v 1.53 2007/01/24 18:55:44 Konstantin Exp $
require_once(HTML2PS_DIR.'encoding.inc.php');
define('SYMBOL_SHY', code_to_utf8(0xAD));
define('BROKEN_SYMBOL', chr(0xC2));
class LineBox {
var $top;
var $right;
var $bottom;
var $left;
function LineBox() { }
function &copy() {
$box =& new LineBox;
$box->top = $this->top;
$box->right = $this->right;
$box->bottom = $this->bottom;
$box->left = $this->left;
return $box;
}
function offset($dx, $dy) {
$this->top += $dy;
$this->bottom += $dy;
$this->left += $dx;
$this->right += $dx;
}
function create(&$box) {
$lbox = new LineBox;
$lbox->top = $box->get_top();
$lbox->right = $box->get_right();
$lbox->bottom = $box->get_bottom();
$lbox->left = $box->get_left();
// $lbox->bottom = $box->get_top() - $box->get_baseline() - $box->get_descender();
// $lbox->top = $box->get_top() - $box->get_baseline() + $box->get_ascender();
return $lbox;
}
function extend(&$box) {
$base = $box->get_top() - $box->get_baseline();
$this->top = max($this->top, $base + $box->get_ascender());
$this->right = max($this->right, $box->get_right());
$this->bottom = min($this->bottom, $base - $box->get_descender());
// Left edge of the line box should never be modified
}
function fake_box(&$box) {
// Create the fake box object
$fake_state = new CSSState(CSS::get());
$fake_state->pushState();
$fake = null;
$fake_box = new BlockBox($fake);
$fake_box->readCSS($fake_state);
// Setup fake box size
$fake_box->put_left($this->left);
$fake_box->put_width($this->right - $this->left);
$fake_box->put_top($this->top - $box->baseline);
$fake_box->put_height($this->top - $this->bottom);
// Setup padding value
$fake_box->setCSSProperty(CSS_PADDING, $box->getCSSProperty(CSS_PADDING));
// Setup fake box border and background
$fake_box->setCSSProperty(CSS_BACKGROUND, $box->getCSSProperty(CSS_BACKGROUND));
$fake_box->setCSSProperty(CSS_BORDER, $box->getCSSProperty(CSS_BORDER));
return $fake_box;
}
}
class InlineBox extends GenericInlineBox {
var $_lines;
function InlineBox() {
// Call parent's constructor
$this->GenericInlineBox();
// Clear the list of line boxes inside this box
$this->_lines = array();
}
function &create(&$root, &$pipeline) {
// Create contents of this inline box
if ($root->node_type() == XML_TEXT_NODE) {
$css_state =& $pipeline->getCurrentCSSState();
return InlineBox::create_from_text($root->content,
$css_state->getProperty(CSS_WHITE_SPACE),
$pipeline);
} else {
$box =& new InlineBox();
$css_state =& $pipeline->getCurrentCSSState();
$box->readCSS($css_state);
// Initialize content
$child = $root->first_child();
while ($child) {
$child_box =& create_pdf_box($child, $pipeline);
$box->add_child($child_box);
$child = $child->next_sibling();
};
// Add fake whitespace box with zero size for the anchor spans
// We need this, as "reflow" functions will automatically remove empty inline boxes from the
// document tree
//
if ($box->is_null()) {
$css_state->pushState();
$css_state->setProperty(CSS_FONT_SIZE, Value::fromData(0.01, UNIT_PT));
$whitespace = WhitespaceBox::create($pipeline);
$whitespace->readCSS($css_state);
$box->add_child($whitespace);
$css_state->popState();
};
}
return $box;
}
function &create_from_text($text, $white_space, &$pipeline) {
$box =& new InlineBox();
$box->readCSS($pipeline->getCurrentCSSState());
// Apply/inherit text-related CSS properties
$css_state =& $pipeline->getCurrentCSSState();
$css_state->pushDefaultTextState();
require_once(HTML2PS_DIR.'inline.content.builder.factory.php');
$inline_content_builder =& InlineContentBuilderFactory::get($white_space);
$inline_content_builder->build($box, $text, $pipeline);
// Clear the CSS stack
$css_state->popState();
return $box;
}
function get_line_box_count() {
return count($this->_lines);
}
// Inherited from GenericFormattedBox
function process_word($raw_content, &$pipeline) {
if ($raw_content === '') {
return false;
}
$ptr = 0;
$word = '';
$hyphens = array();
$encoding = 'iso-8859-1';
$manager_encoding =& ManagerEncoding::get();
$text_box =& TextBox::create_empty($pipeline);
$len = strlen($raw_content);
while ($ptr < $len) {
$char = $manager_encoding->getNextUTF8Char($raw_content, $ptr);
// Check if current char is a soft hyphen character. It it is,
// remove it from the word (as it should not be drawn normally)
// and store its location
if ($char == SYMBOL_SHY) {
$hyphens[] = strlen($word);
} else {
$mapping = $manager_encoding->getMapping($char);
/**
* If this character is not found in predefined encoding vectors,
* we'll use "Custom" encoding and add single-character TextBox
*
* @TODO: handle characters without known glyph names
*/
if (is_null($mapping)) {
/**
* No mapping to default encoding vectors found for this character
*/
/**
* Add last word
*/
if ($word !== '') {
$text_box->add_subword($word, $encoding, $hyphens);
};
/**
* Add current symbol
*/
$custom_char = $manager_encoding->addCustomChar(utf8_to_code($char));
$text_box->add_subword($custom_char, $manager_encoding->getCustomEncodingName(), $hyphens);
$word = '';
} else {
if (isset($mapping[$encoding])) {
$word .= $mapping[$encoding];
} else {
// This condition prevents empty text boxes from appearing; say, if word starts with a national
// character, an () - text box with no letters will be generated, in rare case causing a random line
// wraps, if container is narrow
if ($word !== '') {
$text_box->add_subword($word, $encoding, $hyphens);
};
reset($mapping);
list($encoding, $add) = each($mapping);
$word = $mapping[$encoding];
$hyphens = array();
};
};
};
};
if ($word !== '') {
$text_box->add_subword($word, $encoding, $hyphens);
};
$this->add_child($text_box);
return true;
}
function show(&$driver) {
if ($this->getCSSProperty(CSS_POSITION) == POSITION_RELATIVE) {
// Postpone
return true;
};
return $this->_show($driver);
}
function show_postponed(&$driver) {
return $this->_show($driver);
}
function _show(&$driver) {
// Show line boxes background and borders
$size = $this->getLineBoxCount();
for ($i=0; $i<$size; $i++) {
$line_box = $this->getLineBox($i);
$fake_box = $line_box->fake_box($this);
$background = $this->getCSSProperty(CSS_BACKGROUND);
$border = $this->getCSSProperty(CSS_BORDER);
$background->show($driver, $fake_box);
$border->show($driver, $fake_box);
};
// Show content
$size = count($this->content);
for ($i=0; $i < $size; $i++) {
if (is_null($this->content[$i]->show($driver))) {
return null;
};
}
return true;
}
// Initialize next line box inside this inline
//
// Adds the next element to _lines array inside the current object and initializes it with the
// $box parameters
//
// @param $box child box which will be first in this line box
// @param $line_no number of line box
//
function init_line(&$box, &$line_no) {
$line_box = LineBox::create($box);
$this->_lines[$line_no] = $line_box;
}
// Extends the existing line box to include the given child
// OR starts new line box, if current child is to the left of the box right edge
// (which should not happen white the line box is filled)
//
// @param $box child box which will be first in this line box
// @param $line_no number of line box
//
function extend_line(&$box, $line_no) {
if (!isset($this->_lines[$line_no])) {
// New line box started
$this->init_line($box, $line_no);
return $line_no;
};
// Check if this box starts a new line
if ($box->get_left() < $this->_lines[$line_no]->right) {
$line_no++;
$this->init_line($box, $line_no);
return $line_no;
};
$this->_lines[$line_no]->extend($box);
return $line_no;
}
function merge_line(&$box, $line_no) {
$start_line = 0;
if ($line_no > 0 && count($box->_lines) > 0) {
if ($this->_lines[$line_no-1]->right + EPSILON > $box->_lines[0]->left) {
$this->_lines[$line_no-1]->right = max($box->_lines[0]->right, $this->_lines[$line_no-1]->right);
$this->_lines[$line_no-1]->top = max($box->_lines[0]->top, $this->_lines[$line_no-1]->top);
$this->_lines[$line_no-1]->bottom = min($box->_lines[0]->bottom, $this->_lines[$line_no-1]->bottom);
$start_line = 1;
};
};
$size = count($box->_lines);
for ($i=$start_line; $i<$size; $i++) {
$this->_lines[] = $box->_lines[$i]->copy();
};
return count($this->_lines);
}
function reflow_static(&$parent, &$context) {
GenericFormattedBox::reflow($parent, $context);
// Note that inline boxes (actually SPANS)
// are never added to the parent's line boxes
// Move current box to the parent's current coordinates
// Note that span box will start at the far left of the parent, NOT on its current X!
// Also, note that inline box can have margins, padding and borders!
$this->put_left($parent->get_left());
$this->put_top($parent->get_top() - $this->get_extra_top());
// first line of the SPAN will be offset to its parent current-x
// PLUS the left padding of current span!
$parent->_current_x += $this->get_extra_left();
$this->_current_x = $parent->_current_x;
// Note that the same operation IS NOT applied to parent current-y!
// The padding space is just extended to the top possibly OVERLAPPING the above boxes.
$this->width = 0;
// Reflow contents
$size = count($this->content);
for ($i=0; $i<$size; $i++) {
$child =& $this->content[$i];
// Add current element into _parent_ line box and reflow it
$child->reflow($parent, $context);
// In general, if inline box centained whitespace box only,
// it could be removed during reflow function call;
// let's check it and skip to next child
//
// if no children left AT ALL (so this box is empty), just exit
// Track the real height of the inline box; it will be used by other functions
// (say, functions calculating content height)
$this->extend_height($child->get_bottom_margin());
};
// Apply right extra space value (padding + border + margin)
$parent->_current_x += $this->get_extra_right();
// Margins of inline boxes are not collapsed
if ($this->get_first_data()) {
$context->pop_collapsed_margin();
$context->push_collapsed_margin( 0 );
};
}
function reflow_inline() {
$line_no = 0;
$size = count($this->content);
for ($i=0; $i<$size; $i++) {
$child =& $this->content[$i];
$child->reflow_inline();
if (!$child->is_null()) {
if (is_a($child,'InlineBox')) {
$line_no = $this->merge_line($child, $line_no);
} else {
$line_no = $this->extend_line($child, $line_no);
};
};
};
}
function reflow_whitespace(&$linebox_started, &$previous_whitespace) {
/**
* Anchors could have no content at all (like <a name="test"></a>).
* We should not remove such anchors, as this will break internal links
* in the document.
*/
$dest = $this->getCSSProperty(CSS_HTML2PS_LINK_DESTINATION);
if ($dest != '') { return; };
$size = count($this->content);
for ($i=0; $i<$size; $i++) {
$child =& $this->content[$i];
$child->reflow_whitespace($linebox_started, $previous_whitespace);
};
if ($this->is_null()) {
$this->parent->remove($this);
};
}
function get_extra_line_left() {
return $this->get_extra_left() + ($this->parent ? $this->parent->get_extra_line_left() : 0);
}
function get_extra_line_right() {
return $this->get_extra_right() + ($this->parent ? $this->parent->get_extra_line_right() : 0);
}
/**
* As "nowrap" properties applied to block-level boxes only, we may use simplified version of
* 'get_min_width' here
*/
function get_min_width(&$context) {
if (isset($this->_cache[CACHE_MIN_WIDTH])) {
return $this->_cache[CACHE_MIN_WIDTH];
}
$content_size = count($this->content);
/**
* If box does not have any content, its minimal width is determined by extra horizontal space
*/
if ($content_size == 0) {
return $this->_get_hor_extra();
};
$minw = $this->content[0]->get_min_width($context);
for ($i=1; $i<$content_size; $i++) {
$item = $this->content[$i];
if (!$item->out_of_flow()) {
$minw = max($minw, $item->get_min_width($context));
};
}
// Apply width constraint to min width. Return maximal value
$wc = $this->getCSSProperty(CSS_WIDTH);
$min_width = max($minw, $wc->apply($minw, $this->parent->get_width())) + $this->_get_hor_extra();
$this->_cache[CACHE_MIN_WIDTH] = $min_width;
return $min_width;
}
// Restore default behaviour, as this class is a ContainerBox descendant
function get_max_width_natural(&$context, $limit=10E6) {
return $this->get_max_width($context, $limit);
}
function offset($dx, $dy) {
$size = count($this->_lines);
for ($i=0; $i<$size; $i++) {
$this->_lines[$i]->offset($dx, $dy);
};
GenericInlineBox::offset($dx, $dy);
}
/**
* Deprecated
*/
function getLineBoxCount() {
return $this->get_line_box_count();
}
function &getLineBox($index) {
$line_box =& $this->_lines[$index];
return $line_box;
}
};
?>

View File

@@ -1,48 +0,0 @@
<?php
require_once(HTML2PS_DIR.'box.generic.formatted.php');
class SimpleInlineBox extends GenericBox {
function SimpleInlineBox() {
$this->GenericBox();
}
function readCSS(&$state) {
parent::readCSS($state);
$this->_readCSS($state,
array(CSS_TEXT_DECORATION,
CSS_TEXT_TRANSFORM));
// '-html2ps-link-target'
global $g_config;
if ($g_config["renderlinks"]) {
$this->_readCSS($state,
array(CSS_HTML2PS_LINK_TARGET));
};
}
function get_extra_left() {
return 0;
}
function get_extra_top() {
return 0;
}
function get_extra_right() {
return 0;
}
function get_extra_bottom() {
return 0;
}
function show(&$driver) {
parent::show($driver);
$strategy =& new StrategyLinkRenderingNormal();
$strategy->apply($this, $driver);
}
}
?>

View File

@@ -1,128 +0,0 @@
<?php
class ButtonBrokenImageBox extends BrokenImgBox {
var $_field_name;
var $_field_value;
var $_action_url;
function ButtonBrokenImageBox($width, $height, $alt, $field, $value, $action_url) {
$this->BrokenImgBox($width, $height, $alt);
$this->_field_name = $field;
$this->_field_value = $value;
$this->set_action_url($action_url);
}
function readCSS(&$state) {
parent::readCSS($state);
$this->_readCSS($state,
array(CSS_HTML2PS_FORM_ACTION));
}
function set_action_url($action_url) {
$this->_action_url = $action_url;
}
function show(&$driver) {
$status = parent::show($driver);
global $g_config;
if ($g_config['renderforms']) {
$driver->field_pushbuttonimage($this->get_left_padding(),
$this->get_top_padding(),
$this->get_width() + $this->get_padding_left() + $this->get_padding_right(),
$this->get_height() + $this->get_padding_top() + $this->get_padding_bottom(),
$this->_field_name,
$this->_field_value,
$this->_action_url);
};
return $status;
}
}
class ButtonImageBox extends ImgBox {
var $_field_name;
var $_field_value;
var $_action_url;
function ButtonImageBox($img, $field, $value, $action_url) {
$this->ImgBox($img);
$this->_field_name = $field;
$this->_field_value = $value;
$this->set_action_url($action_url);
}
function readCSS(&$state) {
parent::readCSS($state);
$this->_readCSS($state,
array(CSS_HTML2PS_FORM_ACTION));
}
function set_action_url($action_url) {
$this->_action_url = $action_url;
}
function show(&$driver) {
$status = parent::show($driver);
global $g_config;
if ($g_config['renderforms']) {
$driver->field_pushbuttonimage($this->get_left_padding(),
$this->get_top_padding(),
$this->get_width() + $this->get_padding_left() + $this->get_padding_right(),
$this->get_height() + $this->get_padding_top() + $this->get_padding_bottom(),
$this->_field_name,
$this->_field_value,
$this->_action_url);
};
return $status;
}
function &create(&$root, &$pipeline) {
$name = $root->get_attribute('name');
$value = $root->get_attribute('value');
$url_autofix = new AutofixUrl();
$src = $url_autofix->apply(trim($root->get_attribute("src")));
$src_img = Image::get($pipeline->guess_url($src), $pipeline);
if (is_null($src_img)) {
error_log(sprintf("Cannot open image at '%s'", $src));
if ($root->has_attribute('width')) {
$width = px2pt($root->get_attribute('width'));
} else {
$width = px2pt(BROKEN_IMAGE_DEFAULT_SIZE_PX);
};
if ($root->has_attribute('height')) {
$height = px2pt($root->get_attribute('height'));
} else {
$height = px2pt(BROKEN_IMAGE_DEFAULT_SIZE_PX);
};
$alt = $root->get_attribute('alt');
$css_state =& $pipeline->getCurrentCSSState();
$box =& new ButtonBrokenImagebox($width, $height, $alt, $name, $value,
$css_state->getProperty(CSS_HTML2PS_FORM_ACTION));
$box->readCSS($css_state);
return $box;
};
$css_state =& $pipeline->getCurrentCSSState();
$box =& new ButtonImageBox($src_img, $name, $value,
$css_state->getProperty(CSS_HTML2PS_FORM_ACTION));
$box->readCSS($css_state);
$box->_setupSize();
return $box;
}
}
?>

View File

@@ -1,66 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/box.input.password.php,v 1.6 2006/10/06 20:10:52 Konstantin Exp $
class PasswordInputBox extends TextInputBox {
function &create(&$root, &$pipeline) {
// Text to be displayed
if ($root->has_attribute('value')) {
$text = str_repeat("*",strlen($root->get_attribute("value")));
} else {
$text = "";
};
/**
* Input field name
*/
$name = $root->get_attribute('name');
$box =& new PasswordInputBox($text, $root->get_attribute("value"), $name);
$box->readCSS($pipeline->getCurrentCSSState());
$ibox = InlineBox::create_from_text(" ", WHITESPACE_PRE, $pipeline);
for ($i=0, $size = count($ibox->content); $i<$size; $i++) {
$box->add_child($ibox->content[$i]);
};
return $box;
}
function show(&$driver) {
// Now set the baseline of a button box to align it vertically when flowing isude the
// text line
$this->default_baseline = $this->content[0]->baseline + $this->get_extra_top();
$this->baseline = $this->content[0]->baseline + $this->get_extra_top();
/**
* If we're rendering the interactive form, the field content should not be rendered
*/
global $g_config;
if ($g_config['renderforms']) {
/**
* Render background/borders only
*/
$status = GenericFormattedBox::show($driver);
/**
* @todo encoding name?
* @todo font name?
* @todo check if font is embedded for PDFLIB
*/
$driver->field_password($this->get_left_padding(),
$this->get_top_padding(),
$this->get_width() + $this->get_padding_left() + $this->get_padding_right(),
$this->get_height() + $this->get_padding_top() + $this->get_padding_bottom(),
$this->_value,
$this->_field_name);
} else {
/**
* Render everything, including content
*/
$status = GenericContainerBox::show($driver);
}
return $status;
}
}
?>

View File

@@ -1,103 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/box.input.text.php,v 1.28 2007/01/03 19:39:29 Konstantin Exp $
/// define('SIZE_SPACE_KOEFF',1.65); (defined in tag.input.inc.php)
class TextInputBox extends InlineControlBox {
/**
* @var String contains the default value of this text field
* @access private
*/
var $_value;
function TextInputBox($value, $name) {
// Call parent constructor
$this->InlineBox();
$this->_value = $value;
$this->_field_name = $name;
}
function &create(&$root, &$pipeline) {
// Text to be displayed
if ($root->has_attribute('value')) {
$text = trim($root->get_attribute("value"));
} else {
$text = "";
};
/**
* Input field name
*/
$name = $root->get_attribute('name');
$box =& new TextInputBox($root->get_attribute("value"), $name);
$box->readCSS($pipeline->getCurrentCSSState());
/**
* Contents of the text box are somewhat similar to the inline box:
* a sequence of the text and whitespace boxes; we generate this sequence using
* the InlineBox, then copy contents of the created inline box to our button.
*
* @todo probably, create_from_text() function should be extracted to the common parent
* of inline boxes.
*/
$ibox = InlineBox::create_from_text($text, WHITESPACE_PRE, $pipeline);
for ($i=0, $size = count($ibox->content); $i<$size; $i++) {
$box->add_child($ibox->content[$i]);
};
return $box;
}
function get_height() {
$normal_height = parent::get_height();
$hc = $this->get_height_constraint();
if ($hc->is_null()) {
return $normal_height;
} else {
return $normal_height - $this->_get_vert_extra();
};
}
function show(&$driver) {
// Now set the baseline of a button box to align it vertically when flowing isude the
// text line
$this->default_baseline = $this->content[0]->baseline + $this->get_extra_top();
$this->baseline = $this->content[0]->baseline + $this->get_extra_top();
/**
* If we're rendering the interactive form, the field content should not be rendered
*/
global $g_config;
if ($g_config['renderforms']) {
/**
* Render background/borders only
*/
$status = GenericFormattedBox::show($driver);
/**
* @todo encoding name?
* @todo font name?
* @todo check if font is embedded for PDFLIB
*/
$driver->field_text($this->get_left_padding(),
$this->get_top_padding(),
$this->get_width() + $this->get_padding_left() + $this->get_padding_right(),
$this->get_height(),
$this->_value,
$this->_field_name);
} else {
/**
* Render everything, including content
*/
$status = GenericContainerBox::show($driver);
}
return $status;
}
}
?>

View File

@@ -1,74 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/box.input.textarea.php,v 1.5 2006/12/24 14:42:43 Konstantin Exp $
class TextAreaInputBox extends InlineBlockBox {
var $_field_name;
var $_value;
function TextAreaInputBox($value, $name) {
$this->InlineBlockBox();
$this->set_value($value);
$this->_field_name = $name;
}
function &create(&$root, &$pipeline) {
$value = $root->get_content();
$name = $root->get_attribute('name');
$box = new TextAreaInputBox($value, $name);
$box->readCSS($pipeline->getCurrentCSSState());
$box->create_content($root, $pipeline);
return $box;
}
function get_height() {
$normal_height = parent::get_height();
return $normal_height - $this->_get_vert_extra();
}
function get_min_width(&$context) {
return $this->get_max_width($context);
}
function get_max_width(&$context) {
return $this->get_width();
}
function get_value() {
return $this->_value;
}
function get_width() {
$normal_width = parent::get_width();
return $normal_width - $this->_get_hor_extra();
}
function set_value($value) {
$this->_value = $value;
}
function show(&$driver) {
/**
* If we're rendering the interactive form, the field content should not be rendered
*/
global $g_config;
if ($g_config['renderforms']) {
$status = GenericFormattedBox::show($driver);
$driver->field_multiline_text($this->get_left_padding(),
$this->get_top_padding(),
$this->get_width() + $this->get_padding_left() + $this->get_padding_right(),
$this->get_height() + $this->get_padding_top() + $this->get_padding_bottom(),
$this->_value,
$this->_field_name);
} else {
$status = GenericContainerBox::show($driver);
}
return $status;
}
}
?>

View File

@@ -1,57 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/box.legend.php,v 1.14 2006/07/09 09:07:44 Konstantin Exp $
class LegendBox extends GenericContainerBox {
function &create(&$root, &$pipeline) {
$box = new LegendBox($root);
$box->readCSS($pipeline->getCurrentCSSState());
$box->create_content($root, $pipeline);
return $box;
}
function LegendBox(&$root) {
// Call parent constructor
$this->GenericContainerBox();
$this->_current_x = 0;
$this->_current_y = 0;
}
// Flow-control
function reflow(&$parent, &$context) {
GenericFormattedBox::reflow($parent, $context);
// Determine upper-left _content_ corner position of current box
$this->put_left($parent->get_left_padding());
$this->put_top($parent->get_top_padding());
// Legends will not wrap
$this->put_full_width($this->get_max_width($context));
// Reflow contents
$this->reflow_content($context);
// Adjust legend position
$height = $this->get_full_height();
$this->offset(units2pt(LEGEND_HORIZONTAL_OFFSET) + $this->get_extra_left(),
$height/2);
// Adjust parent position
$parent->offset(0, -$height/2);
// Adjust parent content position
for ($i=0; $i<count($parent->content); $i++) {
if ($parent->content[$i]->uid != $this->uid) {
$parent->content[$i]->offset(0, -$height/2);
}
}
$parent->_current_y -= $height/2;
$parent->extend_height($this->get_bottom_margin());
}
function show(&$driver) {
// draw generic box
return GenericContainerBox::show($driver);
}
}
?>

View File

@@ -1,224 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/box.list-item.php,v 1.34 2006/09/07 18:38:12 Konstantin Exp $
class ListItemBox extends BlockBox {
var $size;
function &create(&$root, &$pipeline) {
$box = new ListItemBox($root, $pipeline);
$box->readCSS($pipeline->getCurrentCSSState());
/**
* Create text box containing item number
*/
$css_state =& $pipeline->getCurrentCSSState();
$css_state->pushState();
$css_state->setProperty(CSS_COLOR, CSSColor::parse('transparent'));
$list_style = $css_state->getProperty(CSS_LIST_STYLE);
$box->str_number_box = TextBox::create(CSSListStyleType::format_number($list_style->type,
$css_state->getProperty(CSS_HTML2PS_LIST_COUNTER)).". ",
'iso-8859-1',
$pipeline);
$box->str_number_box->baseline = $box->str_number_box->default_baseline;
$css_state->popState();
/**
* Create nested items
*/
$box->create_content($root, $pipeline);
return $box;
}
function readCSS(&$state) {
parent::readCSS($state);
$this->_readCSS($state,
array(CSS_LIST_STYLE));
// Pseudo-CSS properties
// '-list-counter'
// increase counter value
$value = $state->getProperty(CSS_HTML2PS_LIST_COUNTER) + 1;
$state->setProperty(CSS_HTML2PS_LIST_COUNTER, $value);
$state->setPropertyOnLevel(CSS_HTML2PS_LIST_COUNTER, CSS_PROPERTY_LEVEL_PARENT, $value);
// open the marker image if specified
$list_style = $this->getCSSProperty(CSS_LIST_STYLE);
if (!$list_style->image->is_default()) {
$this->marker_image = new ImgBox($list_style->image->_image);
$state->pushDefaultState();
$this->marker_image->readCSS($state);
$state->popState();
$this->marker_image->_setupSize();
} else {
$this->marker_image = null;
};
}
function ListItemBox(&$root, &$pipeline) {
// Call parent constructor
$this->BlockBox($root);
}
function reflow(&$parent, &$context) {
$list_style = $this->getCSSProperty(CSS_LIST_STYLE);
// If list-style-position is inside, we'll need to move marker box inside the
// list-item box and offset all content by its size;
if ($list_style->position === LSP_INSIDE) {
// Add marker box width to text-indent value
$this->_additional_text_indent = $this->get_marker_box_width();
};
// Procees with normal block box flow algorithm
BlockBox::reflow($parent, $context);
}
function reflow_text(&$driver) {
if (is_null($this->str_number_box->reflow_text($driver))) {
return null;
};
return GenericContainerBox::reflow_text($driver);
}
function show(&$viewport) {
// draw generic block box
if (is_null(BlockBox::show($viewport))) {
return null;
};
// Draw marker
/**
* Determine the marker box base X coordinate
* If possible, the marker box should be drawn immediately to the left of the first word in this
* box; this means that marker should be tied to the first text box, not to the left
* edge of the list block box
*/
$child = $this->get_first_data();
if (is_null($child)) {
$x = $this->get_left();
$list_style = $this->getCSSProperty(CSS_LIST_STYLE);
// If list-style-position is inside, we'll need to move marker box inside the
// list-item box and offset all content by its size;
if ($list_style->position === LSP_INSIDE) {
$x += $this->get_marker_box_width();
};
} else {
$x = $child->get_left();
};
// Determine the base Y coordinate of marker box
$element = $this->get_first_data();
if ($element) {
$y = $element->get_top() - $element->default_baseline;
} else {
$y = $this->get_top();
}
if (!is_null($this->marker_image)) {
$this->mb_image($viewport, $x, $y);
} else {
$list_style = $this->getCSSProperty(CSS_LIST_STYLE);
switch ($list_style->type) {
case LST_NONE:
// No marker at all
break;
case LST_DISC:
$this->mb_disc($viewport, $x, $y);
break;
case LST_CIRCLE:
$this->mb_circle($viewport, $x, $y);
break;
case LST_SQUARE:
$this->mb_square($viewport, $x, $y);
break;
default:
$this->mb_string($viewport, $x, $y);
break;
}
};
return true;
}
function get_marker_box_width() {
$list_style = $this->getCSSProperty(CSS_LIST_STYLE);
switch ($list_style->type) {
case LST_NONE:
// no marker box will be rendered at all
return 0;
case LST_DISC:
case LST_CIRCLE:
case LST_SQUARE:
// simple graphic marker
$font = $this->getCSSProperty(CSS_FONT);
return $font->size->getPoints();
default:
// string marker. Return the width of the marker text
return $this->str_number_box->get_full_width();
};
}
function mb_string(&$viewport, $x, $y) {
$this->str_number_box->put_top($y + $this->str_number_box->default_baseline);
$this->str_number_box->put_left($x - $this->str_number_box->get_full_width());
$this->str_number_box->show($viewport);
}
function mb_disc(&$viewport, $x, $y) {
$color = $this->getCSSProperty(CSS_COLOR);
$color->apply($viewport);
$font = $this->getCSSProperty(CSS_FONT);
$viewport->circle( $x - $font->size->getPoints()*0.5, $y + $font->size->getPoints()*0.4*HEIGHT_KOEFF, $font->size->getPoints() * BULLET_SIZE_KOEFF);
$viewport->fill();
}
function mb_circle(&$viewport, $x, $y) {
$color = $this->getCSSProperty(CSS_COLOR);
$color->apply($viewport);
$viewport->setlinewidth(0.1);
$font = $this->getCSSProperty(CSS_FONT);
$viewport->circle( $x - $font->size->getPoints()*0.5, $y + $font->size->getPoints()*0.4*HEIGHT_KOEFF, $font->size->getPoints() * BULLET_SIZE_KOEFF);
$viewport->stroke();
}
function mb_square(&$viewport, $x, $y) {
$color = $this->getCSSProperty(CSS_COLOR);
$color->apply($viewport);
$font = $this->getCSSProperty(CSS_FONT);
$viewport->rect($x - $font->size->getPoints()*0.512, $y + $font->size->getPoints()*0.3*HEIGHT_KOEFF, $font->size->getPoints() * 0.25, $font->size->getPoints() * 0.25);
$viewport->fill();
}
function mb_image(&$viewport, $x, $y) {
$font = $this->getCSSProperty(CSS_FONT);
$imagebox =& $this->marker_image;
$imagebox->moveto($x - $font->size->getPoints()*0.5 - $imagebox->get_width()/2,
$y + $font->size->getPoints()*0.4*HEIGHT_KOEFF + $imagebox->get_height()/2);
$imagebox->show($viewport);
}
function isBlockLevel() {
return true;
}
}
?>

View File

@@ -1,199 +0,0 @@
<?php
require_once(HTML2PS_DIR.'box.generic.inline.php');
/**
* @TODO: constructor required font properties to be known for the
* "content" element; on the other side, "content" element may be one
* without font properties defined/used. Currently, it is solved by
* adding CSS_FONT and CSS_LETTER_SPACING to GenericFormattedBox::readCSS
*/
class BoxNoteCall extends GenericInlineBox {
var $_note_number;
var $_note_content;
var $_note_marker_box;
var $_note_call_box;
function offset($dx, $dy) {
parent::offset($dx, $dy);
$this->_note_call_box->offset($dx, $dy);
}
function BoxNoteCall(&$content, &$pipeline) {
$this->GenericInlineBox();
$this->_note_content =& $content;
$this->copy_style($content);
$this->put_height_constraint(new HCConstraint(null, null, null));
/**
* Prepare ::note-call box
*/
$this->_note_call_box = InlineBox::create_from_text(CSSListStyleType::format_number(LST_DECIMAL, 99),
WHITESPACE_NORMAL,
$pipeline);
$this->_note_call_box->copy_style($content);
$this->_note_call_box->content[0]->copy_style($content);
$font = $this->_note_call_box->content[0]->getCSSProperty(CSS_FONT);
$font = $font->copy();
$font->size->scale(0.75);
$this->_note_call_box->content[0]->setCSSProperty(CSS_FONT, $font);
$this->_note_call_box->content[0]->setCSSProperty(CSS_VERTICAL_ALIGN, VA_SUPER);
$this->_note_call_box->content[0]->setCSSProperty(CSS_LINE_HEIGHT, CSS::getDefaultValue(CSS_LINE_HEIGHT));
/**
* Prepare ::marker box
*/
$this->_note_marker_box = InlineBox::create_from_text(CSSListStyleType::format_number(LST_DECIMAL, 99),
WHITESPACE_NORMAL,
$pipeline);
$this->_note_marker_box->copy_style($content);
$this->_note_marker_box->content[0]->copy_style($content);
$font = $this->_note_marker_box->content[0]->getCSSProperty(CSS_FONT);
$font = $font->copy();
$font->size->scale(0.5);
$this->_note_marker_box->content[0]->setCSSProperty(CSS_FONT, $font);
$margin = $this->_note_marker_box->content[0]->getCSSProperty(CSS_MARGIN);
$margin = $margin->copy();
$margin->right = Value::fromData(FOOTNOTE_MARKER_MARGIN, UNIT_PT);
$this->_note_marker_box->content[0]->setCSSProperty(CSS_MARGIN, $margin);
$this->_note_marker_box->content[0]->setCSSProperty(CSS_VERTICAL_ALIGN, VA_SUPER);
$this->_note_marker_box->content[0]->setCSSProperty(CSS_LINE_HEIGHT, CSS::getDefaultValue(CSS_LINE_HEIGHT));
}
function &create(&$content, &$pipeline) {
$box = new BoxNoteCall($content, $pipeline);
return $box;
}
function reflow(&$parent, &$context) {
$parent->append_line($this->_note_call_box);
$body = $parent;
while ($body->parent) {
$body = $body->parent;
};
/**
* Reflow note content
*/
$this->put_full_height(1000);
$this->put_full_width($body->get_width());
$this->_current_x = $this->get_left();
$this->_current_y = $this->get_top();
$this->_note_content->reflow($this, $context);
$this->_current_x = $this->get_left();
$this->_current_y = $this->get_top();
$this->_note_marker_box->reflow($this, $context);
$this->_current_x = $this->get_left();
$this->_current_y = $this->get_top();
$this->_note_call_box->reflow($this, $context);
// This prevents note-call box from affecting line height
$this->_note_call_box->put_full_height(0);
/**
* Reflow note-call itself
*/
$this->put_full_height(0);
$this->put_full_width(0);
$this->guess_corner($parent);
$parent->_current_x += $this->_note_call_box->content[0]->get_width();
$this->_note_call_box->put_full_width($this->_note_call_box->content[0]->get_width());
$this->_note_call_box->moveto($this->get_left(), $this->get_top());
// $last =& $parent->last_in_line();
// $last->note_call = true;
return true;
}
function reflow_whitespace(&$linebox_started, &$previous_whitespace) {
$ls = false;
$pw = false;
$this->_note_content->reflow_whitespace($ls, $pw);
}
function reflow_text(&$driver) {
$this->_note_content->reflow_text($driver);
$this->_note_marker_box->reflow_text($driver);
$this->_note_call_box->reflow_text($driver);
return true;
}
function _getFootnoteHeight(&$driver) {
if ($driver->getFootnoteCount() == 0) {
$footnote_height =
$this->_note_content->get_full_height() +
FOOTNOTE_LINE_TOP_GAP +
FOOTNOTE_LINE_BOTTOM_GAP;
} else {
$footnote_height =
$this->_note_content->get_full_height() +
FOOTNOTE_GAP;
};
return $footnote_height;
}
function show(&$driver) {
$footnote_height = $this->_getFootnoteHeight($driver);
if (!$driver->willContain($this, $footnote_height)) {
return true;
};
$driver->setFootnoteAreaHeight($driver->getFootnoteAreaHeight() + $footnote_height);
$driver->setFootnoteCount($driver->getFootnoteCount() + 1);
/**
* Prepare box containing note number
*/
$this->_note_number = $driver->getFootnoteCount();
/**
* Render reference number
*/
$this->_note_call_box->content[0]->words[0] = CSSListStyleType::format_number(LST_DECIMAL,
$this->_note_number);
$this->_note_call_box->show_fixed($driver);
return true;
}
function show_footnote(&$driver, $x, $y) {
/**
* Render note reference number
*/
$this->_note_marker_box->content[0]->words[0] = CSSListStyleType::format_number(LST_DECIMAL,
$this->_note_number);
$this->_note_marker_box->moveto($x, $y);
$this->_note_marker_box->show_fixed($driver);
/**
* Render note content
*/
$this->_note_content->moveto($x + $this->_note_marker_box->content[0]->get_width()*0.75,
$y);
$this->_note_content->show_fixed($driver);
return $y - $this->_note_content->get_full_height();
}
}
?>

View File

@@ -1,36 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/box.null.php,v 1.18 2006/07/09 09:07:44 Konstantin Exp $
class NullBox extends GenericInlineBox {
function get_min_width(&$context) { return 0; }
function get_max_width(&$context) { return 0; }
function get_height() { return 0; }
function NullBox() {
$this->GenericInlineBox();
}
function &create() {
$box =& new NullBox;
$css_state = new CSSState(CSS::get());
$css_state->pushState();
$box->readCSS($css_state);
return $box;
}
function show(&$viewport) {
return true;
}
function reflow_static(&$parent, &$context) {
// Move current "box" to parent current coordinates. It is REQUIRED,
// as some other routines uses box coordinates.
$this->put_left($parent->get_left());
$this->put_top($parent->get_top());
}
function is_null() { return true; }
}
?>

View File

@@ -1,476 +0,0 @@
<?php
/**
* @abstract
*/
class BoxPageMargin extends GenericContainerBox {
/**
* @param $at_rule CSSAtRuleMarginBox At-rule object describing margin box to be created
* @return Object Object of concrete BoxPageMargin descendant type
*/
function &create(&$pipeline, $at_rule) {
switch ($at_rule->getSelector()) {
case CSS_MARGIN_BOX_SELECTOR_TOP:
$box =& new BoxPageMarginTop($pipeline, $at_rule);
break;
case CSS_MARGIN_BOX_SELECTOR_TOP_LEFT_CORNER:
$box =& new BoxPageMarginTopLeftCorner($pipeline, $at_rule);
break;
case CSS_MARGIN_BOX_SELECTOR_TOP_LEFT:
$box =& new BoxPageMarginTopLeft($pipeline, $at_rule);
break;
case CSS_MARGIN_BOX_SELECTOR_TOP_CENTER:
$box =& new BoxPageMarginTopCenter($pipeline, $at_rule);
break;
case CSS_MARGIN_BOX_SELECTOR_TOP_RIGHT:
$box =& new BoxPageMarginTopRight($pipeline, $at_rule);
break;
case CSS_MARGIN_BOX_SELECTOR_TOP_RIGHT_CORNER:
$box =& new BoxPageMarginTopRightCorner($pipeline, $at_rule);
break;
case CSS_MARGIN_BOX_SELECTOR_BOTTOM:
$box =& new BoxPageMarginBottom($pipeline, $at_rule);
break;
case CSS_MARGIN_BOX_SELECTOR_BOTTOM_LEFT_CORNER:
$box =& new BoxPageMarginBottomLeftCorner($pipeline, $at_rule);
break;
case CSS_MARGIN_BOX_SELECTOR_BOTTOM_LEFT:
$box =& new BoxPageMarginBottomLeft($pipeline, $at_rule);
break;
case CSS_MARGIN_BOX_SELECTOR_BOTTOM_CENTER:
$box =& new BoxPageMarginBottomCenter($pipeline, $at_rule);
break;
case CSS_MARGIN_BOX_SELECTOR_BOTTOM_RIGHT:
$box =& new BoxPageMarginBottomRight($pipeline, $at_rule);
break;
case CSS_MARGIN_BOX_SELECTOR_BOTTOM_RIGHT_CORNER:
$box =& new BoxPageMarginBottomRightCorner($pipeline, $at_rule);
break;
case CSS_MARGIN_BOX_SELECTOR_LEFT_TOP:
$box =& new BoxPageMarginLeftTop($pipeline, $at_rule);
break;
case CSS_MARGIN_BOX_SELECTOR_LEFT_MIDDLE:
$box =& new BoxPageMarginLeftMiddle($pipeline, $at_rule);
break;
case CSS_MARGIN_BOX_SELECTOR_LEFT_BOTTOM:
$box =& new BoxPageMarginLeftBottom($pipeline, $at_rule);
break;
case CSS_MARGIN_BOX_SELECTOR_RIGHT_TOP:
$box =& new BoxPageMarginRightTop($pipeline, $at_rule);
break;
case CSS_MARGIN_BOX_SELECTOR_RIGHT_MIDDLE:
$box =& new BoxPageMarginRightMiddle($pipeline, $at_rule);
break;
case CSS_MARGIN_BOX_SELECTOR_RIGHT_BOTTOM:
$box =& new BoxPageMarginRightBottom($pipeline, $at_rule);
break;
default:
trigger_error("Unknown selector type", E_USER_ERROR);
};
return $box;
}
function BoxPageMargin(&$pipeline, $at_rule) {
$state =& $pipeline->getCurrentCSSState();
$state->pushDefaultState();
$root = null;
$at_rule->css->apply($root, $state, $pipeline);
$this->GenericContainerBox();
$this->readCSS($state);
$state->pushDefaultstate();
/**
* Check whether 'content' or '-html2ps-html-content' properties had been defined
* (if both properties are defined, -html2ps-html-content takes precedence)
*/
$raw_html_content =& $at_rule->getCSSProperty(CSS_HTML2PS_HTML_CONTENT);
$html_content = $raw_html_content->render($pipeline->get_counters());
if ($html_content !== '') {
// We should wrap html_content in DIV tag,
// as we treat only the very first box of the resulting DOM tree as margin box content
$html_content = html2xhtml("<div>".$html_content."</div>");
$tree = TreeBuilder::build($html_content);
$tree_root = traverse_dom_tree_pdf($tree);
$body_box =& create_pdf_box($tree_root, $pipeline);
$box =& $body_box->content[0];
} else {
$raw_content =& $at_rule->getCSSProperty(CSS_CONTENT);
$content = $raw_content->render($pipeline->get_counters());
$box =& InlineBox::create_from_text($content,
WHITESPACE_NORMAL,
$pipeline);
}
$this->add_child($box);
$state->popState();
$state->popState();
}
function get_cell_baseline() {
return 0;
}
function reflow(&$driver, &$media, $boxes) {
$context = new FlowContext;
$this->_position($media, $boxes, $context);
$this->setCSSProperty(CSS_WIDTH, new WCConstant($this->get_width()));
$this->put_height_constraint(new HCConstraint(array($this->height, false),
null,
null));
$this->reflow_content($context);
/**
* Apply vertical-align (behave like table cell)
*/
$va = CSSVerticalAlign::value2pdf($this->getCSSProperty(CSS_VERTICAL_ALIGN));
$va->apply_cell($this,$this->get_full_height(),0);
}
function show(&$driver) {
$this->offset(0, $driver->offset);
$this->show_fixed($driver);
}
function _calc_sizes($full_width, $left, $center, $right) {
$context = new FlowContext;
$left_width = $left->get_max_width($context);
$center_width = $center->get_max_width($context);
$right_width = $right->get_max_width($context);
$calculated_left_width = 0;
$calculated_center_width = 0;
$calculated_right_width = 0;
if ($center_width > 0) {
$calculated_center_width = $full_width * $center_width / ($center_width + 2*max($left_width, $right_width));
$calculated_left_width = ($full_width - $calculated_center_width) / 2;
$calculated_right_width = $calculated_left_width;
} elseif ($left_width == 0 && $right_width == 0) {
$calculated_center_width = 0;
$calculated_left_width = 0;
$calculated_right_width = 0;
} elseif ($left_width == 0) {
$calculated_center_width = 0;
$calculated_left_width = 0;
$calculated_right_width = $full_width;
} elseif ($right_width == 0) {
$calculated_center_width = 0;
$calculated_left_width = $full_width;
$calculated_right_width = 0;
} else {
$calculated_center_width = 0;
$calculated_left_width = $full_width * $left_width / ($left_width + $right_width);
$calculated_right_width = $full_width - $calculated_left_width;
};
return array($calculated_left_width,
$calculated_center_width,
$calculated_right_width);
}
}
class BoxPageMarginTop extends BoxPageMargin {
function _position($media, $boxes, $context) {
$this->put_left($this->get_extra_left() + 0);
$this->put_top(-$this->get_extra_top() +mm2pt($media->height()));
$this->put_full_width(mm2pt($media->width()));
$this->put_full_height(mm2pt($media->margins['top']));
$this->_current_x = $this->get_left();
$this->_current_y = $this->get_top();
}
}
class BoxPageMarginTopLeftCorner extends BoxPageMargin {
function _position($media, $boxes, $context) {
$this->put_left($this->get_extra_left() + 0);
$this->put_top(-$this->get_extra_top() +mm2pt($media->height()));
$this->put_full_width(mm2pt($media->margins['left']));
$this->put_full_height(mm2pt($media->margins['top']));
$this->_current_x = $this->get_left();
$this->_current_y = $this->get_top();
}
}
class BoxPageMarginTopLeft extends BoxPageMargin {
function _position($media, $boxes, $context) {
list($left, $center, $right) = $this->_calc_sizes(mm2pt($media->real_width()),
$boxes[CSS_MARGIN_BOX_SELECTOR_TOP_LEFT],
$boxes[CSS_MARGIN_BOX_SELECTOR_TOP_CENTER],
$boxes[CSS_MARGIN_BOX_SELECTOR_TOP_RIGHT]);
$this->put_left($this->get_extra_left() + mm2pt($media->margins['left']));
$this->put_top(-$this->get_extra_top() +mm2pt($media->height()));
$this->put_full_width($left);
$this->put_full_height(mm2pt($media->margins['top']));
$this->_current_x = $this->get_left();
$this->_current_y = $this->get_top();
}
}
class BoxPageMarginTopCenter extends BoxPageMargin {
function _position($media, $boxes, $context) {
list($left, $center, $right) = $this->_calc_sizes(mm2pt($media->real_width()),
$boxes[CSS_MARGIN_BOX_SELECTOR_TOP_LEFT],
$boxes[CSS_MARGIN_BOX_SELECTOR_TOP_CENTER],
$boxes[CSS_MARGIN_BOX_SELECTOR_TOP_RIGHT]);
$this->put_left($this->get_extra_left() + mm2pt($media->margins['left']) + $left);
$this->put_top(-$this->get_extra_top() +mm2pt($media->height()));
$this->put_full_width($center);
$this->put_full_height(mm2pt($media->margins['top']));
$this->_current_x = $this->get_left();
$this->_current_y = $this->get_top();
}
}
class BoxPageMarginTopRight extends BoxPageMargin {
function _position($media, $boxes, $context) {
list($left, $center, $right) = $this->_calc_sizes(mm2pt($media->real_width()),
$boxes[CSS_MARGIN_BOX_SELECTOR_TOP_LEFT],
$boxes[CSS_MARGIN_BOX_SELECTOR_TOP_CENTER],
$boxes[CSS_MARGIN_BOX_SELECTOR_TOP_RIGHT]);
$this->put_left($this->get_extra_left() + mm2pt($media->margins['left']) + $left + $center);
$this->put_top(-$this->get_extra_top() +mm2pt($media->height()));
$this->put_full_width($right);
$this->put_full_height(mm2pt($media->margins['top']));
$this->_current_x = $this->get_left();
$this->_current_y = $this->get_top();
}
}
class BoxPageMarginTopRightCorner extends BoxPageMargin {
function _position($media, $boxes, $context) {
$this->put_left($this->get_extra_left() + mm2pt($media->width() - $media->margins['right']));
$this->put_top(-$this->get_extra_top() +mm2pt($media->height()));
$this->put_full_width(mm2pt($media->margins['right']));
$this->put_full_height(mm2pt($media->margins['top']));
$this->_current_x = $this->get_left();
$this->_current_y = $this->get_top();
}
}
class BoxPageMarginBottomLeftCorner extends BoxPageMargin {
function _position($media, $boxes, $context) {
$this->put_left($this->get_extra_left() + 0);
$this->put_top(-$this->get_extra_top() +mm2pt($media->margins['bottom']));
$this->put_full_width(mm2pt($media->margins['left']));
$this->put_full_height(mm2pt($media->margins['bottom']));
$this->_current_x = $this->get_left();
$this->_current_y = $this->get_top();
}
}
class BoxPageMarginBottomLeft extends BoxPageMargin {
function _position($media, $boxes, $context) {
list($left, $center, $right) = $this->_calc_sizes(mm2pt($media->real_width()),
$boxes[CSS_MARGIN_BOX_SELECTOR_BOTTOM_LEFT],
$boxes[CSS_MARGIN_BOX_SELECTOR_BOTTOM_CENTER],
$boxes[CSS_MARGIN_BOX_SELECTOR_BOTTOM_RIGHT]);
$this->put_left($this->get_extra_left() + mm2pt($media->margins['left']));
$this->put_top(-$this->get_extra_top() +mm2pt($media->margins['bottom']));
$this->put_full_width($left);
$this->put_full_height(mm2pt($media->margins['bottom']));
$this->_current_x = $this->get_left();
$this->_current_y = $this->get_top();
}
}
class BoxPageMarginBottomCenter extends BoxPageMargin {
function _position($media, $boxes, $context) {
list($left, $center, $right) = $this->_calc_sizes(mm2pt($media->real_width()),
$boxes[CSS_MARGIN_BOX_SELECTOR_BOTTOM_LEFT],
$boxes[CSS_MARGIN_BOX_SELECTOR_BOTTOM_CENTER],
$boxes[CSS_MARGIN_BOX_SELECTOR_BOTTOM_RIGHT]);
$this->put_left($this->get_extra_left() + mm2pt($media->margins['left']) + $left);
$this->put_top(-$this->get_extra_top() +mm2pt($media->margins['bottom']));
$this->put_full_width($center);
$this->put_full_height(mm2pt($media->margins['bottom']));
$this->_current_x = $this->get_left();
$this->_current_y = $this->get_top();
}
}
class BoxPageMarginBottomRight extends BoxPageMargin {
function _position($media, $boxes, $context) {
list($left, $center, $right) = $this->_calc_sizes(mm2pt($media->real_width()),
$boxes[CSS_MARGIN_BOX_SELECTOR_BOTTOM_LEFT],
$boxes[CSS_MARGIN_BOX_SELECTOR_BOTTOM_CENTER],
$boxes[CSS_MARGIN_BOX_SELECTOR_BOTTOM_RIGHT]);
$this->put_left($this->get_extra_left() + mm2pt($media->margins['left']) + $left + $center);
$this->put_top(-$this->get_extra_top() +mm2pt($media->margins['bottom']));
$this->put_full_width($right);
$this->put_full_height(mm2pt($media->margins['bottom']));
$this->_current_x = $this->get_left();
$this->_current_y = $this->get_top();
}
}
class BoxPageMarginBottomRightCorner extends BoxPageMargin {
function _position($media, $boxes, $context) {
$this->put_left($this->get_extra_left() + mm2pt($media->width() - $media->margins['right']));
$this->put_top(-$this->get_extra_top() +mm2pt($media->margins['bottom']));
$this->put_full_width(mm2pt($media->margins['right']));
$this->put_full_height(mm2pt($media->margins['top']));
$this->_current_x = $this->get_left();
$this->_current_y = $this->get_top();
}
}
class BoxPageMarginBottom extends BoxPageMargin {
function _position($media, $boxes, $context) {
$this->put_left($this->get_extra_left() + 0);
$this->put_top(-$this->get_extra_top() +mm2pt($media->margins['bottom']));
$this->put_full_width(mm2pt($media->width()));
$this->put_full_height(mm2pt($media->margins['bottom']));
$this->_current_x = $this->get_left();
$this->_current_y = $this->get_top();
}
}
class BoxPageMarginLeftTop extends BoxPageMargin {
function _position($media, $boxes, $context) {
list($left, $center, $right) = $this->_calc_sizes(mm2pt($media->real_height()),
$boxes[CSS_MARGIN_BOX_SELECTOR_LEFT_TOP],
$boxes[CSS_MARGIN_BOX_SELECTOR_LEFT_MIDDLE],
$boxes[CSS_MARGIN_BOX_SELECTOR_LEFT_BOTTOM]);
$this->put_left($this->get_extra_left() + 0);
$this->put_top(-$this->get_extra_top() +mm2pt($media->height() - $media->margins['top']));
$this->put_full_height($left);
$this->put_full_width(mm2pt($media->margins['left']));
$this->_current_x = $this->get_left();
$this->_current_y = $this->get_top();
}
}
class BoxPageMarginLeftMiddle extends BoxPageMargin {
function _position($media, $boxes, $context) {
list($left, $center, $right) = $this->_calc_sizes(mm2pt($media->real_height()),
$boxes[CSS_MARGIN_BOX_SELECTOR_LEFT_TOP],
$boxes[CSS_MARGIN_BOX_SELECTOR_LEFT_MIDDLE],
$boxes[CSS_MARGIN_BOX_SELECTOR_LEFT_BOTTOM]);
$this->put_left($this->get_extra_left() + 0);
$this->put_top(-$this->get_extra_top() +mm2pt($media->height() - $media->margins['top']) - $left);
$this->put_full_height($center);
$this->put_full_width(mm2pt($media->margins['left']));
$this->_current_x = $this->get_left();
$this->_current_y = $this->get_top();
}
}
class BoxPageMarginLeftBottom extends BoxPageMargin {
function _position($media, $boxes, $context) {
list($left, $center, $right) = $this->_calc_sizes(mm2pt($media->real_height()),
$boxes[CSS_MARGIN_BOX_SELECTOR_LEFT_TOP],
$boxes[CSS_MARGIN_BOX_SELECTOR_LEFT_MIDDLE],
$boxes[CSS_MARGIN_BOX_SELECTOR_LEFT_BOTTOM]);
$this->put_left($this->get_extra_left() + 0);
$this->put_top(-$this->get_extra_top() +mm2pt($media->height() - $media->margins['top']) - $left - $center);
$this->put_full_height($right);
$this->put_full_width(mm2pt($media->margins['left']));
$this->_current_x = $this->get_left();
$this->_current_y = $this->get_top();
}
}
class BoxPageMarginRightTop extends BoxPageMargin {
function _position($media, $boxes, $context) {
list($left, $center, $right) = $this->_calc_sizes(mm2pt($media->real_height()),
$boxes[CSS_MARGIN_BOX_SELECTOR_RIGHT_TOP],
$boxes[CSS_MARGIN_BOX_SELECTOR_RIGHT_MIDDLE],
$boxes[CSS_MARGIN_BOX_SELECTOR_RIGHT_BOTTOM]);
$this->put_left($this->get_extra_left() + mm2pt($media->width() - $media->margins['right']));
$this->put_top(-$this->get_extra_top() +mm2pt($media->height() - $media->margins['top']));
$this->put_full_height($left);
$this->put_full_width(mm2pt($media->margins['right']));
$this->_current_x = $this->get_left();
$this->_current_y = $this->get_top();
}
}
class BoxPageMarginRightMiddle extends BoxPageMargin {
function _position($media, $boxes, $context) {
list($left, $center, $right) = $this->_calc_sizes(mm2pt($media->real_height()),
$boxes[CSS_MARGIN_BOX_SELECTOR_LEFT_TOP],
$boxes[CSS_MARGIN_BOX_SELECTOR_LEFT_MIDDLE],
$boxes[CSS_MARGIN_BOX_SELECTOR_LEFT_BOTTOM]);
$this->put_left($this->get_extra_left() + mm2pt($media->width() - $media->margins['right']));
$this->put_top(-$this->get_extra_top() +mm2pt($media->height() - $media->margins['top']) - $left);
$this->put_full_height($center);
$this->put_full_width(mm2pt($media->margins['right']));
$this->_current_x = $this->get_left();
$this->_current_y = $this->get_top();
}
}
class BoxPageMarginRightBottom extends BoxPageMargin {
function _position($media, $boxes, $context) {
list($left, $center, $right) = $this->_calc_sizes(mm2pt($media->real_height()),
$boxes[CSS_MARGIN_BOX_SELECTOR_LEFT_TOP],
$boxes[CSS_MARGIN_BOX_SELECTOR_LEFT_MIDDLE],
$boxes[CSS_MARGIN_BOX_SELECTOR_LEFT_BOTTOM]);
$this->put_left($this->get_extra_left() + mm2pt($media->width() - $media->margins['right']));
$this->put_top(-$this->get_extra_top() + mm2pt($media->height() - $media->margins['top']) - $left - $center);
$this->put_full_height($right);
$this->put_full_width(mm2pt($media->margins['right']));
$this->_current_x = $this->get_left();
$this->_current_y = $this->get_top();
}
}
?>

View File

@@ -1,49 +0,0 @@
<?php
class BoxPage extends GenericContainerBox {
function BoxPageMargin() {
$this->GenericContainerBox();
}
function &create(&$pipeline, $rules) {
$box =& new BoxPage();
$state =& $pipeline->getCurrentCSSState();
$state->pushDefaultState();
$rules->apply($state);
$box->readCSS($state);
$state->popState();
return $box;
}
function get_bottom_background() {
return $this->get_bottom_margin();
}
function get_left_background() {
return $this->get_left_margin();
}
function get_right_background() {
return $this->get_right_margin();
}
function get_top_background() {
return $this->get_top_margin();
}
function reflow(&$media) {
$this->put_left(mm2pt($media->margins['left']));
$this->put_top(mm2pt($media->height() - $media->margins['top']));
$this->put_width(mm2pt($media->real_width()));
$this->put_height(mm2pt($media->real_height()));
}
function show(&$driver) {
$this->offset(0, $driver->offset);
parent::show($driver);
}
}
?>

View File

@@ -1,576 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/box.php,v 1.45 2007/03/15 18:37:29 Konstantin Exp $
// This variable is used to track the reccurrent framesets
// they can be produced by inaccurate or malicious HTML-coder
// or by some cookie- or referrer- based identification system
//
$GLOBALS['g_frame_level'] = 0;
// Called when frame node is to be processed
function inc_frame_level() {
global $g_frame_level;
$g_frame_level ++;
if ($g_frame_level > MAX_FRAME_NESTING_LEVEL) {
trigger_error('Frame nesting too deep',
E_USER_ERROR);
};
}
// Called when frame (and all nested frames, of course) processing have been completed
//
function dec_frame_level() {
global $g_frame_level;
$g_frame_level --;
}
// Calculate 'display' CSS property according to CSS 2.1 paragraph 9.7
// "Relationships between 'display', 'position', and 'float'"
// (The last table in that paragraph)
//
// @return flag indication of current box need a block box wrapper
//
function _fix_display_position_float(&$css_state) {
// Specified value -> Computed value
// inline-table -> table
// inline, run-in, table-row-group, table-column, table-column-group, table-header-group,
// table-footer-group, table-row, table-cell, table-caption, inline-block -> block
// others-> same as specified
$display = $css_state->getProperty(CSS_DISPLAY);
switch ($display) {
case "inline-table":
$css_state->setProperty(CSS_DISPLAY, 'table');
return false;
case "inline":
case "run-in":
case "table-row-group":
case "table-column":
case "table-column-group":
case "table-header-group":
case "table-footer-group":
case "table-row":
case "table-cell":
case "table-caption":
case "inline-block":
// Note that as we're using some non-standard display values, we need to add them to translation table
$css_state->setProperty(CSS_DISPLAY, 'block');
return false;
// There are display types that cannot be directly converted to block; in this case we need to create a "wrapper" floating
// or positioned block box and put our real box into it.
case "-button":
case "-button-submit":
case "-button-reset":
case "-button-image":
case "-checkbox":
case "-iframe":
case "-image":
case "-legend":
case "-password":
case "-radio":
case "-select":
case "-text":
case "-textarea":
// No change
return true;
// Display values that are not affected by "float" property
case "-frame":
case "-frameset":
// 'block' is assumed here
default:
// No change
return false;
}
}
function &create_pdf_box(&$root, &$pipeline) {
if ($root != ''){
$valueNodeType = $root->node_type();
} else {
throw new Exception("ID_OUTPUT_NOT_GENERATE", 1);
}
switch ($valueNodeType) {
case XML_DOCUMENT_NODE:
// TODO: some magic from traverse_dom_tree
$box =& create_document_box($root, $pipeline);
return $box;
case XML_ELEMENT_NODE:
$box =& create_node_box($root, $pipeline);
return $box;
case XML_TEXT_NODE:
$box =& create_text_box($root, $pipeline);
return $box;
default:
die("Unsupported node type:".$root->node_type());
}
}
function &create_document_box(&$root, &$pipeline) {
return BlockBox::create($root, $pipeline);
}
function &create_node_box(&$root, &$pipeline) {
// Determine CSS proerty value for current child
$css_state =& $pipeline->getCurrentCSSState();
$css_state->pushDefaultState();
$default_css = $pipeline->getDefaultCSS();
$default_css->apply($root, $css_state, $pipeline);
// Store the default 'display' value; we'll need it later when checking for impossible tag/display combination
$handler =& CSS::get_handler(CSS_DISPLAY);
$default_display = $handler->get($css_state->getState());
// Initially generated boxes do not require block wrappers
// Block wrappers are required in following cases:
// - float property is specified for non-block box which cannot be directly converted to block box
// (a button, for example)
// - display set to block for such box
$need_block_wrapper = false;
// TODO: some inheritance magic
// Order is important. Items with most priority should be applied last
// Tag attributes
execute_attrs_before($root, $pipeline);
// CSS stylesheet
$css =& $pipeline->getCurrentCSS();
$css->apply($root, $css_state, $pipeline);
// values from 'style' attribute
if ($root->has_attribute("style")) {
parse_style_attr($root, $css_state, $pipeline);
};
_fix_tag_display($default_display, $css_state, $pipeline);
execute_attrs_after_styles($root, $pipeline);
// CSS 2.1:
// 9.7 Relationships between 'display', 'position', and 'float'
// The three properties that affect box generation and layout B
// 'display', 'position', and 'float' B interact as follows:
// 1. If 'display' has the value 'none', then 'position' and 'float' do not apply.
// In this case, the element generates no box.
$position_handler =& CSS::get_handler(CSS_POSITION);
$float_handler =& CSS::get_handler(CSS_FLOAT);
// 2. Otherwise, if 'position' has the value 'absolute' or 'fixed', the box is absolutely positioned,
// the computed value of 'float' is 'none', and display is set according to the table below.
// The position of the box will be determined by the 'top', 'right', 'bottom' and 'left' properties and
// the box's containing block.
$position = $css_state->getProperty(CSS_POSITION);
if ($position === CSS_PROPERTY_INHERIT) {
$position = $css_state->getInheritedProperty(CSS_POSITION);
};
if ($position === POSITION_ABSOLUTE ||
$position === POSITION_FIXED) {
$float_handler->replace(FLOAT_NONE, $css_state);
$need_block_wrapper |= _fix_display_position_float($css_state);
};
// 3. Otherwise, if 'float' has a value other than 'none', the box is floated and 'display' is set
// according to the table below.
$float = $css_state->getProperty(CSS_FLOAT);
if ($float != FLOAT_NONE) {
$need_block_wrapper |= _fix_display_position_float($css_state);
};
// Process some special nodes, which should not get their 'display' values overwritten (unless
// current display value is 'none'
$current_display = $css_state->getProperty(CSS_DISPLAY);
if ($current_display != 'none') {
switch ($root->tagname()) {
case 'body':
$handler =& CSS::get_handler(CSS_DISPLAY);
$handler->css('-body', $pipeline);
break;
case 'br':
$handler =& CSS::get_handler(CSS_DISPLAY);
$handler->css('-break', $pipeline);
break;
case 'img':
$handler =& CSS::get_handler(CSS_DISPLAY);
$need_block_wrapper |= ($handler->get($css_state->getState()) == "block");
$handler->css('-image', $pipeline);
break;
};
};
// 4. Otherwise, if the element is the root element, 'display' is set according to the table below.
// 5. Otherwise, the remaining 'display' property values apply as specified. (see _fix_display_position_float)
switch($css_state->getProperty(CSS_DISPLAY)) {
case "block":
$box =& BlockBox::create($root, $pipeline);
break;
case "-break":
$box =& BRBox::create($pipeline);
break;
case "-body":
$box =& BodyBox::create($root, $pipeline);
break;
case "-button":
$box =& ButtonBox::create($root, $pipeline);
break;
case "-button-reset":
$box =& ButtonResetBox::create($root, $pipeline);
break;
case "-button-submit":
$box =& ButtonSubmitBox::create($root, $pipeline);
break;
case "-button-image":
$box =& ButtonImageBox::create($root, $pipeline);
break;
case "-checkbox":
$box =& CheckBox::create($root, $pipeline);
break;
case "-form":
$box =& FormBox::create($root, $pipeline);
break;
case "-frame":
inc_frame_level();
$box =& FrameBox::create($root, $pipeline);
dec_frame_level();
break;
case "-frameset":
inc_frame_level();
$box =& FramesetBox::create($root, $pipeline);
dec_frame_level();
break;
case "-iframe":
inc_frame_level();
$box =& IFrameBox::create($root, $pipeline);
dec_frame_level();
break;
case "-textarea":
$box =& TextAreaInputBox::create($root, $pipeline);
break;
case "-image":
$box =& IMGBox::create($root, $pipeline);
break;
case "inline":
$box =& InlineBox::create($root, $pipeline);
break;
case "inline-block":
$box =& InlineBlockBox::create($root, $pipeline);
break;
case "-legend":
$box =& LegendBox::create($root, $pipeline);
break;
case "list-item":
$box =& ListItemBox::create($root, $pipeline);
break;
case "none":
$box =& NullBox::create();
break;
case "-radio":
$box =& RadioBox::create($root, $pipeline);
break;
case "-select":
$box =& SelectBox::create($root, $pipeline);
break;
case "table":
$box =& TableBox::create($root, $pipeline);
break;
case "table-cell":
$box =& TableCellBox::create($root, $pipeline);
break;
case "table-row":
$box =& TableRowBox::create($root, $pipeline);
break;
case "table-row-group":
case "table-header-group":
case "table-footer-group":
$box =& TableSectionBox::create($root, $pipeline);
break;
case "-text":
$box =& TextInputBox::create($root, $pipeline);
break;
case "-password":
$box =& PasswordInputBox::create($root, $pipeline);
break;
default:
/**
* If 'display' value is invalid or unsupported, fall back to 'block' mode
*/
error_log("Unsupported 'display' value: ".$css_state->getProperty(CSS_DISPLAY));
$box =& BlockBox::create($root, $pipeline);
break;
}
// Now check if pseudoelement should be created; in this case we'll use the "inline wrapper" box
// containing both generated box and pseudoelements
//
$pseudoelements = $box->getCSSProperty(CSS_HTML2PS_PSEUDOELEMENTS);
if ($pseudoelements & CSS_HTML2PS_PSEUDOELEMENTS_BEFORE) {
// Check if :before preudoelement exists
$before =& create_pdf_pseudoelement($root, SELECTOR_PSEUDOELEMENT_BEFORE, $pipeline);
if (!is_null($before)) {
$box->insert_child(0, $before);
};
};
if ($pseudoelements & CSS_HTML2PS_PSEUDOELEMENTS_AFTER) {
// Check if :after pseudoelement exists
$after =& create_pdf_pseudoelement($root, SELECTOR_PSEUDOELEMENT_AFTER, $pipeline);
if (!is_null($after)) {
$box->add_child($after);
};
};
// Check if this box needs a block wrapper (for example, floating button)
// Note that to keep float/position information, we clear the CSS stack only
// AFTER the wrapper box have been created; BUT we should clear the following CSS properties
// to avoid the fake wrapper box actually affect the layout:
// - margin
// - border
// - padding
// - background
//
if ($need_block_wrapper) {
/**
* Clear POSITION/FLOAT properties on wrapped boxes
*/
$box->setCSSProperty(CSS_POSITION, POSITION_STATIC);
$box->setCSSProperty(CSS_POSITION, FLOAT_NONE);
$wc = $box->getCSSProperty(CSS_WIDTH);
// Note that if element width have been set as a percentage constraint and we're adding a block wrapper,
// then we need to:
// 1. set the same percentage width constraint to the wrapper element (will be done implicilty if we will not
// modify the 'width' CSS handler stack
// 2. set the wrapped element's width constraint to 100%, otherwise it will be narrower than expected
if ($wc->isFraction()) {
$box->setCSSProperty(CSS_WIDTH, new WCFraction(1));
}
$handler =& CSS::get_handler(CSS_MARGIN);
$box->setCSSProperty(CSS_MARGIN, $handler->default_value());
/**
* Note: default border does not contain any fontsize-dependent
* values, so we may safely use zero as a base font size
*/
$border_handler =& CSS::get_handler(CSS_BORDER);
$value = $border_handler->default_value();
$value->units2pt(0);
$box->setCSSProperty(CSS_BORDER, $value);
$handler =& CSS::get_handler(CSS_PADDING);
$box->setCSSProperty(CSS_PADDING, $handler->default_value());
$handler =& CSS::get_handler(CSS_BACKGROUND);
$box->setCSSProperty(CSS_BACKGROUND, $handler->default_value());
// Create "clean" block box
$wrapper =& new BlockBox();
$wrapper->readCSS($pipeline->getCurrentCSSState());
$wrapper->add_child($box);
// Remove CSS propery values from stack
execute_attrs_after($root, $pipeline);
$css_state->popState();
return $wrapper;
} else {
// Remove CSS propery values from stack
execute_attrs_after($root, $pipeline);
$css_state->popState();
return $box;
};
}
function &create_text_box(&$root, &$pipeline) {
// Determine CSS property value for current child
$css_state =& $pipeline->getCurrentCSSState();
$css_state->pushDefaultTextState();
/**
* No text boxes generated by empty text nodes.
* Note that nodes containing spaces only are NOT empty, as they may
* correspond, for example, to whitespace between tags.
*/
if ($root->content !== "") {
$box =& InlineBox::create($root, $pipeline);
} else {
$box = null;
}
// Remove CSS property values from stack
$css_state->popState();
return $box;
}
function &create_pdf_pseudoelement($root, $pe_type, &$pipeline) {
// Store initial values to CSS stack
$css_state =& $pipeline->getCurrentCSSState();
$css_state->pushDefaultState();
// Initially generated boxes do not require block wrappers
// Block wrappers are required in following cases:
// - float property is specified for non-block box which cannot be directly converted to block box
// (a button, for example)
// - display set to block for such box
$need_block_wrapper = false;
$css =& $pipeline->getCurrentCSS();
$css->apply_pseudoelement($pe_type, $root, $css_state, $pipeline);
// Now, if no content found, just return
//
$content_obj = $css_state->getProperty(CSS_CONTENT);
if ($content_obj === CSS_PROPERTY_INHERIT) {
$content_obj = $css_state->getInheritedProperty(CSS_CONTENT);
};
$content = $content_obj->render($pipeline->get_counters());
if ($content === '') {
$css_state->popState();
$dummy = null;
return $dummy;
};
// CSS 2.1:
// 9.7 Relationships between 'display', 'position', and 'float'
// The three properties that affect box generation and layout B
// 'display', 'position', and 'float' B interact as follows:
// 1. If 'display' has the value 'none', then 'position' and 'float' do not apply.
// In this case, the element generates no box.
// 2. Otherwise, if 'position' has the value 'absolute' or 'fixed', the box is absolutely positioned,
// the computed value of 'float' is 'none', and display is set according to the table below.
// The position of the box will be determined by the 'top', 'right', 'bottom' and 'left' properties and
// the box's containing block.
$position_handler =& CSS::get_handler(CSS_POSITION);
$float_handler =& CSS::get_handler(CSS_FLOAT);
$position = $position_handler->get($css_state->getState());
if ($position === CSS_PROPERTY_INHERIT) {
$position = $css_state->getInheritedProperty(CSS_POSITION);
};
if ($position === POSITION_ABSOLUTE || $position === POSITION_FIXED) {
$float_handler->replace(FLOAT_NONE);
$need_block_wrapper |= _fix_display_position_float($css_state);
};
// 3. Otherwise, if 'float' has a value other than 'none', the box is floated and 'display' is set
// according to the table below.
$float = $float_handler->get($css_state->getState());
if ($float != FLOAT_NONE) {
$need_block_wrapper |= _fix_display_position_float($css_state);
};
// 4. Otherwise, if the element is the root element, 'display' is set according to the table below.
// 5. Otherwise, the remaining 'display' property values apply as specified. (see _fix_display_position_float)
// Note that pseudoelements may get only standard display values
$display_handler =& CSS::get_handler(CSS_DISPLAY);
$display = $display_handler->get($css_state->getState());
switch ($display) {
case 'block':
$box =& BlockBox::create_from_text($content, $pipeline);
break;
case 'inline':
$ws_handler =& CSS::get_handler(CSS_WHITE_SPACE);
$box =& InlineBox::create_from_text($content,
$ws_handler->get($css_state->getState()),
$pipeline);
break;
default:
error_log('Unsupported display value: '.$display_handler->get($css_state->getState()));
die;
}
// Check if this box needs a block wrapper (for example, floating button)
// Note that to keep float/position information, we clear the CSS stack only
// AFTER the wrapper box have been created; BUT we should clear the following CSS properties
// to avoid the fake wrapper box actually affect the layout:
// - margin
// - border
// - padding
// - background
//
if ($need_block_wrapper) {
$handler =& CSS::get_handler(CSS_MARGIN);
$handler->css("0",$pipeline);
pop_border();
push_border(default_border());
pop_padding();
push_padding(default_padding());
$handler =& CSS::get_handler(CSS_BACKGROUND);
$handler->css('transparent',$pipeline);
// Create "clean" block box
$wrapper =& new BlockBox();
$wrapper->readCSS($pipeline->getCurrentCSSState());
$wrapper->add_child($box);
$css_state->popState();
return $wrapper;
} else {
$css_state->popState();
return $box;
};
}
function is_inline(&$box) {
if (is_a($box, "TextBox")) { return true; };
$display = $box->getCSSProperty(CSS_DISPLAY);
return
$display === '-button' ||
$display === '-button-reset' ||
$display === '-button-submit' ||
$display === '-button-image' ||
$display === '-checkbox' ||
$display === '-image' ||
$display === 'inline' ||
$display === 'inline-block' ||
$display === 'none' ||
$display === '-radio' ||
$display === '-select' ||
$display === '-text' ||
$display === '-password';
}
function is_whitespace(&$box) {
return
is_a($box, "WhitespaceBox") ||
is_a($box, "NullBox");
}
function is_container(&$box) {
return is_a($box, "GenericContainerBox") &&
!is_a($box, "GenericInlineBox") ||
is_a($box, "InlineBox");
}
function is_span(&$box) {
return is_a($box, "InlineBox");
}
function is_table_cell(&$box) {
return is_a($box, "TableCellBox");
}
?>

View File

@@ -1,148 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/box.radiobutton.php,v 1.20 2006/11/11 13:43:51 Konstantin Exp $
require_once(HTML2PS_DIR.'box.inline.simple.php');
class RadioBox extends SimpleInlineBox {
var $_checked;
/**
* @var String name of radio button group
* @access private
*/
var $_group_name;
/**
* @var String value to be posted as this radio button value
* @access private
*/
var $_value;
function &create(&$root, &$pipeline) {
if(!class_exists('G')){
$realdocuroot = str_replace( '\\', '/', $_SERVER['DOCUMENT_ROOT'] );
$docuroot = explode( '/', $realdocuroot );
array_pop( $docuroot );
$pathhome = implode( '/', $docuroot ) . '/';
array_pop( $docuroot );
$pathTrunk = implode( '/', $docuroot ) . '/';
require_once($pathTrunk.'gulliver/system/class.g.php');
}
$checked = $root->has_attribute('checked');
$value = $root->get_attribute('value');
if (trim($value) == "") {
error_log("Radiobutton with empty 'value' attribute");
$value = sprintf("___Value%s",G::encryptOld(time().rand()));
};
$css_state = $pipeline->getCurrentCSSState();
$box =& new RadioBox($checked, $value,
$css_state->getProperty(CSS_HTML2PS_FORM_RADIOGROUP));
$box->readCSS($css_state);
return $box;
}
function RadioBox($checked, $value, $group_name) {
// Call parent constructor
$this->GenericBox();
// Check the box state
$this->_checked = $checked;
/**
* Store the form value for this radio button
*/
$this->_value = trim($value);
$this->_group_name = $group_name;
// Setup box size:
$this->default_baseline = units2pt(RADIOBUTTON_SIZE);
$this->height = units2pt(RADIOBUTTON_SIZE);
$this->width = units2pt(RADIOBUTTON_SIZE);
$this->setCSSProperty(CSS_DISPLAY,'-radio');
}
// Inherited from GenericFormattedBox
function get_min_width(&$context) {
return $this->get_full_width($context);
}
function get_max_width(&$context) {
return $this->get_full_width($context);
}
function get_max_width_natural(&$context) {
return $this->get_full_width($context);
}
function reflow(&$parent, &$context) {
GenericFormattedBox::reflow($parent, $context);
// set default baseline
$this->baseline = $this->default_baseline;
// append to parent line box
$parent->append_line($this);
// Determine coordinates of upper-left _margin_ corner
$this->guess_corner($parent);
// Offset parent current X coordinate
$parent->_current_x += $this->get_full_width();
// Extends parents height
$parent->extend_height($this->get_bottom_margin());
}
function show(&$driver) {
// Cet check center
$x = ($this->get_left() + $this->get_right()) / 2;
$y = ($this->get_top() + $this->get_bottom()) / 2;
// Calculate checkbox size
$size = $this->get_width() / 3;
// Draw checkbox
$driver->setlinewidth(0.25);
$driver->circle($x, $y, $size);
$driver->stroke();
/**
* Render the interactive button (if requested and possible)
* Also, if no value were specified, then this radio button should not be interactive
*/
global $g_config;
if ($g_config['renderforms'] && $this->_value != "") {
$driver->field_radio($x - $size,
$y + $size,
2*$size,
2*$size,
$this->_group_name,
$this->_value,
$this->_checked);
} else {
// Draw checkmark if needed
if ($this->_checked) {
$check_size = $this->get_width() / 6;
$driver->circle($x, $y, $check_size);
$driver->fill();
}
};
return true;
}
function get_ascender() {
return $this->get_height();
}
function get_descender() {
return 0;
}
}
?>

View File

@@ -1,128 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/box.select.php,v 1.24 2007/01/03 19:39:29 Konstantin Exp $
class SelectBox extends InlineControlBox {
var $_name;
var $_value;
var $_options;
function SelectBox($name, $value, $options) {
// Call parent constructor
$this->InlineBox();
$this->_name = $name;
$this->_value = $value;
$this->_options = $options;
}
function &create(&$root, &$pipeline) {
$name = $root->get_attribute('name');
$value = "";
$options = array();
// Get option list
$child = $root->first_child();
$content = "";
$size = 0;
while ($child) {
if ($child->node_type() == XML_ELEMENT_NODE) {
$size = max($size, strlen($child->get_content()));
if (empty($content) || $child->has_attribute("selected")) {
$content = preg_replace("/\s/"," ",$child->get_content());
$value = trim($child->get_content());
};
if ($child->has_attribute('value')) {
$options[] = array($child->get_attribute('value'),
$child->get_content());
} else {
$options[] = array($child->get_content(),
$child->get_content());
};
};
$child = $child->next_sibling();
};
$content = str_pad($content, $size*SIZE_SPACE_KOEFF + SELECT_SPACE_PADDING, " ");
$box =& new SelectBox($name, $value, $options);
$box->readCSS($pipeline->getCurrentCSSState());
// Add text to be rendered in non-interactive mode
$ibox = InlineBox::create_from_text($content, WHITESPACE_PRE, $pipeline);
for ($i=0, $size = count($ibox->content); $i<$size; $i++) {
$box->add_child($ibox->content[$i]);
};
return $box;
}
function show(&$driver) {
global $g_config;
if ($g_config['renderforms']) {
return $this->show_field($driver);
} else {
return $this->show_rendered($driver);
};
}
function show_field(&$driver) {
if (is_null(GenericFormattedBox::show($driver))) {
return null;
};
$driver->field_select($this->get_left_padding(),
$this->get_top_padding(),
$this->get_width() + $this->get_padding_left() + $this->get_padding_right(),
$this->get_height(),
$this->_name,
$this->_value,
$this->_options);
return true;
}
function show_rendered(&$driver) {
// Now set the baseline of a button box to align it vertically when flowing isude the
// text line
$this->default_baseline = $this->content[0]->baseline + $this->get_extra_top();
$this->baseline = $this->content[0]->baseline + $this->get_extra_top();
if (is_null(GenericContainerBox::show($driver))) {
return null;
};
$padding = $this->getCSSProperty(CSS_PADDING);
$button_height = $this->get_height() + $padding->top->value + $padding->bottom->value;
// Show arrow button box
$driver->setrgbcolor(0.93, 0.93, 0.93);
$driver->moveto($this->get_right_padding(), $this->get_top_padding());
$driver->lineto($this->get_right_padding() - $button_height, $this->get_top_padding());
$driver->lineto($this->get_right_padding() - $button_height, $this->get_bottom_padding());
$driver->lineto($this->get_right_padding(), $this->get_bottom_padding());
$driver->closepath();
$driver->fill();
// Show box boundary
$driver->setrgbcolor(0,0,0);
$driver->moveto($this->get_right_padding(), $this->get_top_padding());
$driver->lineto($this->get_right_padding() - $button_height, $this->get_top_padding());
$driver->lineto($this->get_right_padding() - $button_height, $this->get_bottom_padding());
$driver->lineto($this->get_right_padding(), $this->get_bottom_padding());
$driver->closepath();
$driver->stroke();
// Show arrow
$driver->setrgbcolor(0,0,0);
$driver->moveto($this->get_right_padding() - SELECT_BUTTON_TRIANGLE_PADDING,
$this->get_top_padding() - SELECT_BUTTON_TRIANGLE_PADDING);
$driver->lineto($this->get_right_padding() - $button_height + SELECT_BUTTON_TRIANGLE_PADDING,
$this->get_top_padding() - SELECT_BUTTON_TRIANGLE_PADDING);
$driver->lineto($this->get_right_padding() - $button_height/2, $this->get_bottom_padding() + SELECT_BUTTON_TRIANGLE_PADDING);
$driver->closepath();
$driver->fill();
return true;
}
}
?>

View File

@@ -1,73 +0,0 @@
<?php
class FakeTableCellBox extends TableCellBox {
var $colspan;
var $rowspan;
function create(&$pipeline) {
$box =& new FakeTableCellBox;
$css_state =& $pipeline->getCurrentCSSState();
$css_state->pushDefaultState();
$box->readCSS($css_state);
$nullbox =& new NullBox;
$nullbox->readCSS($css_state);
$box->add_child($nullbox);
$box->readCSS($css_state);
$css_state->popState();
return $box;
}
function FakeTableCellBox() {
// Required to reset any constraints initiated by CSS properties
$this->colspan = 1;
$this->rowspan = 1;
$this->GenericContainerBox();
$this->setCSSProperty(CSS_DISPLAY, 'table-cell');
$this->setCSSProperty(CSS_VERTICAL_ALIGN, VA_MIDDLE);
}
function show(&$viewport) {
return true;
}
function is_fake() {
return true;
}
function get_width_constraint() {
return new WCNone();
}
function get_height_constraint() {
return new HCConstraint(null, null, null);
}
function get_height() {
return 0;
}
function get_top_margin() {
return 0;
}
function get_full_height() {
return 0;
}
function get_max_width() {
return 0;
}
function get_min_width() {
return 0;
}
}
?>

View File

@@ -1,322 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/box.table.cell.php,v 1.40 2007/01/24 18:55:45 Konstantin Exp $
class TableCellBox extends GenericContainerBox {
var $colspan;
var $rowspan;
var $column;
var $_suppress_first;
var $_suppress_last;
function get_min_width(&$context) {
if (isset($this->_cache[CACHE_MIN_WIDTH])) {
return $this->_cache[CACHE_MIN_WIDTH];
};
$content_size = count($this->content);
/**
* If box does not have any context, its minimal width is determined by extra horizontal space:
* padding, border width and margins
*/
if ($content_size == 0) {
$min_width = $this->_get_hor_extra();
$this->_cache[CACHE_MIN_WIDTH] = $min_width;
return $min_width;
};
/**
* If we're in 'nowrap' mode, minimal and maximal width will be equal
*/
$white_space = $this->getCSSProperty(CSS_WHITE_SPACE);
$pseudo_nowrap = $this->getCSSProperty(CSS_HTML2PS_NOWRAP);
if ($white_space == WHITESPACE_NOWRAP ||
$pseudo_nowrap == NOWRAP_NOWRAP) {
$min_width = $this->get_min_nowrap_width($context);
$this->_cache[CACHE_MIN_WIDTH] = $min_width;
return $min_width;
}
/**
* We need to add text indent size to the with of the first item
*/
$start_index = 0;
while ($start_index < $content_size &&
$this->content[$start_index]->out_of_flow()) {
$start_index++;
};
if ($start_index < $content_size) {
$ti = $this->getCSSProperty(CSS_TEXT_INDENT);
$minw =
$ti->calculate($this) +
$this->content[$start_index]->get_min_width($context);
} else {
$minw = 0;
};
for ($i=$start_index; $i<$content_size; $i++) {
$item =& $this->content[$i];
if (!$item->out_of_flow()) {
$minw = max($minw, $item->get_min_width_natural($context));
};
}
/**
* Apply width constraint to min width. Return maximal value
*/
$wc = $this->getCSSProperty(CSS_WIDTH);
$min_width = max($minw,
$wc->apply($minw, $this->parent->get_width())) + $this->_get_hor_extra();
$this->_cache[CACHE_MIN_WIDTH] = $min_width;
return $min_width;
}
function readCSS(&$state) {
parent::readCSS($state);
$this->_readCSS($state,
array(CSS_BORDER_COLLAPSE));
$this->_readCSSLengths($state,
array(CSS_HTML2PS_CELLPADDING,
CSS_HTML2PS_CELLSPACING,
CSS_HTML2PS_TABLE_BORDER));
}
function isCell() {
return true;
}
function is_fake() {
return false;
}
function &create(&$root, &$pipeline) {
$css_state = $pipeline->getCurrentCSSState();
$box =& new TableCellBox();
$box->readCSS($css_state);
// Use cellspacing / cellpadding values from the containing table
$cellspacing = $box->getCSSProperty(CSS_HTML2PS_CELLSPACING);
$cellpadding = $box->getCSSProperty(CSS_HTML2PS_CELLPADDING);
// FIXME: I'll need to resolve that issue with COLLAPSING border model. Now borders
// are rendered separated
// if not border set explicitly, inherit value set via border attribute of TABLE tag
$border_handler = CSS::get_handler(CSS_BORDER);
if ($border_handler->is_default($box->getCSSProperty(CSS_BORDER))) {
$table_border = $box->getCSSProperty(CSS_HTML2PS_TABLE_BORDER);
$box->setCSSProperty(CSS_BORDER, $table_border);
};
$margin =& CSS::get_handler(CSS_MARGIN);
$box->setCSSProperty(CSS_MARGIN, $margin->default_value());
$h_padding =& CSS::get_handler(CSS_PADDING);
$padding = $box->getCSSProperty(CSS_PADDING);
if ($h_padding->is_default($padding)) {
$padding->left->_units = $cellpadding;
$padding->left->auto = false;
$padding->left->percentage = null;
$padding->right->_units = $cellpadding;
$padding->right->auto = false;
$padding->right->percentage = null;
$padding->top->_units = $cellpadding;
$padding->top->auto = false;
$padding->top->percentage = null;
$padding->bottom->_units = $cellpadding;
$padding->bottom->auto = false;
$padding->bottom->percentage = null;
/**
* Note that cellpadding/cellspacing values never use font-size based units
* ('em' and 'ex'), so we may pass 0 as base_font_size parameter - it
* will not be used anyway
*/
$padding->units2pt(0);
$box->setCSSProperty(CSS_PADDING, $padding);
};
if ($box->getCSSProperty(CSS_BORDER_COLLAPSE) != BORDER_COLLAPSE) {
$margin_value = $box->getCSSProperty(CSS_MARGIN);
if ($margin->is_default($margin_value)) {
$length = $cellspacing->copy();
$length->scale(0.5);
$margin_value->left->_units = $length;
$margin_value->left->auto = false;
$margin_value->left->percentage = null;
$margin_value->right->_units = $length;
$margin_value->right->auto = false;
$margin_value->right->percentage = null;
$margin_value->top->_units = $length;
$margin_value->top->auto = false;
$margin_value->top->percentage = null;
$margin_value->bottom->_units = $length;
$margin_value->bottom->auto = false;
$margin_value->bottom->percentage = null;
/**
* Note that cellpadding/cellspacing values never use font-size based units
* ('em' and 'ex'), so we may pass 0 as base_font_size parameter - it
* will not be used anyway
*/
$margin_value->units2pt(0);
$box->setCSSProperty(CSS_MARGIN, $margin_value);
}
};
// Save colspan and rowspan information
$box->colspan = max(1,(int)$root->get_attribute('colspan'));
$box->rowspan = max(1,(int)$root->get_attribute('rowspan'));
// Create content
// 'vertical-align' CSS value is not inherited from the table cells
$css_state->pushState();
$handler =& CSS::get_handler(CSS_VERTICAL_ALIGN);
$handler->replace($handler->default_value(),
$css_state);
$box->create_content($root, $pipeline);
global $g_config;
if ($g_config['mode'] == "quirks") {
// QUIRKS MODE:
// H1-H6 and P elements should have their top/bottom margin suppressed if they occur as the first/last table cell child
// correspondingly; note that we cannot do it usung CSS rules, as there's no selectors for the last child.
//
$child = $root->first_child();
if ($child) {
while ($child && $child->node_type() != XML_ELEMENT_NODE) {
$child = $child->next_sibling();
};
if ($child) {
if (array_search(strtolower($child->tagname()), array("h1","h2","h3","h4","h5","h6","p"))) {
$box->_suppress_first = true;
}
};
};
$child = $root->last_child();
if ($child) {
while ($child && $child->node_type() != XML_ELEMENT_NODE) {
$child = $child->previous_sibling();
};
if ($child) {
if (array_search(strtolower($child->tagname()), array("h1","h2","h3","h4","h5","h6","p"))) {
$box->_suppress_last = true;
}
};
};
};
// pop the default vertical-align value
$css_state->popState();
return $box;
}
function TableCellBox() {
// Call parent constructor
$this->GenericContainerBox();
$this->_suppress_first = false;
$this->_suppress_last = false;
$this->colspan = 1;
$this->rowspan = 1;
// This value will be overwritten in table 'normalize_parent' method
//
$this->column = 0;
$this->row = 0;
}
// Inherited from GenericFormattedBox
function get_cell_baseline() {
$content = $this->get_first_data();
if (is_null($content)) {
return 0;
}
return $content->baseline;
}
// Flow-control
function reflow(&$parent, &$context) {
GenericFormattedBox::reflow($parent, $context);
global $g_config;
$size = count($this->content);
if ($g_config['mode'] == "quirks" && $size > 0) {
// QUIRKS MODE:
// H1-H6 and P elements should have their top/bottom margin suppressed if they occur as the first/last table cell child
// correspondingly; note that we cannot do it usung CSS rules, as there's no selectors for the last child.
//
$first =& $this->get_first();
if (!is_null($first) && $this->_suppress_first && $first->isBlockLevel()) {
$first->margin->top->value = 0;
$first->margin->top->percentage = null;
};
$last =& $this->get_last();
if (!is_null($last) && $this->_suppress_last && $last->isBlockLevel()) {
$last->margin->bottom->value = 0;
$last->margin->bottom->percentage = null;
};
};
// Determine upper-left _content_ corner position of current box
$this->put_left($parent->_current_x + $this->get_extra_left());
// NOTE: Table cell margin is used as a cell-spacing value
$border = $this->getCSSProperty(CSS_BORDER);
$padding = $this->getCSSProperty(CSS_PADDING);
$this->put_top($parent->_current_y -
$border->top->get_width() -
$padding->top->value);
// CSS 2.1:
// Floats, absolutely positioned elements, inline-blocks, table-cells, and elements with 'overflow' other than
// 'visible' establish new block formatting contexts.
$context->push();
$context->push_container_uid($this->uid);
// Reflow cell content
$this->reflow_content($context);
// Extend the table cell height to fit all contained floats
//
// Determine the bottom edge corrdinate of the bottommost float
//
$float_bottom = $context->float_bottom();
if (!is_null($float_bottom)) {
$this->extend_height($float_bottom);
};
// Restore old context
$context->pop_container_uid();
$context->pop();
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -1,220 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/box.table.row.php,v 1.29 2007/01/24 18:55:45 Konstantin Exp $
class TableRowBox extends GenericContainerBox {
var $rows;
var $colspans;
var $rowspans;
function &create(&$root, &$pipeline) {
$box =& new TableRowBox();
$box->readCSS($pipeline->getCurrentCSSState());
$child = $root->first_child();
while ($child) {
$child_box =& create_pdf_box($child, $pipeline);
$box->add_child($child_box);
$child = $child->next_sibling();
};
return $box;
}
function add_child(&$item) {
if ($item->isCell()) {
GenericContainerBox::add_child($item);
};
}
function TableRowBox() {
// Call parent constructor
$this->GenericContainerBox();
}
// Normalize colspans by adding fake cells after the "colspanned" cell
// Say, if we've got the following row:
// <tr><td colspan="3">1</td><td>2</td></tr>
// we should get row containing four cells after normalization;
// first contains "1"
// second and third are completely empty
// fourth contains "2"
function normalize(&$pipeline) {
for ($i=0, $size = count($this->content); $i < $size; $i++) {
for ($j=1; $j<$this->content[$i]->colspan; $j++) {
$this->add_fake_cell_after($i, $pipeline);
// Note that add_fake_cell_after will increase the length of current row by one cell,
// so we must increase $size variable
$size++;
};
};
}
function add_fake_cell_after($index, &$pipeline) {
array_splice($this->content, $index+1, 0, array(FakeTableCellBox::create($pipeline)));
}
function add_fake_cell_before($index, &$pipeline) {
array_splice($this->content, $index, 0, array(FakeTableCellBox::create($pipeline)));
}
function append_fake_cell(&$pipeline) {
$this->content[] = FakeTableCellBox::create($pipeline);
}
// Table specific
function table_resize_row($height, $top) {
// Do cell vertical-align
// Calculate row baseline
$baseline = $this->get_row_baseline();
// Process cells contained in current row
for ($i=0, $size = count($this->content); $i<$size; $i++) {
$cell =& $this->content[$i];
// Offset cell if needed
$cell->offset(0,
$top -
$cell->get_top_margin());
// Vertical-align cell (do not apply to rowspans)
if ($cell->rowspan == 1) {
$va = $cell->getCSSProperty(CSS_VERTICAL_ALIGN);
$va_fun = CSSVerticalAlign::value2pdf($va);
$va_fun->apply_cell($cell, $height, $baseline);
// Expand cell to full row height
$cell->put_full_height($height);
}
}
}
function get_row_baseline() {
$baseline = 0;
for ($i=0, $size = count($this->content); $i<$size; $i++) {
$cell = $this->content[$i];
if ($cell->rowspan == 1) {
$baseline = max($baseline, $cell->get_cell_baseline());
};
}
return $baseline;
}
function get_colspans($row_index) {
$colspans = array();
for ($i=0, $size = count($this->content); $i<$size; $i++) {
// Check if current colspan will run off the right table edge
if ($this->content[$i]->colspan > 1) {
$colspan = new CellSpan;
$colspan->row = $row_index;
$colspan->column = $i;
$colspan->size = $this->content[$i]->colspan;
$colspans[] = $colspan;
}
}
return $colspans;
}
function get_rowspans($row_index) {
$spans = array();
for ($i=0; $i<count($this->content); $i++) {
if ($this->content[$i]->rowspan > 1) {
$rowspan = new CellSpan;
$rowspan->row = $row_index;
$rowspan->column = $i;
$rowspan->size = $this->content[$i]->rowspan;
$spans[] = $rowspan;
}
}
return $spans;
}
// Column widths
function get_table_columns_max_widths(&$context) {
$widths = array();
for ($i=0; $i<count($this->content); $i++) {
// For now, colspans are treated as zero-width; they affect
// column widths only in parent *_fit function
if ($this->content[$i]->colspan > 1) {
$widths[] = 0;
} else {
$widths[] = $this->content[$i]->get_max_width($context);
}
}
return $widths;
}
function get_table_columns_min_widths(&$context) {
$widths = array();
for ($i=0; $i<count($this->content); $i++) {
// For now, colspans are treated as zero-width; they affect
// column widths only in parent *_fit function
if ($this->content[$i]->colspan > 1) {
$widths[] = 0;
} else {
$widths[] = $this->content[$i]->get_min_width($context);
};
}
return $widths;
}
function row_height() {
// Calculate height of each cell contained in this row
$height = 0;
for ($i=0; $i<count($this->content); $i++) {
if ($this->content[$i]->rowspan <= 1) {
$height = max($height, $this->content[$i]->get_full_height());
}
}
return $height;
}
/**
* Note that we SHOULD owerride the show method inherited from GenericContainerBox,
* as it MAY draw row background in case it was set via CSS rules. As row box
* is a "fake" box and will never have reasonable size and/or position in the layout,
* we should prevent this
*/
function show(&$viewport) {
// draw content
$size = count($this->content);
for ($i=0; $i < $size; $i++) {
/**
* We'll check the visibility property here
* Reason: all boxes (except the top-level one) are contained in some other box,
* so every box will pass this check. The alternative is to add this check into every
* box class show member.
*
* The only exception of absolute positioned block boxes which are drawn separately;
* their show method is called explicitly; the similar check should be performed there
*/
$cell =& $this->content[$i];
$visibility = $cell->getCSSProperty(CSS_VISIBILITY);
if ($visibility === VISIBILITY_VISIBLE) {
if (is_null($cell->show($viewport))) {
return null;
};
};
}
return true;
}
function isTableRow() {
return true;
}
}
?>

View File

@@ -1,55 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/box.table.section.php,v 1.14 2006/10/28 12:24:16 Konstantin Exp $
class TableSectionBox extends GenericContainerBox {
function &create(&$root, &$pipeline) {
$state =& $pipeline->getCurrentCSSState();
$box =& new TableSectionBox();
$box->readCSS($state);
// Automatically create at least one table row
$row = new TableRowBox();
$row->readCSS($state);
$box->add_child($row);
// Parse table contents
$child = $root->first_child();
while ($child) {
$child_box =& create_pdf_box($child, $pipeline);
$box->add_child($child_box);
$child = $child->next_sibling();
};
return $box;
}
function TableSectionBox() {
$this->GenericContainerBox();
}
// Overrides default 'add_child' in GenericFormattedBox
function add_child(&$item) {
// Check if we're trying to add table cell to current table directly, without any table-rows
if ($item->isCell()) {
// Add cell to the last row
$last_row =& $this->content[count($this->content)-1];
$last_row->add_child($item);
} elseif ($item->isTableRow()) {
// If previous row is empty, remove it (get rid of automatically generated table row in constructor)
if (count($this->content) > 0) {
if (count($this->content[count($this->content)-1]->content) == 0) {
array_pop($this->content);
}
};
// Just add passed row
$this->content[] =& $item;
};
}
function isTableSection() {
return true;
}
}
?>

View File

@@ -1,653 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/box.text.php,v 1.54 2007/03/15 18:37:29 Konstantin Exp $
require_once(HTML2PS_DIR.'box.inline.simple.php');
// TODO: from my POV, it wll be better to pass the font- or CSS-controlling object to the constructor
// instead of using globally visible functions in 'show'.
define('SYMBOL_NBSP', chr(160));
class TextBox extends SimpleInlineBox {
var $words;
var $encodings;
var $hyphens;
var $_widths;
var $_word_widths;
var $_wrappable;
var $wrapped;
function TextBox() {
$this->SimpleInlineBox();
$this->words = array();
$this->encodings = array();
$this->hyphens = array();
$this->_word_widths = array();
$this->_wrappable = array();
$this->wrapped = null;
$this->_widths = array();
$this->font_size = 0;
$this->ascender = 0;
$this->descender = 0;
$this->width = 0;
$this->height = 0;
}
/**
* Check if given subword contains soft hyphens and calculate
*/
function _make_wrappable(&$driver, $base_width, $font_name, $font_size, $subword_index) {
$hyphens = $this->hyphens[$subword_index];
$wrappable = array();
foreach ($hyphens as $hyphen) {
$subword_wrappable_index = $hyphen;
$subword_wrappable_width = $base_width + $driver->stringwidth(substr($this->words[$subword_index], 0, $subword_wrappable_index),
$font_name,
$this->encodings[$subword_index],
$font_size);
$subword_full_width = $subword_wrappable_width + $driver->stringwidth('-',
$font_name,
"iso-8859-1",
$font_size);
$wrappable[] = array($subword_index, $subword_wrappable_index, $subword_wrappable_width, $subword_full_width);
};
return $wrappable;
}
function get_height() {
return $this->height;
}
function put_height($value) {
$this->height = $value;
}
// Apply 'line-height' CSS property; modifies the default_baseline value
// (NOT baseline, as it is calculated - and is overwritten - in the close_line
// method of container box
//
// Note that underline position (or 'descender' in terms of PDFLIB) -
// so, simple that space of text box under the baseline - is scaled too
// when 'line-height' is applied
//
function _apply_line_height() {
$height = $this->get_height();
$under = $height - $this->default_baseline;
$line_height = $this->getCSSProperty(CSS_LINE_HEIGHT);
if ($height > 0) {
$scale = $line_height->apply($this->ascender + $this->descender) / ($this->ascender + $this->descender);
} else {
$scale = 0;
};
// Calculate the height delta of the text box
$delta = $height * ($scale-1);
$this->put_height(($this->ascender + $this->descender)*$scale);
$this->default_baseline = $this->default_baseline + $delta/2;
}
function _get_font_name(&$viewport, $subword_index) {
if (isset($this->_cache[CACHE_TYPEFACE][$subword_index])) {
return $this->_cache[CACHE_TYPEFACE][$subword_index];
};
$font_resolver =& $viewport->get_font_resolver();
$font = $this->getCSSProperty(CSS_FONT);
$typeface = $font_resolver->getTypefaceName($font->family,
$font->weight,
$font->style,
$this->encodings[$subword_index]);
$this->_cache[CACHE_TYPEFACE][$subword_index] = $typeface;
return $typeface;
}
function add_subword($raw_subword, $encoding, $hyphens) {
$text_transform = $this->getCSSProperty(CSS_TEXT_TRANSFORM);
switch ($text_transform) {
case CSS_TEXT_TRANSFORM_CAPITALIZE:
$subword = ucwords($raw_subword);
break;
case CSS_TEXT_TRANSFORM_UPPERCASE:
$subword = strtoupper($raw_subword);
break;
case CSS_TEXT_TRANSFORM_LOWERCASE:
$subword = strtolower($raw_subword);
break;
case CSS_TEXT_TRANSFORM_NONE:
$subword = $raw_subword;
break;
}
$this->words[] = $subword;
$this->encodings[] = $encoding;
$this->hyphens[] = $hyphens;
}
function &create($text, $encoding, &$pipeline) {
$box =& TextBox::create_empty($pipeline);
$box->add_subword($text, $encoding, array());
return $box;
}
function &create_empty(&$pipeline) {
$box =& new TextBox();
$css_state = $pipeline->getCurrentCSSState();
$box->readCSS($css_state);
$css_state = $pipeline->getCurrentCSSState();
return $box;
}
function readCSS(&$state) {
parent::readCSS($state);
$this->_readCSSLengths($state,
array(CSS_TEXT_INDENT,
CSS_LETTER_SPACING));
}
// Inherited from GenericFormattedBox
function get_descender() {
return $this->descender;
}
function get_ascender() {
return $this->ascender;
}
function get_baseline() {
return $this->baseline;
}
function get_min_width_natural(&$context) {
return $this->get_full_width();
}
function get_min_width(&$context) {
return $this->get_full_width();
}
function get_max_width(&$context) {
return $this->get_full_width();
}
// Checks if current inline box should cause a line break inside the parent box
//
// @param $parent reference to a parent box
// @param $content flow context
// @return true if line break occurred; false otherwise
//
function maybe_line_break(&$parent, &$context) {
if (!$parent->line_break_allowed()) {
return false;
};
$last =& $parent->last_in_line();
if ($last) {
// Check if last box was a note call box. Punctuation marks
// after a note-call box should not be wrapped to new line,
// while "plain" words may be wrapped.
if ($last->is_note_call() && $this->is_punctuation()) {
return false;
};
};
// Calculate the x-coordinate of this box right edge
$right_x = $this->get_full_width() + $parent->_current_x;
$need_break = false;
// Check for right-floating boxes
// If upper-right corner of this inline box is inside of some float, wrap the line
$float = $context->point_in_floats($right_x, $parent->_current_y);
if ($float) {
$need_break = true;
};
// No floats; check if we had run out the right edge of container
// TODO: nobr-before, nobr-after
if (($right_x > $parent->get_right()+EPSILON)) {
// Now check if parent line box contains any other boxes;
// if not, we should draw this box unless we have a floating box to the left
$first = $parent->get_first();
$ti = $this->getCSSProperty(CSS_TEXT_INDENT);
$indent_offset = $ti->calculate($parent);
if ($parent->_current_x > $parent->get_left() + $indent_offset + EPSILON) {
$need_break = true;
};
}
// As close-line will not change the current-Y parent coordinate if no
// items were in the line box, we need to offset this explicitly in this case
//
if ($parent->line_box_empty() && $need_break) {
$parent->_current_y -= $this->get_height();
};
if ($need_break) {
// Check if current box contains soft hyphens and use them, breaking word into parts
$size = count($this->_wrappable);
if ($size > 0) {
$width_delta = $right_x - $parent->get_right();
if (!is_null($float)) {
$width_delta = $right_x - $float->get_left_margin();
};
$this->_find_soft_hyphen($parent, $width_delta);
};
$parent->close_line($context);
// Check if parent inline boxes have left padding/margins and add them to current_x
$element = $this->parent;
while (!is_null($element) && is_a($element,"GenericInlineBox")) {
$parent->_current_x += $element->get_extra_left();
$element = $element->parent;
};
};
return $need_break;
}
function _find_soft_hyphen(&$parent, $width_delta) {
/**
* Now we search for soft hyphen closest to the right margin
*/
$size = count($this->_wrappable);
for ($i=$size-1; $i>=0; $i--) {
$wrappable = $this->_wrappable[$i];
if ($this->get_width() - $wrappable[3] > $width_delta) {
$this->save_wrapped($wrappable, $parent, $context);
$parent->append_line($this);
return;
};
};
}
function save_wrapped($wrappable, &$parent, &$context) {
$this->wrapped = array($wrappable,
$parent->_current_x + $this->get_extra_left(),
$parent->_current_y - $this->get_extra_top());
}
function reflow(&$parent, &$context) {
// Check if we need a line break here (possilble several times in a row, if we
// have a long word and a floating box intersecting with this word
//
// To prevent infinite loop, we'll use a limit of 100 sequental line feeds
$i=0;
do { $i++; } while ($this->maybe_line_break($parent, $context) && $i < 100);
// Determine the baseline position and height of the text-box using line-height CSS property
$this->_apply_line_height();
// set default baseline
$this->baseline = $this->default_baseline;
// append current box to parent line box
$parent->append_line($this);
// Determine coordinates of upper-left _margin_ corner
$this->guess_corner($parent);
// Offset parent current X coordinate
if (!is_null($this->wrapped)) {
$parent->_current_x += $this->get_full_width() - $this->wrapped[0][2];
} else {
$parent->_current_x += $this->get_full_width();
};
// Extends parents height
$parent->extend_height($this->get_bottom());
// Update the value of current collapsed margin; pure text (non-span)
// boxes always have zero margin
$context->pop_collapsed_margin();
$context->push_collapsed_margin( 0 );
}
function getWrappedWidthAndHyphen() {
return $this->wrapped[0][3];
}
function getWrappedWidth() {
return $this->wrapped[0][2];
}
function reflow_text(&$viewport) {
$num_words = count($this->words);
/**
* Empty text box
*/
if ($num_words == 0) {
return true;
};
/**
* A simple assumption is made: fonts used for different encodings
* have equal ascender/descender values (while they have the same
* typeface, style and weight).
*/
$font_name = $this->_get_font_name($viewport, 0);
/**
* Get font vertical metrics
*/
$ascender = $viewport->font_ascender($font_name, $this->encodings[0]);
if (is_null($ascender)) {
error_log("TextBox::reflow_text: cannot get font ascender");
return null;
};
$descender = $viewport->font_descender($font_name, $this->encodings[0]);
if (is_null($descender)) {
error_log("TextBox::reflow_text: cannot get font descender");
return null;
};
/**
* Setup box size
*/
$font = $this->getCSSProperty(CSS_FONT_SIZE);
$font_size = $font->getPoints();
// Both ascender and descender should make $font_size
// as it is not guaranteed that $ascender + $descender == 1,
// we should normalize the result
$koeff = $font_size / ($ascender + $descender);
$this->ascender = $ascender * $koeff;
$this->descender = $descender * $koeff;
$this->default_baseline = $this->ascender;
$this->height = $this->ascender + $this->descender;
/**
* Determine box width
*/
if ($font_size > 0) {
$width = 0;
for ($i=0; $i<$num_words; $i++) {
$font_name = $this->_get_font_name($viewport, $i);
$current_width = $viewport->stringwidth($this->words[$i],
$font_name,
$this->encodings[$i],
$font_size);
$this->_word_widths[] = $current_width;
// Add information about soft hyphens
$this->_wrappable = array_merge($this->_wrappable, $this->_make_wrappable($viewport, $width, $font_name, $font_size, $i));
$width += $current_width;
};
$this->width = $width;
} else {
$this->width = 0;
};
$letter_spacing = $this->getCSSProperty(CSS_LETTER_SPACING);
if ($letter_spacing->getPoints() != 0) {
$this->_widths = array();
for ($i=0; $i<$num_words; $i++) {
$num_chars = strlen($this->words[$i]);
for ($j=0; $j<$num_chars; $j++) {
$this->_widths[] = $viewport->stringwidth($this->words[$i]{$j},
$font_name,
$this->encodings[$i],
$font_size);
};
$this->width += $letter_spacing->getPoints()*$num_chars;
};
};
return true;
}
function show(&$driver) {
/**
* Check if font-size have been set to 0; in this case we should not draw this box at all
*/
$font_size = $this->getCSSProperty(CSS_FONT_SIZE);
if ($font_size->getPoints() == 0) {
return true;
}
// Check if current text box will be cut-off by the page edge
// Get Y coordinate of the top edge of the box
$top = $this->get_top_margin();
// Get Y coordinate of the bottom edge of the box
$bottom = $this->get_bottom_margin();
$top_inside = $top >= $driver->getPageBottom()-EPSILON;
$bottom_inside = $bottom >= $driver->getPageBottom()-EPSILON;
if (!$top_inside && !$bottom_inside) {
return true;
}
return $this->_showText($driver);
}
function _showText(&$driver) {
if (!is_null($this->wrapped)) {
return $this->_showTextWrapped($driver);
} else {
return $this->_showTextNormal($driver);
};
}
function _showTextWrapped(&$driver) {
// draw generic box
parent::show($driver);
$font_size = $this->getCSSProperty(CSS_FONT_SIZE);
$decoration = $this->getCSSProperty(CSS_TEXT_DECORATION);
// draw text decoration
$driver->decoration($decoration['U'],
$decoration['O'],
$decoration['T']);
$letter_spacing = $this->getCSSProperty(CSS_LETTER_SPACING);
// Output text with the selected font
// note that we're using $default_baseline;
// the alignment offset - the difference between baseline and default_baseline values
// is taken into account inside the get_top/get_bottom functions
//
$current_char = 0;
$left = $this->wrapped[1];
$top = $this->get_top() - $this->default_baseline;
$num_words = count($this->words);
/**
* First part of wrapped word (before hyphen)
*/
for ($i=0; $i<$this->wrapped[0][0]; $i++) {
// Activate font
$status = $driver->setfont($this->_get_font_name($driver, $i),
$this->encodings[$i],
$font_size->getPoints());
if (is_null($status)) {
error_log("TextBox::show: setfont call failed");
return null;
};
$driver->show_xy($this->words[$i],
$left,
$this->wrapped[2] - $this->default_baseline);
$left += $this->_word_widths[$i];
};
$index = $this->wrapped[0][0];
$status = $driver->setfont($this->_get_font_name($driver, $index),
$this->encodings[$index],
$font_size->getPoints());
if (is_null($status)) {
error_log("TextBox::show: setfont call failed");
return null;
};
$driver->show_xy(substr($this->words[$index],0,$this->wrapped[0][1])."-",
$left,
$this->wrapped[2] - $this->default_baseline);
/**
* Second part of wrapped word (after hyphen)
*/
$left = $this->get_left();
$top = $this->get_top();
$driver->show_xy(substr($this->words[$index],$this->wrapped[0][1]),
$left,
$top - $this->default_baseline);
$size = count($this->words);
for ($i = $this->wrapped[0][0]+1; $i<$size; $i++) {
// Activate font
$status = $driver->setfont($this->_get_font_name($driver, $i),
$this->encodings[$i],
$font_size->getPoints());
if (is_null($status)) {
error_log("TextBox::show: setfont call failed");
return null;
};
$driver->show_xy($this->words[$i],
$left,
$top - $this->default_baseline);
$left += $this->_word_widths[$i];
};
return true;
}
function _showTextNormal(&$driver) {
// draw generic box
parent::show($driver);
$font_size = $this->getCSSProperty(CSS_FONT_SIZE);
$decoration = $this->getCSSProperty(CSS_TEXT_DECORATION);
// draw text decoration
$driver->decoration($decoration['U'],
$decoration['O'],
$decoration['T']);
$letter_spacing = $this->getCSSProperty(CSS_LETTER_SPACING);
if ($letter_spacing->getPoints() == 0) {
// Output text with the selected font
// note that we're using $default_baseline;
// the alignment offset - the difference between baseline and default_baseline values
// is taken into account inside the get_top/get_bottom functions
//
$size = count($this->words);
$left = $this->get_left();
for ($i=0; $i<$size; $i++) {
// Activate font
$status = $driver->setfont($this->_get_font_name($driver, $i),
$this->encodings[$i],
$font_size->getPoints());
if (is_null($status)) {
error_log("TextBox::show: setfont call failed");
return null;
};
$driver->show_xy($this->words[$i],
$left,
$this->get_top() - $this->default_baseline);
$left += $this->_word_widths[$i];
};
} else {
$current_char = 0;
$left = $this->get_left();
$top = $this->get_top() - $this->default_baseline;
$num_words = count($this->words);
for ($i=0; $i<$num_words; $i++) {
$num_chars = strlen($this->words[$i]);
for ($j=0; $j<$num_chars; $j++) {
$status = $driver->setfont($this->_get_font_name($driver, $i),
$this->encodings[$i],
$font_size->getPoints());
$driver->show_xy($this->words[$i]{$j}, $left, $top);
$left += $this->_widths[$current_char] + $letter_spacing->getPoints();
$current_char++;
};
};
};
return true;
}
function show_fixed(&$driver) {
$font_size = $this->getCSSProperty(CSS_FONT_SIZE);
// Check if font-size have been set to 0; in this case we should not draw this box at all
if ($font_size->getPoints() == 0) {
return true;
}
return $this->_showText($driver);
}
function offset($dx, $dy) {
parent::offset($dx, $dy);
// Note that horizonal offset should be called explicitly from text-align routines
// otherwise wrapped part will be offset twice (as offset is called both for
// wrapped and non-wrapped parts).
if (!is_null($this->wrapped)) {
$this->offset_wrapped($dx, $dy);
};
}
function offset_wrapped($dx, $dy) {
$this->wrapped[1] += $dx;
$this->wrapped[2] += $dy;
}
function reflow_whitespace(&$linebox_started, &$previous_whitespace) {
$linebox_started = true;
$previous_whitespace = false;
return;
}
function is_null() { return false; }
}
?>

View File

@@ -1,60 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/box.text.string.php,v 1.5 2006/10/06 20:10:52 Konstantin Exp $
// TODO: from my POV, it wll be better to pass the font- or CSS-controlling object to the constructor
// instead of using globally visible functions in 'show'.
class TextBoxString extends TextBox {
function &create($text, $encoding) {
$box =& new TextBoxString($text, $encoding);
$box->readCSS($pipeline->getCurrentCSSState());
return $box;
}
function TextBoxString($word, $encoding) {
// Call parent constructor
$this->TextBox();
$this->add_subword($word, $encoding, array());
}
function get_extra_bottom() {
return 0;
}
// "Pure" Text boxes never have margins/border/padding
function get_extra_left() {
return 0;
}
// "Pure" Text boxes never have margins/border/padding
function get_extra_right() {
return 0;
}
function get_extra_top() {
return 0;
}
function get_full_width() {
return $this->width;
}
function get_margin_top() {
return 0;
}
function get_min_width(&$context) {
return $this->width;
}
function get_max_width(&$context) {
return $this->width;
}
// Note that we don't need to call complicated 'get_width' function inherited from GenericFormattedBox,
// a TextBox never have width constraints nor children; its width is always defined by the string length
function get_width() {
return $this->width;
}
}
?>

View File

@@ -1,103 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/box.utils.text-align.inc.php,v 1.13 2007/01/09 20:13:48 Konstantin Exp $
function ta_left(&$box, &$context, $lastline) {
// Do nothing; text is left-aligned by default
}
function ta_center(&$box, &$context, $lastline) {
$delta = $box->_line_length_delta($context) / 2;
$size = count($box->_line);
for ($i=0; $i< $size; $i++) {
$box->_line[$i]->offset($delta, 0);
};
$first_box =& $box->_line[0];
if (isset($first_box->wrapped) && !is_null($first_box->wrapped)) {
$first_box->offset_wrapped(-$delta, 0);
};
}
function ta_right(&$box, &$context, $lastline) {
$delta = $box->_line_length_delta($context);
$size = count($box->_line);
for ($i=0; $i<$size; $i++) {
$box->_line[$i]->offset($delta, 0);
};
$first_box =& $box->_line[0];
if (isset($first_box->wrapped) && !is_null($first_box->wrapped)) {
$first_box->offset_wrapped(-$delta, 0);
};
}
function ta_justify(&$box, &$context, $lastline) {
// last line is never justified
if ($lastline) {
return;
}
// If line box contains less that two items, no justification can be done, just return
if (count($box->_line) < 2) {
return;
}
// Calculate extra space to be filled by this line
$delta = $box->_line_length_delta($context);
// note that if it is the very first line inside the container, 'text-indent' value
// should not be taken into account while calculating delta value
if (count($box->content) > 0) {
if ($box->content[0]->uid === $box->_line[0]->uid) {
$delta -= $box->text_indent->calculate($box);
};
};
// if line takes less that MAX_JUSTIFY_FRACTION of available space, no justtification should be done
if ($delta > $box->_line_length() * MAX_JUSTIFY_FRACTION) {
return;
};
// Calculate offset for each whitespace box
$whitespace_count = 0;
$size = count($box->_line);
// Why $size-1? Ignore whitespace box, if it is located at the very end of
// line box
// Also, ignore whitespace box at the very beginning of the line
for ($i=1; $i<$size-1; $i++) {
if (is_a($box->_line[$i],"WhitespaceBox")) {
$whitespace_count++;
};
};
if ($whitespace_count > 0) {
$offset = $delta / $whitespace_count;
} else {
$offset = 0;
};
// Offset all boxes in current line box
$num_whitespaces = 0;
$size = count($box->_line);
for ($i=1; $i < $size; $i++) {
/*
* Note that order is important: additional horizontal space
* is added after the whitespace box; it is important, as
* whitespace box (if it is the last box in the line) should not
* run off the right edge of the container box
*/
$box->_line[$i]->offset($offset * $num_whitespaces, 0);
if (is_a($box->_line[$i],"WhitespaceBox")) {
$num_whitespaces++;
};
};
// The very first box is not offset in this case, so we don't need to
// call offset_wrapped to compensate this.
}
?>

View File

@@ -1,121 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/box.whitespace.php,v 1.33 2007/01/24 18:55:46 Konstantin Exp $
class WhitespaceBox extends TextBox {
function &create(&$pipeline) {
$box =& new WhitespaceBox();
$box->readCSS($pipeline->getCurrentCSSState());
$box->add_subword(" ", 'iso-8859-1', array());
return $box;
}
function readCSS(&$state) {
parent::readCSS($state);
$this->_readCSSLengths($state,
array(CSS_WORD_SPACING));
}
function get_extra_bottom() {
return 0;
}
// "Pure" Text boxes never have margins/border/padding
function get_extra_left() {
return 0;
}
// "Pure" Text boxes never have margins/border/padding
function get_extra_right() {
return 0;
}
function get_extra_top() {
return 0;
}
function get_full_width() {
return $this->width;
}
function get_margin_top() {
return 0;
}
function get_min_width(&$context) {
return $this->width;
}
function get_max_width(&$context) {
return $this->width;
}
function WhitespaceBox() {
// Call parent constructor
$this->TextBox();
}
// (!) SIDE EFFECT: current whitespace box can be replaced by a null box during reflow.
// callers of reflow should take this into account and possilby check for this
// after reflow returns. This can be detected by UID change.
//
function reflow(&$parent, &$context) {
// Check if there are any boxes in parent's line box
if ($parent->line_box_empty()) {
// The very first whitespace in the line box should not affect neither height nor baseline of the line box;
// because following boxes can be smaller that assumed whitespace height
// Example: <br>[whitespace]<img height="2" width="2"><br>; whitespace can overextend this line
$this->width = 0;
$this->height = 0;
} elseif (is_a($parent->last_in_line(),"WhitespaceBox")) {
// Duplicate whitespace boxes should not offset further content and affect the line box length
$this->width = 0;
$this->height = 0;
} elseif ($this->maybe_line_break($parent, $context)) {
$this->width = 0;
$this->height = 0;
};
parent::reflow($parent, $context);
}
function reflow_text(&$driver) {
if (is_null(parent::reflow_text($driver))) {
return null;
};
// Override widths
$letter_spacing = $this->getCSSProperty(CSS_LETTER_SPACING);
$word_spacing = $this->getCSSProperty(CSS_WORD_SPACING);
$this->width =
$this->height * WHITESPACE_FONT_SIZE_FRACTION +
$letter_spacing->getPoints() +
$word_spacing->getPoints();
return true;
}
function reflow_whitespace(&$linebox_started, &$previous_whitespace) {
if (!$linebox_started ||
($linebox_started && $previous_whitespace)) {
$link_destination = $this->getCSSProperty(CSS_HTML2PS_LINK_DESTINATION);
if ($link_destination == "") {
$this->parent->remove($this);
} else {
$this->font_height = 0.001;
$this->height = 0;
$this->width = 0;
};
};
$previous_whitespace = true;
// Note that there can (in theory) several whitespaces in a row, so
// we could not modify a flag until we met a real text box
}
}
?>

View File

@@ -1,39 +0,0 @@
<?php
/*
This file is part of ActiveLink PHP XML Package (www.active-link.com).
Copyright (c) 2002-2004 by Zurab Davitiani
You can contact the author of this software via E-mail at
hattrick@mailcan.com
ActiveLink PHP XML Package is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
ActiveLink PHP XML Package 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ActiveLink PHP XML Package; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* Include file for ActiveLink IORCA
*/
// define included package locations
$GLOBALS["IORCA"]["BASE"]["PATH"] = dirname(__FILE__) . "/";
function import($classPath) {
$importFile = str_replace(".", "/", $classPath) . ".php";
require_once($GLOBALS["IORCA"]["BASE"]["PATH"] . $importFile);
}
?>

View File

@@ -1,242 +0,0 @@
<?php
/*
This file is part of ActiveLink PHP DOC Package (www.active-link.com).
Copyright (c) 2002-2004 by Zurab Davitiani
You can contact the author of this software via E-mail at
hattrick@mailcan.com
ActiveLink PHP DOC Package is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
ActiveLink PHP DOC Package 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ActiveLink PHP DOC Package; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import("org.active-link.xml.XML");
import("org.active-link.doc.PHPClass");
import("org.active-link.doc.Method");
/**
* DocHTML parses PHP class file comments and generates documentation
* @class DocHTML
* @package org.active-link.doc
* @author Zurab Davitiani
* @version 0.3.4
* @requires XML, PHPClass, Method
* @see PHPClass
*/
class DocHTML {
var $CSSFile;
var $CSSFileTag;
var $CSSString;
var $CSSStringTag;
var $CSSStringDefault;
/**
* Constructor, runs when new object instance is created, sets default values
* @method DocHTML
*/
function DocHTML() {
$this->CSSStringDefault = "
body {background-color: white;}
a {font-family: monospace;}
ul {list-style-type: none;}
.classTitle {color: blue;}
.name {color: black;}
.version {color: black;}
.requires {color: red;}
.extends {color: black;}
.description {color: black;font-family: sans-serif;}
.author {color: blue;}
.methodsTitle {color: blue;}
.methodList {color: blue;}
.methodName {color: blue;font-weight: bold;}
.returns {color: black;}
.param {color: black;font-weight: bold;font-family: monospace;}
";
}
/**
* Returns class documentation as a string, formatted in HTML
* If argument is a filename, it parses the file for comments and generates documentation
* If argument is an object of type PHPClass, then documentation is generated from it
* @method getClassDoc
* @param mixed argument
* @returns string HTML-formatted documentation if successful, false otherwise
*/
function getClassDoc($argument) {
if(is_object($argument) && get_class($argument) == "phpclass")
return $this->getClassDocFromClass($argument);
elseif(is_string($argument))
return $this->getClassDocFromFile($argument);
else
return false;
}
/**
* Returns class documentation as a string, formatted in HTML
* @method getClassDocFromClass
* @param object objClass
* @returns string HTML-formatted documentation if successful, false otherwise
*/
function getClassDocFromClass($objClass) {
if(is_object($objClass) && get_class($objClass) == "phpclass") {
$classDocXML = new XML_("html");
// ---------------------- HEAD ---------------------- //
$headXML = new XMLBranch("head");
$headXML->setTagContent($objClass->getInfo("name"), "head/title");
$headXML->setTagContent("", "head/meta");
$headXML->setTagAttribute("http-equiv", "content-type", "head/meta");
$headXML->setTagAttribute("content", "text/html; charset=ISO-8859-1", "head/meta");
$headXML->setTagContent($this->CSSStringDefault, "head/style");
$headXML->setTagAttribute("type", "text/css", "head/style");
// ---------------------- BODY ---------------------- //
$bodyXML = new XMLBranch("body");
$classTitleXML = new XMLBranch("h1");
$classTitleXML->setTagAttribute("class", "classTitle");
$classTitleXML->setTagContent($objClass->getInfo("name") . " Class");
$bodyXML->addXMLBranch($classTitleXML);
foreach($objClass->info as $infoKey => $infoValue) {
$brXML = new XMLBranch("br");
$bodyXML->addXMLBranch($brXML);
if(is_array($infoValue)) {
$spanXML = new XMLBranch("span");
$spanXML->setTagAttribute("class", $infoKey);
$spanXML->setTagContent(ucfirst($infoKey) . ":");
$ulXML = new XMLBranch("ul");
$ulXML->setTagAttribute("class", $infoKey);
foreach($infoValue as $value) {
$liXML = new XMLBranch("li");
$liXML->setTagContent($value);
$ulXML->addXMLBranch($liXML);
}
$bodyXML->addXMLBranch($spanXML);
$bodyXML->addXMLBranch($ulXML);
}
else {
$spanXML = new XMLBranch("span");
$spanXML->setTagAttribute("class", $infoKey);
$spanXML->setTagContent(ucfirst($infoKey) . ": " . $infoValue);
$bodyXML->addXMLBranch($spanXML);
}
}
$hrXML = new XMLBranch("hr");
$bodyXML->addXMLBranch($hrXML);
$h2XML = new XMLBranch("h2");
$h2XML->setTagAttribute("class", "methodsTitle");
$h2XML->setTagContent("All Methods");
$bodyXML->addXMLBranch($h2XML);
$spanXML = new XMLBranch("span");
$spanXML->setTagAttribute("class", "methodList");
foreach($objClass->methods as $methodName => $method) {
$aMethodXML = new XMLBranch("a");
$aMethodXML->setTagAttribute("href", "#" . $methodName);
$aMethodXML->setTagContent($methodName);
$brXML = new XMLBranch("br");
$spanXML->addXMLBranch($aMethodXML);
$spanXML->addXMLBranch($brXML);
}
$bodyXML->addXMLBranch($spanXML);
foreach($objClass->methods as $methodName => $method) {
$hrXML = new XMLBranch("hr");
$bodyXML->addXMLBranch($hrXML);
$pMethodXML = new XMLBranch("p");
$aMethodXML = new XMLBranch("a");
$aMethodXML->setTagAttribute("name", $methodName);
$spanXMLName = new XMLBranch("span");
$spanXMLName->setTagAttribute("class", "methodName");
$spanXMLName->setTagContent($methodName);
$spanXMLArgs = new XMLBranch("span");
$tagContentArgs = " ( ";
if(is_array($method->params) && count($method->params) > 0) {
$paramCount = 0;
foreach($method->params as $key => $value) {
if($paramCount > 0)
$tagContentArgs .= ", ";
$tagContentArgs .= $key;
$paramCount ++;
}
}
$tagContentArgs .= " )";
$spanXMLArgs->setTagContent($tagContentArgs);
$aMethodXML->addXMLBranch($spanXMLName);
$aMethodXML->addXMLBranch($spanXMLArgs);
$pMethodXML->addXMLBranch($aMethodXML);
$bodyXML->addXMLBranch($pMethodXML);
unset($method->info["name"]);
foreach($method->info as $infoKey => $infoValue) {
if(is_array($infoValue)) {
$pXML = new XMLBranch("p");
$pXML->setTagAttribute("class", $infoKey);
$pXML->setTagContent(ucfirst($infoKey) . ":");
$ulXML = new XMLBranch("ul");
$ulXML->setTagAttribute("class", $infoKey);
foreach($infoValue as $value) {
$liXML = new XMLBranch("li");
$liXML->setTagContent($value);
$ulXML->addXMLBranch($liXML);
}
$bodyXML->addXMLBranch($pXML);
$bodyXML->addXMLBranch($ulXML);
}
else {
$pXML = new XMLBranch("p");
$pXML->setTagAttribute("class", $infoKey);
$pXML->setTagContent(ucfirst($infoKey) . ": " . $infoValue);
$bodyXML->addXMLBranch($pXML);
}
}
if(is_array($method->params) && count($method->params) > 0) {
$pParamXML = new XMLBranch("p");
//$pParamXML->setTagAttribute("class", "param");
$paramTitleXML = new XMLBranch("span");
$paramTitleXML->setTagContent("Arguments:");
$pParamXML->addXMLBranch($paramTitleXML);
$paramListXML = new XMLBranch("ul");
foreach($method->params as $key => $value) {
$paramItemXML = new XMLBranch("li");
$paramItemXML->setTagAttribute("class", "param");
$paramItemXML->setTagContent($key);
$paramListXML->addXMLBranch($paramItemXML);
}
$pParamXML->addXMLBranch($paramListXML);
$bodyXML->addXMLBranch($pParamXML);
}
}
// ---------------------- END ---------------------- //
$classDocXML->addXMLBranch($headXML);
$classDocXML->addXMLBranch($bodyXML);
return $classDocXML->getXMLString(0);
}
else
return false;
}
/**
* Returns class documentation as a string, formatted in HTML
* @method getClassDocFromFile
* @param string filename
* @returns string HTML-formatted documentation if successful, false otherwise
*/
function getClassDocFromFile($filename) {
if(is_string($filename) && file_exists($filename) && is_readable($filename)) {
$objClass = new PHPClass($filename);
return $this->getClassDocFromClass($objClass);
}
else
return false;
}
}

View File

@@ -1,83 +0,0 @@
<?php
/*
This file is part of ActiveLink PHP DOC Package (www.active-link.com).
Copyright (c) 2002-2004 by Zurab Davitiani
You can contact the author of this software via E-mail at
hattrick@mailcan.com
ActiveLink PHP DOC Package is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
ActiveLink PHP DOC Package 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ActiveLink PHP DOC Package; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* Method class complements PHPClass and is used to define a class method
* @class Method
* @package org.active-link.doc
* @author Zurab Davitiani
* @version 0.3.4
* @see PHPClass
*/
class Method {
var $params;
var $info;
/**
* Constructor, runs when new object instance is created, sets name of the method
* @method Method
* @param string name
*/
function Method($name) {
$this->info = array();
$this->params = array();
$this->setInfo("name", $name);
}
/**
* Returns value of a property by name
* @method getInfo
* @param string name
* @returns string value of a property if found, false otherwise
*/
function getInfo($name) {
if(array_key_exists($name, $this->info))
return $this->info[$name];
else
return false;
}
/**
* Sets a property with supplied name to a supplied value
* @method setInfo
* @param string name, string value
* @returns none
*/
function setInfo($name, $value) {
$this->info[$name] = $value;
}
/**
* Sets a parameter with supplied name and value
* @method setParam
* @param string name, string value
* @returns none
*/
function setParam($name, $value) {
$this->params[$name] = $value;
}
}

View File

@@ -1,195 +0,0 @@
<?php
/*
This file is part of ActiveLink PHP DOC Package (www.active-link.com).
Copyright (c) 2002-2004 by Zurab Davitiani
You can contact the author of this software via E-mail at
hattrick@mailcan.com
ActiveLink PHP DOC Package is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
ActiveLink PHP DOC Package 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ActiveLink PHP DOC Package; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* PHPClass class provides a structural definition for a class
* @class PHPClass
* @package org.active-link.doc
* @author Zurab Davitiani
* @version 0.3.4
* @requires Method
* @see PHPClass
*/
class PHPClass {
var $methods;
var $properties;
var $info;
/**
* Constructor, if filename is supplied parses the file into the object
* @method PHPClass
* @param optional string filename
* @returns none
*/
function PHPClass($filename = "") {
$this->methods = array();
$this->properties = array();
$this->info = array();
if($filename != "")
$this->parseFromFile($filename);
}
/**
* Deletes a property by name
* @method deleteInfo
* @param string name
* @returns true if successful, false otherwise
*/
function deleteInfo($name) {
$success = false;
if(array_key_exists($name, $this->info)) {
unset($this->info[$name]);
$success = true;
}
return $success;
}
/**
* Returns a property value by name
* @method getInfo
* @param string name
* @returns string value if successful, false otherwise
*/
function getInfo($name) {
if(array_key_exists($name, $this->info))
return $this->info[$name];
else
return false;
}
/**
* Parses a class from supplied filename
* @method parseFromFile
* @param string filename
* @returns true if successful, false otherwise
*/
function parseFromFile($filename) {
$success = false;
if(file_exists($filename) && is_readable($filename)) {
$arrContents = file($filename);
$parsing = false;
$parsingBlocks = array();
$tempBlock = array();
foreach($arrContents as $line) {
if(trim($line) == "/**") {
$parsing = true;
$blockstart = true;
}
elseif($parsing && trim($line) == "*/") {
$parsing = false;
$parsingBlocks[] = $tempBlock;
$tempBlock = array();
}
else {
if($parsing) {
if($blockstart) {
$tempBlock[] = $line;
$blockstart = false;
}
else {
$tempBlock[] = $line;
}
}
}
}
foreach($parsingBlocks as $blockLines) {
$block = array();
foreach($blockLines as $line) {
$str = strstr($line, "@");
$str = substr($str, 1);
if($str !== false) {
$separatorPos = (strpos($str, " ") && strpos($str, "\t")) ? min(strpos($str, " "), strpos($str, "\t")) : (strpos($str, " ") ? strpos($str, " ") : (strpos($str, "\t") ? strpos($str, "\t") : strlen($str)));
$name = trim(substr($str, 0, $separatorPos));
$value = trim(substr($str, $separatorPos));
}
else {
$name = "description";
$value = trim($line);
}
if($name == "param" || $name == "description")
$block[$name][] = $value;
else
$block[$name] = $value;
}
//print("<pre>");
//print_r($block);
//print("</pre>");
if(array_key_exists("method", $block)) {
$tempMethod = new Method($block["method"]);
unset($block["method"]);
if(isset($block["param"]) && is_array($block["param"])) {
foreach($block["param"] as $param) {
$tempMethod->setParam($param, "");
}
}
unset($block["param"]);
foreach($block as $name => $value) {
$tempMethod->setInfo($name, $value);
}
$this->setMethod($tempMethod);
}
elseif(array_key_exists("class", $block)) {
$this->setInfo("name", $block["class"]);
unset($block["class"]);
foreach($block as $name => $value) {
$this->setInfo($name, $value);
}
}
}
$success = true;
}
return $success;
}
/**
* Sets a property by name
* @method setInfo
* @param string name, string value
* @returns none
*/
function setInfo($name, $value) {
$this->info[$name] = $value;
}
/**
* Adds a method to the class definition
* @method setMethod
* @param object method
* @returns true if successful, false otherwise
*/
function setMethod($method) {
$success = false;
if(is_object($method) && get_class($method) == "Method") {
$this->methods[$method->getInfo("name")] = $method;
$success = true;
}
return $success;
}
}
?>

View File

@@ -1,173 +0,0 @@
<?php
/*
This file is part of ActiveLink PHP NET Package (www.active-link.com).
Copyright (c) 2002-2004 by Zurab Davitiani
You can contact the author of this software via E-mail at
hattrick@mailcan.com
ActiveLink PHP NET Package is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
ActiveLink PHP NET Package 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ActiveLink PHP NET Package; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* requires Socket class
*/
import("org.active-link.net.Socket");
/**
* HTTPClient class provides HTTP request functionality and ability to retrieve response
* @class HTTPClient
* @package org.active-link.net
* @author Zurab Davitiani
* @version 0.4.0
* @extends Socket
* @requires Socket
* @see Socket
*/
class HTTPClient extends Socket {
// protected properties
var $defaultRequestMethod;
var $defaultRequestURI;
var $defaultRequestVersion;
var $defaultRequestUserAgent;
var $defaultRequestBody;
var $requestMethod;
var $requestURI;
var $requestVersion;
var $requestUserAgent;
var $requestHeaders;
/**
* HTTP client class constructor accepts host (required) and port (optional, default 80) arguments
* @method HTTPClient
* @param string host
* @param optional int port
*/
function HTTPClient($host, $port = 80) {
$this->Socket($host, $port);
$this->defaultRequestMethod = "GET";
$this->defaultRequestURI = "/";
$this->defaultRequestVersion = "HTTP/1.0";
$this->defaultRequestUserAgent = "ActiveLink NET Object/0.3.3";
$this->defaultRequestBody = "";
$this->requestMethod = $this->defaultRequestMethod;
$this->requestURI = $this->defaultRequestURI;
$this->requestVersion = $this->defaultRequestVersion;
$this->requestUserAgent = $this->defaultRequestUserAgent;
$this->requestBody = $this->defaultRequestBody;
$this->requestHeaders = array();
}
/**
* Adds a supplied raw header to the internal header array
* @method addRequestHeaderRaw
* @param string header
* @returns none
*/
function addRequestHeaderRaw($header) {
$this->requestHeaders[] = $header;
}
/**
* Gets a string containing all HTTP request headers in their raw form
* @method getRequestHeaders
* @returns string request HTTP headers
*/
function getRequestHeaders() {
$headers = $this->requestMethod . " " . $this->requestURI . " " . $this->requestVersion . "\r\n";
$headers .= "User-Agent: " . $this->requestUserAgent . "\r\n";
$headers .= "Host: " . $this->host . "\r\n";
foreach($this->requestHeaders as $header) {
$headers .= $header . "\r\n";
}
if($this->requestMethod == "POST") {
$contentLength = strlen($this->requestBody);
$headers .= "Content-length: " . $contentLength . "\r\n";
}
$headers .= "Connection: close\r\n\r\n";
return $headers;
}
/**
* Sets HTTP request body/payload, used only when request method is POST
* @method setRequestBody
* @param string body
* @returns none
*/
function setRequestBody($body) {
$this->requestBody = $body;
}
/**
* Sets HTTP request method, GET or POST
* @method setRequestMethod
* @param string method
* @returns none
*/
function setRequestMethod($method) {
$this->requestMethod = strtoupper($method);
}
/**
* Sets request URI, if not set here, default will be /
* @method setRequestURI
* @param string uri
* @returns none
*/
function setRequestURI($uri) {
$this->requestURI = $uri;
}
/**
* Sets HTTP request User-Agent to send to the server, default is "ActiveLink NET Object/version"
* @method setRequestUserAgent
* @param string userAgent
* @returns none
*/
function setRequestUserAgent($userAgent) {
$this->setRequestUserAgent = $userAgent;
}
/**
* Sets HTTP protocol version to be used, default is "HTTP/1.0"
* @method setRequestVersion
* @param string version
* @returns none
*/
function setRequestVersion($version) {
$this->requestVersion = $version;
}
/**
* After all settings are complete, send the request to the server
* @method sendRequest
* @returns string server response if successful, false otherwise
*/
function sendRequest() {
$response = false;
$request = $this->getRequestHeaders();
$request .= $this->requestBody;
$success = $this->connect();
if($success) {
$response = $this->sendReceive($request);
$this->disconnect();
}
return $response;
}
}

View File

@@ -1,50 +0,0 @@
<?php
/*
This file is part of ActiveLink PHP NET Package (www.active-link.com).
Copyright (c) 2002-2004 by Zurab Davitiani
You can contact the author of this software via E-mail at
hattrick@mailcan.com
ActiveLink PHP NET Package is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
ActiveLink PHP NET Package 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ActiveLink PHP NET Package; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* requires Socket class
*/
import("org.active-link.net.Socket");
/**
* HTTPServer class provides functionality to receive HTTP requests and serve responses
* @class HTTPServer
* @package org.active-link.net
* @author Zurab Davitiani
* @version 0.4.0
* @extends Socket
* @requires Socket
* @see Socket
*/
class HTTPServer extends Socket {
// protected properties
var $defaultServer;
function HTTPServer () {
$this->defaultServer = "ActiveLink NET Object/0.1";
}
}

View File

@@ -1,162 +0,0 @@
<?php
/*
This file is part of ActiveLink PHP NET Package (www.active-link.com).
Copyright (c) 2002-2004 by Zurab Davitiani
You can contact the author of this software via E-mail at
hattrick@mailcan.com
ActiveLink PHP NET Package is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
ActiveLink PHP NET Package 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ActiveLink PHP NET Package; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* Socket class provides a basic network socket functionality
* @class Socket
* @package org.active-link.net
* @author Zurab Davitiani
* @version 0.4.0
*/
class Socket {
// protected properties
var $host;
var $port;
var $connected;
var $connectionID;
/**
* Constructor, accepts host and port, initializes object
* @method Socket
* @param host
* @param port
*/
function Socket($host, $port) {
$this->host = $host;
$this->port = $port;
$this->connected = false;
}
/**
* Connects to host with specified settings, accepts connection timeout (optional, default 30)
* @method connect
* @param optional int connectionTimeout
* @returns true if successful, false otherwise
*/
function connect($connectTimeout = 30) {
$this->connectionID = fsockopen($this->host, $this->port, $errorID, $errorDesc, $connectTimeout);
if($this->connectionID === false) {
return false;
}
else {
$this->connected = true;
return true;
}
}
/**
* Disconnects if already connected
* @method disconnect
* @returns true if successful, false otherwise
*/
function disconnect() {
$success = fclose($this->connectionID);
if($success)
$this->connected = false;
return $success;
}
/**
* Receives data through connected socket, accepts chunk size (optional, default 4096)
* @method receive
* @param optional int chunkSize
* @returns string received data if successful, false otherwise
*/
function receive($chunkSize = 4096) {
$receivedString = "";
$success = false;
if($this->connected) {
while(!feof($this->connectionID)) {
$receivedString .= fgets($this->connectionID, $chunkSize);
}
$success = true;
}
if($success)
return $receivedString;
else
return false;
}
/**
* Sends data through connected socket
* @method send
* @param string sendString
* @returns true if successful, false otherwise
*/
function send($sendString) {
$success = false;
if($this->connected)
$success = fwrite($this->connectionID, $sendString);
return $success;
}
/**
* Combination of send and receive methods in one
* @method sendReceive
* @param sendString
* @param optional int connectionTimeout
* @returns string received data if successful, false otherwise
*/
function sendReceive($sendString, $receiveChunkSize = 4096) {
$success = true;
$receivedString = "";
if($this->connected) {
$bytesSent = $this->send($sendString);
if($bytesSent === false)
$success = false;
if($success) {
$receivedString = $this->receive($receiveChunkSize);
if($receivedString === false)
$success = false;
}
}
if($success)
return $receivedString;
else
return false;
}
/**
* Sets host to make a connection to
* @method setHost
* @param string host
* @returns none
*/
function setHost($host) {
$this->host = $host;
}
/**
* Sets port to use for the connection
* @method setPort
* @param int port
* @returns none
*/
function setPort($port) {
$this->port = $port;
}
}

View File

@@ -1,153 +0,0 @@
<?php
/*
This file is part of ActiveLink PHP SYS Package (www.active-link.com).
Copyright (c) 2002-2004 by Zurab Davitiani
You can contact the author of this software via E-mail at
hattrick@mailcan.com
ActiveLink PHP SYS Package is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
ActiveLink PHP SYS Package 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ActiveLink PHP SYS Package; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* File class provides a wrapper around filesystem file functions
* @class File
* @package org.active-link.sys
* @author Zurab Davitiani
* @version 0.4.0
*/
class File {
// protected variables
var $filename;
var $fileOpenMode;
var $fileOpenModeRead;
var $fileOpenModeReadWrite;
var $fileOpenModeWrite;
var $fileOpenModeWriteRead;
var $fileOpenModeAppend;
var $fileOpenModeAppendRead;
var $connected;
var $handleID;
/**
* Constructor accepts filename (optional) and open mode (optional, default "r")
* If filename is specified, it is opened with the supplied open mode
* @method File
* @param optional string filename
* @param optional string fileOpenMode
*/
function File($filename = "", $fileOpenMode = "r") {
$success = true;
$this->filename = $filename;
$this->fileOpenMode = $fileOpenMode;
$this->fileOpenModeRead = "r";
$this->fileOpenModeReadWrite = "r+";
$this->fileOpenModeWrite = "w";
$this->fileOpenModeWriteRead = "w+";
$this->fileOpenModeAppend = "a";
$this->fileOpenModeAppendRead = "a+";
$this->connected = false;
$this->handleID = false;
if($this->filename != "")
$success = $this->open($this->filename, $this->fileOpenMode);
return $success;
}
/**
* Closes open file handle, resets filename, and file open mode to defaults
* @method close
* @returns true if successful, false otherwise
*/
function close() {
$success = fclose($this->handleID);
if($success) {
$this->filename = "";
$this->fileOpenMode = "r";
$this->connected = false;
$this->handleID = false;
}
return $success;
}
/**
* Returns file contents, optionally specify chunk size number of bytes to use per chunk read (default 8192)
* @method getContents
* @param optional int chunkSize
* @returns string file contents if successful, false otherwise
*/
function getContents($chunkSize = 8192) {
if($this->connected) {
$fileContents = "";
do {
$data = fread($this->handleID, $chunkSize);
if (strlen($data) == 0) {
break;
}
$fileContents .= $data;
} while(true);
return $fileContents;
}
else
return false;
}
/**
* Returns file contents as an array of lines
* @method getContentsArray
* @returns array file contents lines
*/
function getContentsArray() {
$fileContentsArray = file($this->filename);
return $fileContentsArray;
}
/**
* Opens a file with the supplied open mode
* @method open
* @param string filename
* @param optional string fileOpenMode
* @returns true if successful, false otherwise
*/
function open($filename, $mode = "r") {
$success = false;
if(!$this->connected) {
$this->handleID = @fopen($filename, $mode);
if($this->handleID !== false) {
$this->filename = $filename;
$this->fileOpenMode = $mode;
$this->connected = true;
$success = true;
}
}
return $success;
}
/**
* Writes supplied string content to already open file handle
* @method write
* @param string strContent
* @returns number of bytes written if successful, false otherwise
*/
function write($strContent) {
$bytesWritten = fwrite($this->handleID, $strContent, strlen($strContent));
return $bytesWritten;
}
}
?>

View File

@@ -1,42 +0,0 @@
<?php
/*
This file is part of ActiveLink PHP XML Package (www.active-link.com).
Copyright (c) 2002-2004 by Zurab Davitiani
You can contact the author of this software via E-mail at
hattrick@mailcan.com
ActiveLink PHP XML Package is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
ActiveLink PHP XML Package 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ActiveLink PHP XML Package; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import("org.active-link.xml.Tree");
/**
* Branch class is part of a Tree-Branch-Leaf trio
* @class Branch
* @package org.active-link.xml
* @author Zurab Davitiani
* @version 0.4.0
* @extends Tree
* @requires Tree
* @see Tree, Leaf
*/
class Branch extends Tree {
}
?>

View File

@@ -1,70 +0,0 @@
<?php
/*
This file is part of ActiveLink PHP XML Package (www.active-link.com).
Copyright (c) 2002-2004 by Zurab Davitiani
You can contact the author of this software via E-mail at
hattrick@mailcan.com
ActiveLink PHP XML Package is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
ActiveLink PHP XML Package 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ActiveLink PHP XML Package; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* Leaf class is part of a Tree-Branch-Leaf trio
* @class Leaf
* @package org.active-link.xml
* @author Zurab Davitiani
* @version 0.4.0
* @see Tree, Branch
*/
class Leaf {
// protected variables
var $value;
/**
* Constructor for the object
* @method Leaf
* @param optional mixed value
* @returns none
*/
function Leaf($value = "") {
$this->setValue($value);
}
/**
* Gets Leaf object value
* @method getValue
* @returns value of the object
*/
function getValue() {
return $this->value;
}
/**
* Sets Leaf object to the specified value
* @method setValue
* @param mixed value
* @returns none
*/
function setValue($value) {
$this->value = $value;
}
}
?>

View File

@@ -1,108 +0,0 @@
<?php
/*
This file is part of ActiveLink PHP XML Package (www.active-link.com).
Copyright (c) 2002-2004 by Zurab Davitiani
You can contact the author of this software via E-mail at
hattrick@mailcan.com
ActiveLink PHP XML Package is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
ActiveLink PHP XML Package 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ActiveLink PHP XML Package; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import("org.active-link.xml.XML");
/**
* Simple RSS class based on XML
* @class RSS
* @package org.active-link.xml
* @author Zurab Davitiani
* @version 0.4.0
* @requires XML
* @see XML
*/
class RSS {
var $xml;
var $rootTags;
var $itemBranches;
/**
* Constructor, parses the supplied RSS string into the object
* @method RSS
* @param string parseString
* @returns none
*/
function RSS($parseString) {
$this->xml = new XML_($parseString);
$this->rootTags = array("rss", "rdf:RDF");
$this->itemBranches = array();
$this->parseItemBranches();
}
/**
* Returns array of references to item branches of the RSS
* @method getItemBranches
* @returns array of references to objects of type XMLBranch (item branches of RSS)
*/
function getItemBranches() {
return $this->itemBranches;
}
/**
* Returns HTML-formatted RSS items
* @method getHTMLTitlesFormatted
* @returns string HTML-formatted RSS items
*/
function getHTMLTitlesFormatted() {
$itemBranchesXML = new XML_("ul");
reset($this->itemBranches);
foreach($this->itemBranches as $newsItem) {
$itemXML = new XMLBranch("li");
$itemLinkXML = new XMLBranch("a");
$itemLinkXML->setTagContent($newsItem->getTagContent("item/title"));
$itemLinkXML->setTagAttribute("href", $newsItem->getTagContent("item/link"));
$itemXML->addXMLBranch($itemLinkXML);
$itemBranchesXML->addXMLBranch($itemXML);
}
return $itemBranchesXML->getXMLString();
}
/**
* Parses RSS item branches, called from constructor
* @method parseItemBranches
* @returns true if successful, false otherwise
*/
function parseItemBranches() {
$success = false;
$rootTagName = $this->xml->getTagName();
if(in_array($rootTagName, $this->rootTags)) {
$tempBranches = array();
if($rootTagName == "rss")
$tempBranches = $this->xml->getBranches($rootTagName . "/channel", "item");
elseif($rootTagName == "rdf:RDF")
$tempBranches = $this->xml->getBranches($rootTagName, "item");
if($tempBranches !== false) {
$this->itemBranches = $tempBranches;
$success = true;
}
}
return $success;
}
}
?>

View File

@@ -1,422 +0,0 @@
<?php
/*
This file is part of ActiveLink PHP XML Package (www.active-link.com).
Copyright (c) 2002-2004 by Zurab Davitiani
You can contact the author of this software via E-mail at
hattrick@mailcan.com
ActiveLink PHP XML Package is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
ActiveLink PHP XML Package 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ActiveLink PHP XML Package; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* Tag class provides a base for parsing, modifying, outputting and creating XML tags
* @class Tag
* @package org.active-link.xml
* @author Zurab Davitiani
* @version 0.4.0
* @see XML
*/
class Tag {
// protected variables
var $tagStartOpen;
var $tagStartClose;
var $tagClose;
var $tagEndOpen;
var $tagEndClose;
var $tagName;
var $tagContent;
var $tagAttributes;
var $tagAttributeSeparator;
var $tagAttributeSeparators;
var $tagAttributeAssignment;
var $tagAttributeValueQuote;
var $FORMAT_NONE;
var $FORMAT_INDENT;
var $tagFormat;
var $tagFormatIndentLevel;
var $tagFormatEndTag;
var $tagFormatNewLine = "\n";
var $tagFormatIndent = "\t";
/**
* Constructor creates a tag object with the specified name and tag content
* @method Tag
* @param optional string name
* @param optional string content
* @returns none
*/
function Tag($name = "", $content = "") {
$this->tagStartOpen = "<";
$this->tagStartClose = ">";
$this->tagClose = "/>";
$this->tagEndOpen = "</";
$this->tagEndClose = ">";
$this->setTagName($name);
$this->setTagContent($content);
$this->tagAttributes = array();
$this->tagAttributeSeparator = " ";
$this->tagAttributeSeparators = array(" ", "\n", "\r", "\t");
$this->tagAttributeAssignment = "=";
$this->tagAttributeValueQuote = '"';
$this->FORMAT_NONE = 0;
$this->FORMAT_INDENT = 1;
$this->tagFormat = $this->FORMAT_NONE;
$this->tagFormatIndentLevel = 0;
$this->tagFormatEndTag = false;
}
/**
* Find out whether attribute exists
* @method attributeExists
* @param string attrName
* @returns true if attribute exists, false otherwise
*/
function attributeExists($attrName) {
return array_key_exists($attrName, $this->tagAttributes);
}
/**
* Get attribute value by its name
* @method getTagAttribute
* @param string attrName
* @returns string attribute value
*/
function getTagAttribute($attrName) {
return $this->tagAttributes[$attrName];
}
/**
* Get tag content string
* @method getTagContent
* @returns string tag content
*/
function getTagContent() {
return $this->tagContent;
}
/**
* Get tag name string
* @method getTagName
* @returns string tag name
*/
function getTagName() {
return $this->tagName;
}
/**
* Get complete tag string with its attributes and content
* @method getTagString
* @returns string tag string
*/
function getTagString() {
$formatTagBegin = "";
$formatTagEnd = "";
$formatContent = "";
if($this->tagFormat == $this->FORMAT_INDENT) {
if($this->tagFormatIndentLevel > 0)
$formatTagBegin = $this->tagFormatNewLine . str_repeat($this->tagFormatIndent, $this->tagFormatIndentLevel);
if($this->tagFormatEndTag)
$formatTagEnd = $this->tagFormatNewLine . str_repeat($this->tagFormatIndent, $this->tagFormatIndentLevel);
}
$tagString = $formatTagBegin . $this->getTagStringBegin() . $formatContent . $this->tagContent . $formatTagEnd . $this->getTagStringEnd();
return $tagString;
}
/**
* Get beginning of the tag string, i.e. its name attributes up until tag contents
* @method getTagStringBegin
* @returns string beginning of the tag string
*/
function getTagStringBegin() {
$tagString = "";
if($this->tagName != "") {
$tagString .= $this->tagStartOpen . $this->tagName;
foreach($this->tagAttributes as $attrName => $attrValue) {
$tagString .= $this->tagAttributeSeparator . $attrName . $this->tagAttributeAssignment . $this->tagAttributeValueQuote . $attrValue . $this->tagAttributeValueQuote;
}
if($this->tagContent == "")
$tagString .= $this->tagAttributeSeparator . $this->tagClose;
else
$tagString .= $this->tagStartClose;
}
return $tagString;
}
/**
* Get ending of the tag string, i.e. its closing tag
* @method getTagStringEnd
* @returns string close tag if tag is not short-handed, empty string otherwise
*/
function getTagStringEnd() {
$tagString = "";
if($this->tagName != "" && $this->tagContent != "")
$tagString .= $this->tagEndOpen . $this->tagName . $this->tagEndClose;
return $tagString;
}
/**
* Remove all tag attributes
* @method removeAllAttributes
* @returns none
*/
function removeAllAttributes() {
$this->tagAttributes = array();
}
/**
* Remove a tag attribute by its name
* @method removeAttribute
* @returns none
*/
function removeAttribute($attrName) {
unset($this->tagAttributes[$attrName]);
}
/**
* Reset the tag object - set name, content to empty strings, and reset all attributes
* @method resetTag
* @returns none
*/
function resetTag() {
$this->setTagName("");
$this->setTagContent("");
$this->removeAllAttributes();
}
/**
* Create or modify an existing attribute by supplying attribute name and value
* @method setAttribute
* @param string attrName
* @param string attrValue
* @returns none
*/
function setAttribute($attrName, $attrValue) {
$this->tagAttributes[$attrName] = $attrValue;
}
/**
* Set contents of the tag
* @method setTagContent
* @param string content
* @returns none
*/
function setTagContent($content) {
$this->tagContent = $content;
}
/**
* Set tag formatting option by specifying tagFormat to 0 (none), or 1 (indented)
* @method setTagFormat
* @param int tagFormat
* @param optional int tagFormatIndentLevel
* @returns none
*/
function setTagFormat($tagFormat, $tagFormatIndentLevel = 0) {
$this->tagFormat = $tagFormat;
$this->tagFormatIndentLevel = $tagFormatIndentLevel;
}
/**
* Set whether closing of the tag should be formatted or not
* @method setTagFormatEndTag
* @param optional boolean formatEndTag
* @returns none
*/
function setTagFormatEndTag($formatEndTag = true) {
$this->tagFormatEndTag = $formatEndTag;
}
/**
* Parse a string containing a tag into the tag object, this will parse the first tag found
* @method setTagFromString
* @param string tagString
* @returns array array of [0]=>index of the beginning of the tag, [1]=>index where tag ended
*/
function setTagFromString($tagString) {
$i = 0;
$j = 0;
$tagStartOpen = $tagStartClose = $tagNameStart = $tagNameEnd = $tagContentStart = $tagContentEnd = $tagEndOpen = $tagEndClose = 0;
$tagName = $tagContent = "";
$tagShort = false;
$tagAttributes = array();
$success = true;
$tagFound = false;
while(!$tagFound && $i < strlen($tagString)) {
// look for start tag character
$i = strpos($tagString, $this->tagStartOpen, $i);
if($i === false)
break;
// if tag name starts from alpha character we found the tag
if(ctype_alpha(substr($tagString, $i + 1, 1)))
$tagFound = true;
// else continue searching
else
$i ++;
}
// if no tag found set success to false
if(!$tagFound)
$success = false;
// if so far so good continue with found tag name
if($success) {
$tagStartOpen = $i;
$tagNameStart = $i + 1;
// search where tag name would end
// search for a space separator to account for attributes
$separatorPos = array();
for($counter = 0; $counter < count($this->tagAttributeSeparators); $counter ++) {
$separatorPosTemp = strpos($tagString, $this->tagAttributeSeparators[$counter], $tagStartOpen);
if($separatorPosTemp !== false)
$separatorPos[] = $separatorPosTemp;
}
//$i = strpos($tagString, $this->tagAttributeSeparator, $tagStartOpen);
if(count($separatorPos) > 0)
$i = min($separatorPos);
else
$i = false;
// search for tag close character
$j = strpos($tagString, $this->tagStartClose, $tagStartOpen);
// search for short tag (no content)
$k = strpos($tagString, $this->tagClose, $tagStartOpen);
// if tag close character is not found then no tag exists, set success to false
if($j === false)
$success = false;
// if tag short close found before tag close, then tag is short
if($k !== false && $k < $j)
$tagShort = true;
}
// if so far so good set tag name correctly
if($success) {
// if space separator not found or it is found after the tag close char
if($i === false || $i > $j) {
if($tagShort)
$tagNameEnd = $k;
else
$tagNameEnd = $j;
$tagStartClose = $j;
}
// else if tag attributes exist
else {
$tagNameEnd = $i;
$tagStartClose = $j;
// parse attributes
$tagAttributesStart = $i + strlen($this->tagAttributeSeparator);
$attrString = trim(substr($tagString, $tagAttributesStart, $j - $tagAttributesStart));
$attrArray = explode($this->tagAttributeValueQuote, $attrString);
$attrCounter = 0;
while($attrCounter < count($attrArray) - 1) {
$attributeName = trim(str_replace($this->tagAttributeAssignment, "", $attrArray[$attrCounter]));
$attributeValue = $attrArray[$attrCounter + 1];
$tagAttributes[$attributeName] = $attributeValue;
$attrCounter += 2;
}
}
$tagName = rtrim(substr($tagString, $tagNameStart, $tagNameEnd - $tagNameStart));
if(!$tagShort) {
$tagContentStart = $tagStartClose + 1;
// look for ending of the tag after tag content
$j = $tagContentStart;
$tagCloseFound = false;
// while loop will find the k-th tag close
// start with one since we have one tag open
$k = 1;
while(!$tagCloseFound && $success) {
// find k-th tag close from j
$n = $j - 1;
for($skip = 0; $skip < $k; $skip ++) {
$n ++;
$tempPos = strpos($tagString, $this->tagEndOpen . $tagName . $this->tagEndClose, $n);
if($tempPos !== false)
$n = $tempPos;
else {
$success = false;
break;
}
}
// if success, find number of tag opens before the tag close
$k = 0;
if($success) {
$tempString = substr($tagString, $j, $n - $j);
$tempNewPos = 0;
do {
$tempPos = strpos($tempString, $this->tagStartOpen . $tagName, $tempNewPos);
if($tempPos !== false) {
$tempPosChar = substr($tempString, $tempPos + strlen($this->tagStartOpen . $tagName), 1);
$tagEndArray = $this->tagAttributeSeparators;
$tagEndArray[] = $this->tagEndClose;
$tempPosTagEnded = array_search($tempPosChar, $tagEndArray);
if($tempPosTagEnded !== false && $tempPosTagEnded !== NULL) {
$tempStartClose = strpos($tempString, $this->tagStartClose, $tempPos);
$tempStartShortClose = strpos($tempString, $this->tagClose, $tempPos);
// if open tag found increase counter
if($tempStartClose !== false && ($tempStartShortClose === false || $tempStartClose < $tempStartShortClose))
$k ++;
$tempNewPos = $tempPos + strlen($this->tagStartOpen . $tagName);
}
else
$tempNewPos = $tempPos + strlen($this->tagStartOpen . $tagName);
}
} while($tempPos !== false);
}
// if no tags opened we found the tag close
if($k == 0)
$tagCloseFound = true;
// else set new j
else {
$j = $n + strlen($this->tagEndOpen . $tagName . $this->tagEndClose);
}
}
if($tagCloseFound)
$i = $n;
else
$success = false;
}
}
// if so far so good, then we have everything we need! set the object
if($success) {
if(!$tagShort) {
$tagContentEnd = $i;
$tagContent = substr($tagString, $tagContentStart, $tagContentEnd - $tagContentStart);
$tagEndOpen = $i;
$tagEndClose = $tagEndOpen + strlen($this->tagEndOpen . $tagName . $this->tagEndClose);
}
else
$tagEndClose = $tagStartClose + strlen($this->tagStartClose);
$this->setTagName($tagName);
$this->setTagContent($tagContent);
$this->tagAttributes = $tagAttributes;
}
if($success)
return array($tagStartOpen, $tagEndClose);
else
return false;
}
/**
* Set tag name
* @method setTagName
* @param string name
* @returns none
*/
function setTagName($name) {
$this->tagName = $name;
}
}
?>

View File

@@ -1,94 +0,0 @@
<?php
/*
This file is part of ActiveLink PHP XML Package (www.active-link.com).
Copyright (c) 2002-2004 by Zurab Davitiani
You can contact the author of this software via E-mail at
hattrick@mailcan.com
ActiveLink PHP XML Package is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
ActiveLink PHP XML Package 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ActiveLink PHP XML Package; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* Tree class provides a base for Tree-Branch-Leaf trio
* @class Tree
* @package org.active-link.xml
* @author Zurab Davitiani
* @version 0.4.0
* @see Branch, Leaf
*/
class Tree {
// protected variables
var $nodes;
var $id = 0;
/**
* Constructor for the object
* @method Tree
* @returns none
*/
function Tree() {
$this->nodes = array();
}
/**
* Adds given node to the Tree
* @method addNode
* @param mixed id
* @param mixed node
* @returns true if successful, false otherwise
*/
function addNode($id, $node) {
$success = true;
if($id == -1)
$this->nodes[] = $node;
else
if(isset($this->nodes[$id]))
$success = false;
else
$this->nodes[$id] = $node;
return $success;
}
/**
* Removes all nodes
* @method removeAllNodes
* @returns none
*/
function removeAllNodes () {
$this->nodes = array();
}
/**
* Removes specified node from the Tree
* @method removeNode
* @param mixed id
* @returns true if successful, false otherwise
*/
function removeNode($id) {
$success = false;
if(isset($this->nodes[$id])) {
unset($this->nodes[$id]);
$success = true;
}
return $success;
}
}
?>

View File

@@ -1,580 +0,0 @@
<?php
/*
This file is part of ActiveLink PHP XML Package (www.active-link.com).
Copyright (c) 2002-2004 by Zurab Davitiani
You can contact the author of this software via E-mail at
hattrick@mailcan.com
ActiveLink PHP XML Package is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
ActiveLink PHP XML Package 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ActiveLink PHP XML Package; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import("org.active-link.xml.Tag");
import("org.active-link.xml.Tree");
/**
* XML class provides a tree-like structure to read/write/modify XML
* @class XML
* @package org.active-link.xml
* @author Zurab Davitiani
* @version 0.4.0
* @extends Tree
* @requires Tag, Tree, XMLBranch, XMLLeaf
* @see Tree
*/
class XML_ extends Tree {
// protected variables
var $tag;
var $pathSeparator;
/**
* If argument is an XML String it parses the string into XML object
* If argument is a tag path, creates appropriate branches and tags
* If argument is a simple string then sets that as a root tag name
* @method XML
* @param optional string argument
* @returns none
*/
function XML_($argument = "") {
$success = false;
$this->Tree();
$this->pathSeparator = "/";
$this->tag = new Tag();
if(is_string($argument)) {
// if this is an XML string to be parsed
if(strpos($argument, $this->tag->tagEndOpen) > 0 || strpos($argument, $this->tag->tagClose) > 0)
$this->parseFromString($argument);
// else if this is a tag path to be created
elseif(strpos($argument, $this->pathSeparator) > 0) {
$tags = explode($this->pathSeparator, $argument);
$this->tag->setTagName($tags[0]);
$this->setTagContent("", $argument);
}
else
$this->tag->setTagName($argument);
$success = true;
}
else
$success = false;
return $success;
}
/**
* Adds another XML tree as a branch to the current XML object
* @method addXMLAsBranch
* @param object xml
* @param optional mixed id
* @returns true if successful, false otherwise
*/
function addXMLAsBranch($xml, $id = -1) {
$success = false;
if(is_object($xml) && strtolower(get_class($xml)) == "xml") {
$newBranch = new XMLBranch();
$newBranch->nodes = $xml->nodes;
$newBranch->tag = $xml->tag;
$success = $this->addXMLBranch($newBranch, $id);
}
return $success;
}
/**
* Adds XML Branch to the current XML object
* @method addXMLBranch
* @param object xmlBranch
* @param optional mixed id
* @returns true if successful, false otherwise
*/
function addXMLBranch($xmlBranch, $id = -1) {
$success = false;
if(is_object($xmlBranch) && strtolower(get_class($xmlBranch)) == "xmlbranch") {
$xmlBranch->setParentXML($this);
$success = $this->addNode($id, $xmlBranch);
}
return $success;
}
/**
* Adds XML Leaf to the current XML object
* @method addXMLLeaf
* @param object xmlLeaf
* @param optional mixed id
* @returns true if successful, false otherwise
*/
function addXMLLeaf($xmlLeaf, $id = -1) {
$success = false;
if(is_object($xmlLeaf) && strtolower(get_class($xmlLeaf)) == "xmlleaf") {
$xmlLeaf->setParentXML($this);
$success = $this->addNode($id, $xmlLeaf);
}
return $success;
}
/**
* Retrieves an array of references to XMLBranches within the specified path, tag name, attribute name, and attribute value
* @method getBranches
* @param optional string tagPath
* @param optional string tagName
* @param optional string attrName
* @param optional string attrValue
* @returns array of references to XMLBranch objects that meet specified criteria, or false if none found
*/
function getBranches($tagPath = "", $tagName = "", $attrName = "", $attrValue = "") {
$branchArray = array();
if($tagPath == "")
$tagPath = $this->tag->getTagName();
$tags = explode($this->pathSeparator, $tagPath);
if($this->tag->getTagName() == $tags[0]) {
if(count($tags) == 1) {
$arrKeys = array_keys($this->nodes);
for($index = 0; $index < count($arrKeys); $index ++) {
if(gettype($this->nodes[$arrKeys[$index]]) == "object" && strtolower(get_class($this->nodes[$arrKeys[$index]])) == "xmlbranch") {
if(($tagName == "" || $this->nodes[$arrKeys[$index]]->tag->getTagName() == $tagName) &&
($attrName == "" || $this->nodes[$arrKeys[$index]]->tag->attributeExists($attrName)) &&
($attrValue == "" || $this->nodes[$arrKeys[$index]]->tag->getTagAttribute($attrName) == $attrValue)) {
$branchArray[] = &$this->nodes[$arrKeys[$index]];
}
}
}
}
else {
$arrKeys = array_keys($this->nodes);
for($index = 0; $index < count($arrKeys); $index ++) {
if(gettype($this->nodes[$arrKeys[$index]]) == "object" && strtolower(get_class($this->nodes[$arrKeys[$index]])) == "xmlbranch") {
if($this->nodes[$arrKeys[$index]]->tag->getTagName() == $tags[1]) {
$newTagPath = implode($this->pathSeparator, array_slice($tags, 1));
$newArray = $this->nodes[$arrKeys[$index]]->getBranches($newTagPath, $tagName, $attrName, $attrValue);
if($newArray !== false)
$branchArray = array_merge($branchArray, $newArray);
}
}
}
}
}
if(count($branchArray) == 0)
$branchArray = false;
return $branchArray;
}
/**
* Retrieves an array of references to XMLLeaf(s) within the specified path
* @method getLeafs
* @param optional string tagPath
* @returns array of references to XMLLeaf objects in specified tag path, false if none found
*/
function getLeafs($tagPath = "") {
$leafArray = array();
if($tagPath == "")
$tagPath = $this->tag->getTagName();
$tags = explode($this->pathSeparator, $tagPath);
if($this->tag->getTagName() == $tags[0]) {
if(count($tags) == 1) {
$arrKeys = array_keys($this->nodes);
for($index = 0; $index < count($arrKeys); $index ++) {
if(gettype($this->nodes[$arrKeys[$index]]) == "object" && strtolower(get_class($this->nodes[$arrKeys[$index]])) == "xmlleaf") {
$leafArray[] = &$this->nodes[$arrKeys[$index]];
}
}
}
else {
$arrKeys = array_keys($this->nodes);
for($index = 0; $index < count($arrKeys); $index ++) {
if(gettype($this->nodes[$arrKeys[$index]]) == "object" && strtolower(get_class($this->nodes[$arrKeys[$index]])) == "xmlbranch") {
if($this->nodes[$arrKeys[$index]]->tag->getTagName() == $tags[1]) {
$newTagPath = implode($this->pathSeparator, array_slice($tags, 1));
$newArray = $this->nodes[$arrKeys[$index]]->getLeafs($newTagPath);
if($newArray !== false)
$leafArray = array_merge($leafArray, $newArray);
}
}
}
}
}
if(count($leafArray) == 0)
$leafArray = false;
return $leafArray;
}
/**
* Returns attribute value of the specified tag and tagpath
* @method getTagAttribute
* @param string attributeName
* @param optional string tagPath
* @returns attribute of the specified tag if successful, false otherwise
*/
function getTagAttribute($attributeName, $tagPath = "") {
if($tagPath == "")
$tagPath = $this->tag->getTagName();
$tags = explode($this->pathSeparator, $tagPath);
$attributeValue = false;
if($this->tag->getTagName() == $tags[0]) {
if(sizeof($tags) == 1) {
if($this->tag->attributeExists($attributeName))
$attributeValue = $this->tag->getTagAttribute($attributeName);
}
else {
foreach($this->nodes as $node) {
if(strtolower(get_class($node)) == "xmlbranch")
if($node->tag->getTagName() == $tags[1]) {
$newTagPath = implode($this->pathSeparator, array_slice($tags, 1));
$attributeValue = $node->getTagAttribute($attributeName, $newTagPath);
}
}
}
}
return $attributeValue;
}
/**
* Returns contents of the specified tag path
* @method getTagContent
* @param optional string tagPath
* @returns content of the tag from the specified path if successful, false otherwise
*/
function getTagContent($tagPath = "") {
if($tagPath == "")
$tagPath = $this->tag->getTagName();
$tags = explode($this->pathSeparator, $tagPath);
$tagValue = false;
if($this->tag->getTagName() == $tags[0]) {
if(sizeof($tags) == 1)
$tagValue = $this->getXMLContent();
else {
foreach($this->nodes as $node) {
if(strtolower(get_class($node)) == "xmlbranch")
if($node->tag->getTagName() == $tags[1]) {
$newTagPath = implode($this->pathSeparator, array_slice($tags, 1));
$tagValue = $node->getTagContent($newTagPath);
}
}
}
}
return $tagValue;
}
/**
* Retrieves the tag name of the current object
* @method getTagName
* @returns tag name
*/
function getTagName() {
return($this->tag->getTagName());
}
/**
* Gets contents from the current object
* @method getXMLContent
* @returns contents of the current XML tag
*/
function getXMLContent() {
$xmlContent = "";
foreach($this->nodes as $node) {
if(gettype($node) == "object") {
if(strtolower(get_class($node)) == "xmlbranch")
$xmlContent .= $node->getXMLString();
elseif(strtolower(get_class($node)) == "xmlleaf")
$xmlContent .= $node->getValue();
}
}
return $xmlContent;
}
/**
* Gets the whole XML string of the current object
* @method getXMLString
* @param optional mixed indent
* @returns complete XML string of current object
*/
function getXMLString($indent = false) {
$xmlString = "";
$containsBranches = false;
$containsLeafs = false;
$newIndent = false;
if($indent === false)
$newIndent = false;
else {
$newIndent = $indent + 1;
$this->tag->setTagFormat($this->tag->FORMAT_INDENT, $indent);
}
foreach($this->nodes as $node) {
if(gettype($node) == "object") {
if(strtolower(get_class($node)) == "xmlbranch") {
$this->tag->tagContent .= $node->getXMLString($newIndent);
$containsBranches = true;
}
elseif(strtolower(get_class($node)) == "xmlleaf") {
$this->tag->tagContent .= $node->getValue();
$containsLeafs = true;
}
}
}
if($containsBranches)
$this->tag->setTagFormatEndTag(true);
$xmlString = $this->tag->getTagString();
$this->tag->setTagContent("");
return $xmlString;
}
/**
* Find out whether the current object has any branches
* @method hasBranch
* @returns true if branches exist, false otherwise
*/
function hasBranch() {
$hasBranch = false;
foreach($this->nodes as $node) {
if(strtolower(get_class($node)) == "xmlbranch") {
$hasBranch = true;
break;
}
}
return $hasBranch;
}
/**
* Find out whether the current object has any leaf(s)
* @method hasLeaf
* @returns true if leaf(s) exist, false otherwise
*/
function hasLeaf() {
$hasLeaf = false;
foreach($this->nodes as $node) {
if(strtolower(get_class($node)) == "xmlleaf") {
$hasLeaf = true;
break;
}
}
return $hasLeaf;
}
/**
* Parse entire XML string into the current object; also called from constructor
* @method parseFromString
* @param string parseString
* @returns none
*/
function parseFromString($parseString) {
$tagResult = $this->tag->setTagFromString($parseString);
if($tagResult !== false) {
$this->parseNodesFromTag();
$this->tag->setTagContent("");
}
}
/**
* Parses the current tag content into Branches and Leaf(s); called from parseFromString
* @method parseNodesFromTag
* @returns none
*/
function parseNodesFromTag() {
$tempTag = new Tag();
$parseString = $this->tag->getTagContent();
while($tagParsed = $tempTag->setTagFromString($parseString)) {
if($tagParsed[0] != 0 && substr($parseString, 0, $tagParsed[0]) != "")
$this->addXMLLeaf(new XMLLeaf(substr($parseString, 0, $tagParsed[0])));
$branch = new XMLBranch();
$tempTagCopy = new Tag();
$tempTagCopy->setTagName($tempTag->getTagName());
$tempTagCopy->tagAttributes = $tempTag->tagAttributes;
$tempTagCopy->setTagContent($tempTag->getTagContent());
$branch->setTag($tempTagCopy);
$branch->parseNodesFromTag();
$branch->tag->setTagContent("");
$this->addXMLBranch($branch);
$parseString = substr($parseString, $tagParsed[1]);
}
if(strlen($parseString) > 0 && $parseString != "")
$this->addXMLLeaf(new XMLLeaf($parseString));
}
/**
* Removes all Branches from current object
* @method removeAllBranches
*/
function removeAllBranches() {
foreach($this->nodes as $key => $value) {
if(strtolower(get_class($value)) == "xmlbranch")
unset($this->nodes[$key]);
}
}
/**
* Removes all Leaf(s) from current object
* @method removeAllLeafs
*/
function removeAllLeafs() {
foreach($this->nodes as $key => $value) {
if(strtolower(get_class($value)) == "xmlleaf")
unset($this->nodes[$key]);
}
}
/**
* Removes Branches with the specified criteria
* @method removeBranches
* @param optional string tagPath
* @param optional string tagName
* @param optional string attrName
* @param optional string attrValue
* @returns number of branches deleted
*/
function removeBranches($tagPath = "", $tagName = "", $attrName = "", $attrValue = "") {
$branchesDeleted = 0;
$referencedBranches = array();
$tags = explode($this->pathSeparator, $tagPath);
if(count($tags) > 1) {
$parentTagName = array_pop($tags);
$parentTagPath = implode($this->pathSeparator, $tags);
$referencedBranches = $this->getBranches($parentTagPath, $parentTagName);
}
else {
$referencedBranches[] = &$this;
}
for($i = 0; $i < count($referencedBranches); $i ++) {
$arrKeys = array_keys($referencedBranches[$i]->nodes);
for($index = 0; $index < count($arrKeys); $index ++) {
if(gettype($referencedBranches[$i]->nodes[$arrKeys[$index]]) == "object" && strtolower(get_class($referencedBranches[$i]->nodes[$arrKeys[$index]])) == "xmlbranch") {
if(($tagName == "" || $referencedBranches[$i]->nodes[$arrKeys[$index]]->tag->getTagName() == $tagName) &&
($attrName == "" || $referencedBranches[$i]->nodes[$arrKeys[$index]]->tag->attributeExists($attrName)) &&
($attrValue == "" || $referencedBranches[$i]->nodes[$arrKeys[$index]]->tag->getTagAttribute($attrName) == $attrValue)) {
$referencedBranches[$i]->removeNode($arrKeys[$index]);
$branchesDeleted ++;
}
}
}
}
return $branchesDeleted;
}
/**
* Sets tag object of a branch specified by branch ID for the current object; see getBranches and setTag
* @method setBranchTag
* @param mixed branchId
* @param object tag
* @returns true on success, false otherwise
*/
function setBranchTag($branchId, $tag) {
$success = true;
if(strtolower(get_class($this->nodes[$branchId])) == "xmlbranch" && strtolower(get_class($tag)) == "tag")
$this->nodes[$branchId]->setTag($tag);
else
$success = false;
return $success;
}
/**
* Sets tag object of the current object
* @method setTag
* @param object tag
* @returns true if successful, false otherwise
*/
function setTag($tag) {
$success = true;
if(strtolower(get_class($tag)) == "tag")
$this->tag = $tag;
else
$success = false;
return $success;
}
/**
* Sets an attribute name and value on an existing tag found via tagpath string
* @method setTagAttribute
* @param string attributeName
* @param optional string attributeValue
* @param optional string tagPath
* @returns true if successful, false otherwise
*/
function setTagAttribute($attributeName, $attributeValue = "", $tagPath = "") {
if($tagPath == "")
$tagPath = $this->tag->getTagName();
$success = true;
$tags = explode($this->pathSeparator, $tagPath);
if($this->tag->getTagName() == $tags[0]) {
if(sizeof($tags) == 1)
$this->tag->setAttribute($attributeName, $attributeValue);
else {
$nodeTagFound = false;
reset($this->nodes);
$arrKeys = array_keys($this->nodes);
for($index = 0; $index < count($arrKeys); $index ++) {
$node =& $this->nodes[$arrKeys[$index]];
if(strtolower(get_class($node)) == "xmlbranch")
if($node->tag->getTagName() == $tags[1]) {
$newTagPath = implode($this->pathSeparator, array_slice($tags, 1));
$success = $node->setTagAttribute($attributeName, $attributeValue, $newTagPath);
$nodeTagFound = true;
}
}
if(!$nodeTagFound)
$success = false;
}
}
else
$success = false;
return $success;
}
/**
* Sets content of the specified tag
* @method setTagContent
* @param mixed content
* @param optional string tagPath
* @returns true if successful, false otherwise
*/
function setTagContent($content, $tagPath = "") {
if($tagPath == "")
$tagPath = $this->tag->getTagName();
$success = true;
$tags = explode($this->pathSeparator, $tagPath);
if($this->tag->getTagName() == $tags[0]) {
if(sizeof($tags) == 1) {
//$this->nodes = array(new XMLLeaf($content));
$this->removeAllNodes();
$this->addXMLLeaf(new XMLLeaf($content));
}
else {
$nodeTagFound = false;
reset($this->nodes);
$arrKeys = array_keys($this->nodes);
for($index = 0; $index < count($arrKeys); $index ++) {
$node =& $this->nodes[$arrKeys[$index]];
if(strtolower(get_class($node)) == "xmlbranch")
if($node->tag->getTagName() == $tags[1]) {
$newTagPath = implode($this->pathSeparator, array_slice($tags, 1));
$success = $node->setTagContent($content, $newTagPath);
$nodeTagFound = true;
}
}
if(!$nodeTagFound) {
$branch = new XMLBranch();
$branch->setTag(new Tag($tags[1]));
$newTagPath = implode($this->pathSeparator, array_slice($tags, 1));
$branch->setTagContent($content, $newTagPath);
$this->addXMLBranch($branch);
}
}
}
return $success;
}
}
import("org.active-link.xml.XMLBranch");
import("org.active-link.xml.XMLLeaf");
?>

View File

@@ -1,71 +0,0 @@
<?php
/*
This file is part of ActiveLink PHP XML Package (www.active-link.com).
Copyright (c) 2002-2004 by Zurab Davitiani
You can contact the author of this software via E-mail at
hattrick@mailcan.com
ActiveLink PHP XML Package is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
ActiveLink PHP XML Package 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ActiveLink PHP XML Package; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* requires XML class
*/
import("org.active-link.xml.XML");
/**
* XMLBranch class provides a tree-like structure to read/write/modify XML
* @class XMLBranch
* @package org.active-link.xml
* @author Zurab Davitiani
* @version 0.4.0
* @extends XML
* @requires XML
* @see Tree
*/
class XMLBranch extends XML_ {
var $parentXML;
/**
* Gets parent object of the XML branch
* @method getParentXML
* @returns parent object of the XML branch
*/
function getParentXML() {
return $this->parentXML;
}
/**
* Sets parent object of the XML branch
* @method setParentXML
* @param object xml
* @returns true if successful, false otherwise
*/
function setParentXML(&$xml) {
$success = false;
if(strtolower(get_class($xml)) == "xml" || strtolower(get_class($xml)) == "xmlbranch") {
$this->parentXML = &$xml;
$success = true;
}
return $success;
}
}
?>

View File

@@ -1,174 +0,0 @@
<?php
/*
This file is part of ActiveLink PHP XML Package (www.active-link.com).
Copyright (c) 2002-2004 by Zurab Davitiani
You can contact the author of this software via E-mail at
hattrick@mailcan.com
ActiveLink PHP XML Package is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
ActiveLink PHP XML Package 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ActiveLink PHP XML Package; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* requires XML, Tag and File classes
*/
import("org.active-link.xml.XML");
import("org.active-link.sys.File");
import("org.active-link.xml.Tag");
/**
* XMLDocument class provides a document class for XML
* @class XMLDocument
* @package org.active-link.xml
* @author Zurab Davitiani
* @version 0.4.0
* @extends File
* @requires File, XML, Tag
* @see XML
*/
class XMLDocument extends File {
// protected variables
var $xml;
var $tag;
/**
* If filename is set and fileOpenMode is one of the modes that allows file to be read then file is opened and its contents parsed
* If filename is set and fileOpenMode is something other than above the appropriate file is opened/created
* If filename is not set then no files are opened/parsed/created and object contains default values
* @method XMLDocument
* @param optional string filename
* @param optional string fileOpenMode
*/
function XMLDocument($filename = "", $fileOpenMode = "r") {
$success = $this->File($filename, $fileOpenMode);
$this->tag = new Tag();
$this->tag->tagStartOpen = "<?";
$this->tag->tagClose = "?>";
if($this->connected && ($this->fileOpenMode == $this->fileOpenModeRead || $this->fileOpenMode == $this->fileOpenModeReadWrite)) {
$fileContents = $this->getContents();
$this->close();
$this->parseFromString($fileContents);
}
else {
$this->setDefaultXMLTag();
$this->xml = new XML_();
}
return $success;
}
/**
* Returns the XML object containing actual XML tree; in PHP 4 make sure to use =& to get a reference instead of a copy
* @method getXML
* @returns object of type XML containing actual XML tree
*/
function getXML() {
return $this->xml;
}
/**
* Returns the XML string of a complete XML document
* @method getXMLString
* @returns string containing contents of XML document
*/
function getXMLString() {
$xmlString = $this->tag->getTagString();
$xmlString .= "\n\n";
$xmlString .= $this->xml->getXMLString(0);
return $xmlString;
}
/**
* Parses XML document from supplied string, also called from constructor when parsing file contents
* @method parseFromString
* @param string XMLDocString
* @returns none
*/
function parseFromString($XMLDocString) {
$tagPos = $this->tag->setTagFromString($XMLDocString);
if($tagPos === false) {
$tagPos = array(0 => 0, 1 => 0);
$this->setDefaultXMLTag();
}
$xmlContents = trim(substr($XMLDocString, $tagPos[1]));
$this->xml = new XML_($xmlContents);
}
/**
* Saves document contents to a supplied filename
* @method save
* @param string filename
* @returns true if successful, false otherwise
*/
function save($filename) {
$success = $this->open($filename, $this->fileOpenModeWrite);
if($success) {
$bytesWritten = $this->write($this->getXMLString());
if($bytesWritten <= 0)
$success = false;
$this->close();
}
return $success;
}
/**
* (Re)sets XML version/encoding to default values
* @method setDefaultXMLTag
* @returns none
*/
function setDefaultXMLTag() {
$this->tag->setTagName("xml");
$this->tag->setAttribute("version", "1.0");
$this->tag->setAttribute("encoding", "UTF-8");
}
/**
* Sets encoding of the XML document
* @method setEncoding
* @param string encoding
* @returns none
*/
function setEncoding($encoding) {
$this->tag->setAttribute("encoding", $encoding);
}
/**
* Sets version of the XML document
* @method setVersion
* @param string version
* @returns none
*/
function setVersion($version) {
$this->tag->setAttribute("version", $version);
}
/**
* Sets XML object of the XMLDocument, sets/changes/updates XML content to the supplied XML tree, uses reference no copy is created
* @method setXML
* @param object xml
* @returns true if successful, false otherwise
*/
function setXML(&$xml) {
$success = false;
if(gettype($xml) == "object" && strtolower(get_class($xml)) == "xml") {
$this->xml = &$xml;
$success = true;
}
return $success;
}
}

View File

@@ -1,73 +0,0 @@
<?php
/*
This file is part of ActiveLink PHP XML Package (www.active-link.com).
Copyright (c) 2002-2004 by Zurab Davitiani
You can contact the author of this software via E-mail at
hattrick@mailcan.com
ActiveLink PHP XML Package is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
ActiveLink PHP XML Package 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ActiveLink PHP XML Package; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* requires XML class
*/
import("org.active-link.xml.XML");
import("org.active-link.xml.XMLBranch");
import("org.active-link.xml.Leaf");
/**
* XMLLeaf class provides means to store text values for use in XML tree
* @class XMLLeaf
* @package org.active-link.xml
* @author Zurab Davitiani
* @version 0.4.0
* @extends Leaf
* @requires Leaf
* @see XML
*/
class XMLLeaf extends Leaf {
var $parentXML;
/**
* Gets parent object of the XML leaf
* @method getParentXML
* @returns parent object of the XML leaf
*/
function getParentXML() {
return $this->parentXML;
}
/**
* Sets parent object of the XML leaf
* @method setParentXML
* @param object xml
* @returns true if successful, false otherwise
*/
function setParentXML(&$xml) {
$success = false;
if(strtolower(get_class($xml)) == "xml" || strtolower(get_class($xml)) == "xmlbranch") {
$this->parentXML = &$xml;
$success = true;
}
return $success;
}
}
?>

View File

@@ -1,120 +0,0 @@
<?php
/*
This file is part of ActiveLink PHP XML Package (www.active-link.com).
Copyright (c) 2002-2004 by Zurab Davitiani
You can contact the author of this software via E-mail at
hattrick@mailcan.com
ActiveLink PHP XML Package is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
ActiveLink PHP XML Package 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ActiveLink PHP XML Package; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* requires HTTPClient, XML and XMLDocument classes
*/
import("org.active-link.net.HTTPClient");
import("org.active-link.xml.XML");
import("org.active-link.xml.XMLDocument");
/**
* XMLRPCClient class provides XML-RPC client capabilities
* @class XMLRPCClient
* @package org.active-link.xml
* @author Zurab Davitiani
* @version 0.4.0
* @extends HTTPClient
* @requires HTTPClient, XML, XMLDocument
* @see HTTPClient
*/
class XMLRPCClient extends HTTPClient {
var $xml;
var $xmlDoc;
var $params;
/**
* XMLRPCClient client class constructor accepts host (required) and port (optional, default 80) arguments
* @method XMLRPCClient
* @param string host
* @param optional int port
*/
function XMLRPCClient($host, $port = 80) {
$this->HTTPClient($host, $port);
$this->setRequestMethod("POST");
$this->addRequestHeaderRaw("Content-type: text/xml");
$this->xml = new XML_("methodCall");
$this->xml->setTagContent("", "methodCall/methodName");
$this->xml->setTagContent("", "methodCall/params");
$this->xmlDoc = new XMLDocument();
$this->xmlDoc->setXML($this->xml);
$paramsBranchArray = &$this->xml->getBranches("methodCall", "params");
$this->params = &$paramsBranchArray[0];
// this call not necessary if we can somehow update body before HTTPClient->sendRequest
$this->setRequestBody($this->xmlDoc->getXMLString());
}
/**
* Adds a parameter to a method call in XMLRPC request
* @method addParam
* @param string paramType
* @param mixed paramValue
* @returns none
*/
function addParam($paramType, $paramValue) {
$newParam = new XMLBranch("param");
$newParam->setTagContent($paramValue, "param/value/$paramType");
$this->params->addXMLBranch($newParam);
// this call not necessary if we can somehow update body before HTTPClient->sendRequest
$this->setRequestBody($this->xmlDoc->getXMLString());
}
/**
* Sets method name in XMLRPC request
* @method setMethodName
* @param string methodName
* @returns none
*/
function setMethodName ($methodName) {
$this->xml->setTagContent($methodName, "methodCall/methodName");
// this call not necessary if we can somehow update body before HTTPClient->sendRequest
$this->setRequestBody($this->xmlDoc->getXMLString());
}
/**
* Sets XMLRPC request by supplying an XMLDocument object
* @method setRequestXML
* @param object XMLDocument
* @returns true if successful, false otherwise
*/
function setRequestXML(&$XMLDocument) {
if(is_object($XMLDocument) && strtolower(get_class($XMLDocument)) == "xmldocument") {
$this->xmlDoc = &$XMLDocument;
$this->xml = &$this->xmlDoc->getXML();
$this->params = &$this->xml->getBranches("methodCall", "params");
// this call not necessary if we can somehow update body before HTTPClient->sendRequest
$this->setRequestBody(htmlspecialchars($this->xmlDoc->getXMLString()));
$success = true;
}
else
$success = false;
return $success;
}
}
?>

View File

@@ -1,46 +0,0 @@
<?php
/*
This file is part of ActiveLink PHP XML Package (www.active-link.com).
Copyright (c) 2002-2004 by Zurab Davitiani
You can contact the author of this software via E-mail at
hattrick@mailcan.com
ActiveLink PHP XML Package is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
ActiveLink PHP XML Package 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with ActiveLink PHP XML Package; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* requires XML class
*/
import("org.active-link.xml.XML");
/**
* XPath class provides XPath interface to XML object
* @class XPath
* @package org.active-link.xml
* @author Zurab Davitiani
* @version 0.4.0
* @see XML
*/
class XPath {
var $xml;
}
?>

View File

@@ -1,157 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/config.inc.php,v 1.44 2007/04/01 12:11:24 Konstantin Exp $
/**
* Common configuration options
*/
// Directory containing HTML2PS script files (with traling slash)
if (!defined('HTML2PS_DIR')) {
define('HTML2PS_DIR', dirname(__FILE__).'/');
};
// User-Agent HTTP header to send when requesting a file
define('DEFAULT_USER_AGENT',"Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7) Gecko/20040803 Firefox/0.9.3");
// Default PDF or PS file name to use
define('OUTPUT_DEFAULT_NAME','unnamed');
// Default text encoding to use when no encoding information is available
define('DEFAULT_ENCODING', 'iso-8859-1');
/**
* Postscript-specific configuration options
*/
// Path to Ghostscript executable
define('GS_PATH','c:\gs\gs8.51\bin\gswin32c.exe');
// Path to font metric files (AFM files).
// NOTE: Trailing backslash required
//define('TYPE1_FONTS_REPOSITORY',"c:\\gs\\fonts\\");
//define('TYPE1_FONTS_REPOSITORY',"/usr/share/ghostscript/fonts/");
define('TYPE1_FONTS_REPOSITORY',"/usr/share/fonts/default/Type1/");
/**
* PDFLIB-specific configuration options
*/
// Path to PDFLIB dynamically loaded library (if not configured in php.ini to load automatically)
define('PDFLIB_DL_PATH','pdflib.so');
// Uncomment this if you have PDFLIB license key and want to use it
// define('PDFLIB_LICENSE', 'YOUR LICENSE KEY');
// This variable defines the path to PDFLIB configuration file; in particular, it contains
// information about the supported encodings.
//
// define('PDFLIB_UPR_PATH',"c:/php/php4.4.0/pdf-related/pdflib.upr");
// define('PDFLIB_UPR_PATH',"c:/php/pdf-related/pdflib.upr");
// Path to directory containing fonts used by PDFLIB / FPDF
// Trailing backslash required
define('TTF_FONTS_REPOSITORY',HTML2PS_DIR."fonts/");
/**
* Some constants you better not change.
*
* They're created in order to avoid using too much "magic numbers" in the script source,
* but it is very unlikely you'll need to change them
*/
define('EPSILON',0.001);
define('DEFAULT_SUBMIT_TEXT','Submit');
define('DEFAULT_RESET_TEXT' ,'Reset');
define('DEFAULT_BUTTON_TEXT','Send request');
define('CHECKBOX_SIZE','15px');
define('RADIOBUTTON_SIZE','15px');
define('SELECT_BUTTON_TRIANGLE_PADDING',1.5);
define('BROKEN_IMAGE_DEFAULT_SIZE_PX',24);
define('BROKEN_IMAGE_ALT_SIZE_PT',10);
define('BASE_FONT_SIZE_PT',12);
define('DEFAULT_TEXT_SIZE',20);
define('EM_KOEFF',1);
// Note that Firefox calculated ex for each font separately, while
// IE uses fixed value of 'ex' unit. We behave like IE here.
define('EX_KOEFF',0.50);
define('DEFAULT_CHAR_WIDTH', 600);
define('WHITESPACE_FONT_SIZE_FRACTION', 0.25);
define('SIZE_SPACE_KOEFF',1.2);
define('INPUT_SIZE_EM_KOEFF',0.48);
define('INPUT_SIZE_BASE_EM',2.2);
define('SELECT_SPACE_PADDING', 5);
define('LEGEND_HORIZONTAL_OFFSET','5pt');
define('BULLET_SIZE_KOEFF',0.15);
define('HEIGHT_KOEFF',0.7);
define('MAX_FRAME_NESTING_LEVEL',4);
define('MAX_JUSTIFY_FRACTION',0.33);
define('HILIGHT_COLOR_ALPHA',0.6);
define('MAX_REDIRECTS',5);
// Maximal length of line inside the stream data
// (we need to limit this, as most postscript interpreters will complain
// on long strings)
//
// Note it is measured in BYTES! Each byte will be represented by TWO characters
// in the hexadecimal form
//
define("MAX_LINE_LENGTH", 100);
define('MAX_IMAGE_ROW_LEN',16);
define('MAX_TRANSPARENT_IMAGE_ROW_LEN',16);
define('CACHE_DIR', HTML2PS_DIR.'cache/');
define('OUTPUT_FILE_DIRECTORY', PATH_OUTPUT_FILE_DIRECTORY);
define('FPDF_PATH', HTML2PS_DIR.'fpdf/');
// Note that WRITER_TEMPDIR !REQUIRES! slash (or backslash) on the end (unless you want to get
// some files like tempPS_jvckxlvjl in your working directory).
define('WRITER_TEMPDIR', HTML2PS_DIR.'temp/');
define('WRITER_FILE_PREFIX','PS_');
// number of retries to generate unique filename in case we have had troubles with
// tempnam function
define('WRITER_RETRIES',10);
define('WRITER_CANNOT_CREATE_FILE',"Cannot create unique temporary filename, sorry");
define('HTML2PS_CONNECTION_TIMEOUT', 10);
// directory to restrict 'file://' access to
// empty string for no restrictions
define('FILE_PROTOCOL_RESTRICT', HTML2PS_DIR);
define('FOOTNOTE_LINE_PERCENT', 30);
define('FOOTNOTE_LINE_TOP_GAP', 1); // Content points
define('FOOTNOTE_LINE_BOTTOM_GAP', 3); // Content points
define('FOOTNOTE_MARKER_MARGIN', 1); // Content points
define('FOOTNOTE_GAP', 2); // Space between footnotes
if (!defined('DEBUG_MODE')) {
// define('DEBUG_MODE',1);
};
define('HTML2PS_VERSION_MAJOR', 2);
define('HTML2PS_VERSION_MINOR', 0);
define('HTML2PS_SUBVERSON', 16);
define('MAX_UNPENALIZED_FREE_FRACTION', 0.25);
if (!defined('MAX_FREE_FRACTION')) {
define('MAX_FREE_FRACTION', 0.5);
};
define('MAX_PAGE_BREAK_HEIGHT_PENALTY', 10000);
define('MAX_PAGE_BREAK_PENALTY', 1000000);
define('FORCED_PAGE_BREAK_BONUS', -1000000);
define('PAGE_BREAK_INSIDE_AVOID_PENALTY', 300);
define('PAGE_BREAK_AFTER_AVOID_PENALTY', 5100);
define('PAGE_BREAK_BEFORE_AVOID_PENALTY', 1100);
define('PAGE_BREAK_ORPHANS_PENALTY', 1000);
define('PAGE_BREAK_WIDOWS_PENALTY', 1000);
define('PAGE_BREAK_LINE_PENALTY', 0);
define('PAGE_BREAK_BORDER_PENALTY', 150);
define('OVERLINE_POSITION', 1);
define('UNDERLINE_POSITION', 0.1);
define('LINE_THROUGH_POSITION', 0.4);
?>

View File

@@ -1,170 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/config.parse.php,v 1.6 2007/01/03 19:39:29 Konstantin Exp $
require_once(HTML2PS_DIR.'font.resolver.class.php');
require_once(HTML2PS_DIR.'treebuilder.class.php');
require_once(HTML2PS_DIR.'media.layout.inc.php');
// Get list of media types being used by script;
// It should be a list of two types:
// 1. Current CSS media type chose by user (defaults to 'screen')
// 2. 'all' media type
//
function config_get_allowed_media() {
return array($GLOBALS['g_config']['cssmedia'], 'all');
}
function parse_encoding_override_node_config_file($root, &$resolver) {
$child = $root->first_child();
do {
if ($child->node_type() == XML_ELEMENT_NODE) {
switch ($child->tagname()) {
case "normal":
$names = explode(',',$root->get_attribute('name'));
foreach ($names as $name) {
$resolver->add_normal_encoding_override($name,
$child->get_attribute('normal'),
$child->get_attribute('italic'),
$child->get_attribute('oblique'));
};
break;
case "bold":
$names = explode(',',$root->get_attribute('name'));
foreach ($names as $name) {
$resolver->add_bold_encoding_override($name,
$child->get_attribute('normal'),
$child->get_attribute('italic'),
$child->get_attribute('oblique'));
};
break;
};
};
} while ($child = $child->next_sibling());
}
function parse_metrics_node_config_file($root, &$resolver) {
$resolver->add_afm_mapping($root->get_attribute('typeface'),
$root->get_attribute('file'));
}
function parse_ttf_node_config_file($root, &$resolver) {
$resolver->add_ttf_mapping($root->get_attribute('typeface'),
$root->get_attribute('file'),
(bool)$root->get_attribute('embed'));
}
function parse_family_encoding_override_node_config_file($family, $root, &$resolver) {
$child = $root->first_child();
do {
if ($child->node_type() == XML_ELEMENT_NODE) {
switch ($child->tagname()) {
case "normal":
$names = explode(",",$root->get_attribute('name'));
foreach ($names as $name) {
$resolver->add_family_normal_encoding_override($family,
$name,
$child->get_attribute('normal'),
$child->get_attribute('italic'),
$child->get_attribute('oblique'));
};
break;
case "bold":
$names = explode(",",$root->get_attribute('name'));
foreach ($names as $name) {
$resolver->add_family_bold_encoding_override($family,
$name,
$child->get_attribute('normal'),
$child->get_attribute('italic'),
$child->get_attribute('oblique'));
};
break;
};
};
} while ($child = $child->next_sibling());
}
function parse_fonts_family_node_config_file($root, &$resolver) {
// Note: font family names are always converted to lower case to be non-case-sensitive
$child = $root->first_child();
do {
if ($child->node_type() == XML_ELEMENT_NODE) {
$font_family_name = strtolower($root->get_attribute('name'));
switch ($child->tagname()) {
case "normal":
$resolver->add_normal_family($font_family_name,
$child->get_attribute('normal'),
$child->get_attribute('italic'),
$child->get_attribute('oblique'));
break;
case "bold":
$resolver->add_bold_family($font_family_name,
$child->get_attribute('normal'),
$child->get_attribute('italic'),
$child->get_attribute('oblique'));
break;
case "encoding-override":
parse_family_encoding_override_node_config_file($font_family_name, $child, $resolver);
break;
};
};
} while ($child = $child->next_sibling());
}
function parse_fonts_node_config_file($root, &$resolver) {
$child = $root->first_child();
do {
if ($child->node_type() == XML_ELEMENT_NODE) {
switch ($child->tagname()) {
case "alias":
$resolver->add_alias($child->get_attribute('alias'), $child->get_attribute('family'));
break;
case "family":
parse_fonts_family_node_config_file($child, $resolver);
break;
case "encoding-override":
parse_encoding_override_node_config_file($child, $resolver);
break;
case "ttf":
parse_ttf_node_config_file($child, $resolver);
break;
case "metrics":
parse_metrics_node_config_file($child, $resolver);
break;
};
};
} while ($child = $child->next_sibling());
}
function parse_config_file($filename) {
// Save old magic_quotes_runtime value and disable it
$mq_runtime = get_magic_quotes_runtime();
set_magic_quotes_runtime(0);
$doc = TreeBuilder::build(file_get_contents($filename));
$root=$doc->document_element();
$child = $root->first_child();
do {
if ($child->node_type() == XML_ELEMENT_NODE) {
switch ($child->tagname()) {
case "fonts":
global $g_font_resolver;
parse_fonts_node_config_file($child, $g_font_resolver);
break;
case "fonts-pdf":
global $g_font_resolver_pdf;
parse_fonts_node_config_file($child, $g_font_resolver_pdf);
break;
case "media":
add_predefined_media($child->get_attribute('name'),
(float)$child->get_attribute('height'),
(float)$child->get_attribute('width'));
break;
};
};
} while ($child = $child->next_sibling());
// Restore old magic_quotes_runtime values
set_magic_quotes_runtime($mq_runtime);
}
?>

View File

@@ -1,27 +0,0 @@
<?php
class ContentType {
var $default_extension;
var $mime_type;
function ContentType($extension, $mime) {
$this->default_extension = $extension;
$this->mime_type = $mime;
}
function png() {
return new ContentType('png', 'image/png');
}
function gz() {
return new ContentType('gz', 'application/gzip');
}
function pdf() {
return new ContentType('pdf', 'application/pdf');
}
function ps() {
return new ContentType('ps', 'application/postscript');
}
}
?>

View File

@@ -1,58 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/converter.class.php,v 1.6 2006/06/25 13:55:35 Konstantin Exp $
class Converter {
function create() {
if (function_exists('iconv')) {
return new IconvConverter;
} else {
return new PurePHPConverter;
}
}
}
class IconvConverter {
function to_utf8($string, $encoding) {
return iconv(strtoupper($encoding), "UTF-8", $string);
}
}
class PurePHPConverter {
function apply_aliases($encoding) {
global $g_encoding_aliases;
if (isset($g_encoding_aliases[$encoding])) {
return $g_encoding_aliases[$encoding];
}
return $encoding;
}
function to_utf8($html, $encoding) {
global $g_utf8_converters;
$encoding = $this->apply_aliases($encoding);
if ($encoding === 'iso-8859-1') {
return utf8_encode($html);
} elseif ($encoding === 'utf-8') {
return $html;
} elseif(isset($g_utf8_converters[$encoding])) {
return $this->something_to_utf8($html, $g_utf8_converters[$encoding][0]);
} else {
die("Unsupported encoding detected: '$encoding'");
};
}
function something_to_utf8($html, &$mapping) {
for ($i=0; $i < strlen($html); $i++) {
$replacement = code_to_utf8($mapping[$html{$i}]);
if ($replacement != $html{$i}) {
$html = substr_replace($html, $replacement, $i, 1);
$i += strlen($replacement) - 1;
};
};
return $html;
}
}
?>

View File

@@ -1,35 +0,0 @@
<?php
define('BACKGROUND_ATTACHMENT_SCROLL', 1);
define('BACKGROUND_ATTACHMENT_FIXED', 2);
class CSSBackgroundAttachment extends CSSSubFieldProperty {
function getPropertyCode() {
return CSS_BACKGROUND_ATTACHMENT;
}
function getPropertyName() {
return 'background-attachment';
}
function default_value() {
return BACKGROUND_ATTACHMENT_SCROLL;
}
function &parse($value_string) {
if ($value_string === 'inherit') {
return CSS_PROPERTY_INHERIT;
};
if (preg_match('/\bscroll\b/', $value_string)) {
$value = BACKGROUND_ATTACHMENT_SCROLL;
} elseif (preg_match('/\bfixed\b/', $value_string)) {
$value = BACKGROUND_ATTACHMENT_FIXED;
} else {
$value = BACKGROUND_ATTACHMENT_SCROLL;
};
return $value;
}
}
?>

View File

@@ -1,62 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/css.background.color.inc.php,v 1.16 2007/01/24 18:55:50 Konstantin Exp $
// 'background-color' and color part of 'background' CSS properies handler
class CSSBackgroundColor extends CSSSubFieldProperty {
function getPropertyCode() {
return CSS_BACKGROUND_COLOR;
}
function getPropertyName() {
return 'background-color';
}
function default_value() {
// Transparent color
return new Color(array(0,0,0), true);
}
// Note: we cannot use parse_color_declaration here directly, as at won't process composite 'background' values
// containing, say, both background image url and background color; on the other side,
// parse_color_declaration slow down if we'll put this composite-value processing there
function parse($value) {
// We should not split terms at whitespaces immediately preceeded by ( or , symbols, as
// it would break "rgb( xxx, yyy, zzz)" notation
//
// As whitespace could be preceeded by another whitespace, we should prevent breaking
// value in the middle of long whitespace too
$terms = preg_split("/(?<![,(\s])\s+/ ",$value);
// Note that color declaration always will contain only one word;
// thus, we can split out value into words and try to parse each one as color
// if parse_color_declaration returns transparent value, it is possible not
// a color part of background declaration
foreach ($terms as $term) {
if ($term === 'inherit') {
return CSS_PROPERTY_INHERIT;
}
$color =& parse_color_declaration($term);
if (!$color->isTransparent()) {
return $color;
}
}
return CSSBackgroundColor::default_value();
}
function get_visible_background_color() {
$owner =& $this->owner();
for ($i=0, $size = count($owner->_stack); $i<$size; $i++) {
if ($owner->_stack[$i][0]->color[0] >= 0) {
return $owner->_stack[$i][0]->color;
};
};
return array(255,255,255);
}
}
?>

View File

@@ -1,41 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/css.background.image.inc.php,v 1.16 2006/07/09 09:07:44 Konstantin Exp $
class CSSBackgroundImage extends CSSSubFieldProperty {
function getPropertyCode() {
return CSS_BACKGROUND_IMAGE;
}
function getPropertyName() {
return 'background-image';
}
function default_value() {
return new BackgroundImage(null, null);
}
function parse($value, &$pipeline) {
global $g_config;
if (!$g_config['renderimages']) {
return CSSBackgroundImage::default_value();
};
if ($value === 'inherit') {
return CSS_PROPERTY_INHERIT;
}
// 'url' value
if (preg_match("/url\((.*[^\\\\]?)\)/is",$value,$matches)) {
$url = $matches[1];
$full_url = $pipeline->guess_url(css_remove_value_quotes($url));
return new BackgroundImage($full_url,
Image::get($full_url, $pipeline));
}
// 'none' and unrecognzed values
return CSSBackgroundImage::default_value();
}
}
?>

View File

@@ -1,64 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/css.background.inc.php,v 1.23 2007/03/15 18:37:30 Konstantin Exp $
require_once(HTML2PS_DIR.'value.background.php');
class CSSBackground extends CSSPropertyHandler {
var $default_value;
function getPropertyCode() {
return CSS_BACKGROUND;
}
function getPropertyName() {
return 'background';
}
function CSSBackground() {
$this->default_value = new Background(CSSBackgroundColor::default_value(),
CSSBackgroundImage::default_value(),
CSSBackgroundRepeat::default_value(),
CSSBackgroundPosition::default_value(),
CSSBackgroundAttachment::default_value());
$this->CSSPropertyHandler(true, false);
}
function inherit($state, &$new_state) {
// Determine parent 'display' value
$parent_display = $state[CSS_DISPLAY];
// If parent is a table row, inherit the background settings
$this->replace_array(($parent_display == 'table-row') ? $state[CSS_BACKGROUND] : $this->default_value(),
$new_state);
}
function default_value() {
return $this->default_value->copy();
}
function parse($value, &$pipeline) {
if ($value === 'inherit') {
return CSS_PROPERTY_INHERIT;
}
$background = new Background(CSSBackgroundColor::parse($value),
CSSBackgroundImage::parse($value, $pipeline),
CSSBackgroundRepeat::parse($value),
CSSBackgroundPosition::parse($value),
CSSBackgroundAttachment::parse($value));
return $background;
}
}
$bg = new CSSBackground;
CSS::register_css_property($bg);
CSS::register_css_property(new CSSBackgroundColor($bg, '_color'));
CSS::register_css_property(new CSSBackgroundImage($bg, '_image'));
CSS::register_css_property(new CSSBackgroundRepeat($bg, '_repeat'));
CSS::register_css_property(new CSSBackgroundPosition($bg, '_position'));
CSS::register_css_property(new CSSBackgroundAttachment($bg, '_attachment'));
?>

View File

@@ -1,108 +0,0 @@
<?php
// The background-position value is an array containing two array for X and Y position correspondingly
// each coordinate-position array, in its turn containes two values:
// first, the numeric value of percentage or units
// second, flag indication that this value is a percentage (true) or plain unit value (false)
define('LENGTH_REGEXP',"(?:-?\d*\.?\d+(?:em|ex|px|in|cm|mm|pt|pc)\b|-?\d+(?:em|ex|px|in|cm|mm|pt|pc)\b)");
define('PERCENTAGE_REGEXP',"\b\d+%");
define('TEXT_REGEXP',"\b(?:top|bottom|left|right|center)\b");
define('BG_POSITION_SUBVALUE_TYPE_HORZ',1);
define('BG_POSITION_SUBVALUE_TYPE_VERT',2);
class CSSBackgroundPosition extends CSSSubFieldProperty {
function getPropertyCode() {
return CSS_BACKGROUND_POSITION;
}
function getPropertyName() {
return 'background-position';
}
function default_value() {
return new BackgroundPosition(0,true,
0,true);
}
function build_subvalue($value) {
if ($value === "left" ||
$value === "top") {
return array(0, true);
};
if ($value === "right" ||
$value === "bottom") {
return array(100, true);
};
if ($value === "center") {
return array(50, true);
};
if (substr($value, strlen($value)-1,1) === "%") {
return array((int)$value, true);
} else {
return array($value, false);
};
}
function build_value($x, $y) {
return array(CSSBackgroundPosition::build_subvalue($x),
CSSBackgroundPosition::build_subvalue($y));
}
function detect_type($value) {
if ($value === "left" || $value === "right") { return BG_POSITION_SUBVALUE_TYPE_HORZ; };
if ($value === "top" || $value === "bottom") { return BG_POSITION_SUBVALUE_TYPE_VERT; };
return null;
}
// See CSS 2.1 'background-position' for description of possible values
//
function parse_in($value) {
if (preg_match("/(".LENGTH_REGEXP."|".PERCENTAGE_REGEXP."|".TEXT_REGEXP."|\b0\b)\s+(".LENGTH_REGEXP."|".PERCENTAGE_REGEXP."|".TEXT_REGEXP."|\b0\b)/", $value, $matches)) {
$x = $matches[1];
$y = $matches[2];
$type_x = CSSBackgroundPosition::detect_type($x);
$type_y = CSSBackgroundPosition::detect_type($y);
if (is_null($type_x) && is_null($type_y)) {
return CSSBackgroundPosition::build_value($x,$y);
};
if ($type_x == BG_POSITION_SUBVALUE_TYPE_HORZ ||
$type_y == BG_POSITION_SUBVALUE_TYPE_VERT) {
return CSSBackgroundPosition::build_value($x,$y);
};
return CSSBackgroundPosition::build_value($y,$x);
};
// These values should be processed separately at lastt
if (preg_match("/\b(top)\b/",$value)) { return array(array(50, true), array(0, true)); };
if (preg_match("/\b(center)\b/",$value)) { return array(array(50, true), array(50, true)); };
if (preg_match("/\b(bottom)\b/",$value)) { return array(array(50, true), array(100, true)); };
if (preg_match("/\b(left)\b/",$value)) { return array(array(0, true), array(50, true)); };
if (preg_match("/\b(right)\b/",$value)) { return array(array(100, true), array(50, true)); };
if (preg_match("/".LENGTH_REGEXP."|".PERCENTAGE_REGEXP."/", $value, $matches)) {
$x = $matches[0];
return CSSBackgroundPosition::build_value($x,"50%");
};
return null;
}
function parse($value) {
if ($value === 'inherit') {
return CSS_PROPERTY_INHERIT;
};
$value = CSSBackgroundPosition::parse_in($value);
return new BackgroundPosition($value[0][0], $value[0][1],
$value[1][0], $value[1][1]);
}
}
?>

View File

@@ -1,43 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/css.background.repeat.inc.php,v 1.8 2006/07/09 09:07:44 Konstantin Exp $
define('BR_REPEAT',0);
define('BR_REPEAT_X',1);
define('BR_REPEAT_Y',2);
define('BR_NO_REPEAT',3);
class CSSBackgroundRepeat extends CSSSubFieldProperty {
function getPropertyCode() {
return CSS_BACKGROUND_REPEAT;
}
function getPropertyName() {
return 'background-repeat';
}
function default_value() { return BR_REPEAT; }
function parse($value) {
if ($value === 'inherit') {
return CSS_PROPERTY_INHERIT;
}
// Note that we cannot just compare $value with these strings for equality,
// as 'parse' can be called with composite 'background' value as a parameter,
// say, 'black url(picture.gif) repeat', instead of just using 'repeat'
// Also, note that
// 1) 'repeat-x' value will match 'repeat' term
// 2) background-image 'url' values may contain these values as substrings
// to avoid these problems, we'll add spaced to the beginning and to the end of value,
// and will search for space-padded values, instead of raw substrings
$value = " ".$value." ";
if (strpos($value, ' repeat-x ') !== false) { return BR_REPEAT_X; };
if (strpos($value, ' repeat-y ') !== false) { return BR_REPEAT_Y; };
if (strpos($value, ' no-repeat ') !== false) { return BR_NO_REPEAT; };
if (strpos($value, ' repeat ') !== false) { return BR_REPEAT; };
return CSSBackgroundRepeat::default_value();
}
}
?>

View File

@@ -1,35 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/css.border.bottom.color.inc.php,v 1.2 2006/11/16 03:32:56 Konstantin Exp $
class CSSBorderBottomColor extends CSSSubProperty {
function CSSBorderBottomColor(&$owner) {
$this->CSSSubProperty($owner);
}
function setValue(&$owner_value, &$value) {
$owner_value->bottom->setColor($value);
}
function getValue(&$owner_value) {
$value = $owner_value->bottom->color->copy();
return $value;
}
function getPropertyCode() {
return CSS_BORDER_BOTTOM_COLOR;
}
function getPropertyName() {
return 'border-bottom-color';
}
function parse($value) {
if ($value == 'inherit') {
return CSS_PROPERTY_INHERIT;
}
return parse_color_declaration($value);
}
}
?>

View File

@@ -1,23 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/css.border.bottom.inc.php,v 1.1 2006/09/07 18:38:13 Konstantin Exp $
class CSSBorderBottom extends CSSSubFieldProperty {
function getPropertyCode() {
return CSS_BORDER_BOTTOM;
}
function getPropertyName() {
return 'border-bottom';
}
function parse($value) {
if ($value == 'inherit') {
return CSS_PROPERTY_INHERIT;
};
$border = CSSBorder::parse($value);
return $border->bottom;
}
}
?>

View File

@@ -1,34 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/css.border.bottom.style.inc.php,v 1.1 2006/09/07 18:38:13 Konstantin Exp $
class CSSBorderBottomStyle extends CSSSubProperty {
function CSSBorderBottomStyle(&$owner) {
$this->CSSSubProperty($owner);
}
function setValue(&$owner_value, &$value) {
$owner_value->bottom->style = $value;
}
function getValue(&$owner_value) {
return $owner_value->bottom->style;
}
function getPropertyCode() {
return CSS_BORDER_BOTTOM_STYLE;
}
function getPropertyName() {
return 'border-bottom-style';
}
function parse($value) {
if ($value == 'inherit') {
return CSS_PROPERTY_INHERIT;
}
return CSSBorderStyle::parse_style($value);
}
}
?>

View File

@@ -1,40 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/css.border.bottom.width.inc.php,v 1.2 2007/02/04 17:08:18 Konstantin Exp $
class CSSBorderBottomWidth extends CSSSubProperty {
function CSSBorderBottomWidth(&$owner) {
$this->CSSSubProperty($owner);
}
function setValue(&$owner_value, &$value) {
if ($value != CSS_PROPERTY_INHERIT) {
$owner_value->bottom->width = $value->copy();
} else {
$owner_value->bottom->width = $value;
};
}
function getValue(&$owner_value) {
return $owner_value->bottom->width;
}
function getPropertyCode() {
return CSS_BORDER_BOTTOM_WIDTH;
}
function getPropertyName() {
return 'border-bottom-width';
}
function parse($value) {
if ($value == 'inherit') {
return CSS_PROPERTY_INHERIT;
}
$width_handler = CSS::get_handler(CSS_BORDER_WIDTH);
$width = $width_handler->parse_value($value);
return $width;
}
}
?>

View File

@@ -1,31 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/css.border.collapse.inc.php,v 1.7 2006/07/09 09:07:44 Konstantin Exp $
define('BORDER_COLLAPSE', 1);
define('BORDER_SEPARATE', 2);
class CSSBorderCollapse extends CSSPropertyStringSet {
function CSSBorderCollapse() {
$this->CSSPropertyStringSet(true,
true,
array('inherit' => CSS_PROPERTY_INHERIT,
'collapse' => BORDER_COLLAPSE,
'separate' => BORDER_SEPARATE));
}
function default_value() {
return BORDER_SEPARATE;
}
function getPropertyCode() {
return CSS_BORDER_COLLAPSE;
}
function getPropertyName() {
return 'border-collapse';
}
}
CSS::register_css_property(new CSSBorderCollapse);
?>

View File

@@ -1,92 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/css.border.color.inc.php,v 1.3 2006/11/11 13:43:52 Konstantin Exp $
require_once(HTML2PS_DIR.'value.border.color.class.php');
class CSSBorderColor extends CSSSubProperty {
var $_defaultValue;
function CSSBorderColor(&$owner) {
$this->CSSSubProperty($owner);
$this->_defaultValue = new BorderColor(new Color(array(0,0,0), true),
new Color(array(0,0,0), true),
new Color(array(0,0,0), true),
new Color(array(0,0,0), true));
}
function setValue(&$owner_value, &$value) {
if ($value != CSS_PROPERTY_INHERIT) {
$owner_value->top->setColor($value->top);
$owner_value->right->setColor($value->right);
$owner_value->bottom->setColor($value->bottom);
$owner_value->left->setColor($value->left);
} else {
$owner_value->top->setColor(CSS_PROPERTY_INHERIT);
$owner_value->right->setColor(CSS_PROPERTY_INHERIT);
$owner_value->bottom->setColor(CSS_PROPERTY_INHERIT);
$owner_value->left->setColor(CSS_PROPERTY_INHERIT);
};
}
function getValue(&$owner_value) {
return new BorderColor($owner_value->top->color,
$owner_value->right->color,
$owner_value->bottom->color,
$owner_value->left->color);
}
function getPropertyCode() {
return CSS_BORDER_COLOR;
}
function getPropertyName() {
return 'border-color';
}
function default_value() {
return $this->_defaultValue;
}
function parse_in($value) {
$values = preg_split("/(?<![,(\s])\s+/ ",$value);
switch (count($values)) {
case 1:
$v1 = parse_color_declaration($values[0]);
return array($v1, $v1, $v1, $v1);
case 2:
$v1 = parse_color_declaration($values[0]);
$v2 = parse_color_declaration($values[1]);
return array($v1, $v2, $v1, $v2);
case 3:
$v1 = parse_color_declaration($values[0]);
$v2 = parse_color_declaration($values[1]);
$v3 = parse_color_declaration($values[2]);
return array($v1, $v2, $v3, $v2);
case 4:
$v1 = parse_color_declaration($values[0]);
$v2 = parse_color_declaration($values[1]);
$v3 = parse_color_declaration($values[2]);
$v4 = parse_color_declaration($values[3]);
return array($v1, $v2, $v3, $v4);
default:
return $this->default_value();
};
}
function parse($value) {
if ($value == 'inherit') {
return CSS_PROPERTY_INHERIT;
}
$colors = $this->parse_in($value);
return new BorderColor($colors[0],
$colors[1],
$colors[2],
$colors[3]);
}
}
?>

View File

@@ -1,151 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/css.border.inc.php,v 1.25 2006/11/11 13:43:52 Konstantin Exp $
require_once(HTML2PS_DIR.'css.border.color.inc.php');
require_once(HTML2PS_DIR.'css.border.style.inc.php');
require_once(HTML2PS_DIR.'css.border.width.inc.php');
require_once(HTML2PS_DIR.'css.border.top.inc.php');
require_once(HTML2PS_DIR.'css.border.right.inc.php');
require_once(HTML2PS_DIR.'css.border.left.inc.php');
require_once(HTML2PS_DIR.'css.border.bottom.inc.php');
require_once(HTML2PS_DIR.'css.border.top.color.inc.php');
require_once(HTML2PS_DIR.'css.border.right.color.inc.php');
require_once(HTML2PS_DIR.'css.border.left.color.inc.php');
require_once(HTML2PS_DIR.'css.border.bottom.color.inc.php');
require_once(HTML2PS_DIR.'css.border.top.style.inc.php');
require_once(HTML2PS_DIR.'css.border.right.style.inc.php');
require_once(HTML2PS_DIR.'css.border.left.style.inc.php');
require_once(HTML2PS_DIR.'css.border.bottom.style.inc.php');
require_once(HTML2PS_DIR.'css.border.top.width.inc.php');
require_once(HTML2PS_DIR.'css.border.right.width.inc.php');
require_once(HTML2PS_DIR.'css.border.left.width.inc.php');
require_once(HTML2PS_DIR.'css.border.bottom.width.inc.php');
require_once(HTML2PS_DIR.'value.generic.length.php');
require_once(HTML2PS_DIR.'value.border.class.php');
require_once(HTML2PS_DIR.'value.border.edge.class.php');
define('BORDER_VALUE_COLOR',1);
define('BORDER_VALUE_WIDTH',2);
define('BORDER_VALUE_STYLE',3);
class CSSBorder extends CSSPropertyHandler {
var $_defaultValue;
function CSSBorder() {
$this->CSSPropertyHandler(false, false);
$this->_defaultValue = BorderPDF::create(array('top' => array('width' => Value::fromString('2px'),
'color' => array(0,0,0),
'style' => BS_NONE),
'right' => array('width' => Value::fromString('2px'),
'color' => array(0,0,0),
'style' => BS_NONE),
'bottom' => array('width' => Value::fromString('2px'),
'color' => array(0,0,0),
'style' => BS_NONE),
'left' => array('width' => Value::fromString('2px'),
'color' => array(0,0,0),
'style' => BS_NONE)));
}
function default_value() {
return $this->_defaultValue;
}
function parse($value) {
if ($value == 'inherit') {
return CSS_PROPERTY_INHERIT;
};
// Remove spaces between color values in rgb() color definition; this will allow us to tread
// this declaration as a single value
$value = preg_replace("/\s*,\s*/",",",$value);
// Remove spaces before and after parens in rgb color definition
$value = preg_replace("/rgb\s*\(\s*(.*?)\s*\)/", 'rgb(\1)', $value);
$subvalues = explode(" ", $value);
$border = CSS::getDefaultValue(CSS_BORDER);
foreach ($subvalues as $subvalue) {
$subvalue = trim(strtolower($subvalue));
switch (CSSBorder::detect_border_value_type($subvalue)) {
case BORDER_VALUE_COLOR:
$color_handler = CSS::get_handler(CSS_BORDER_COLOR);
$border_color = $color_handler->parse($subvalue);
$color_handler->setValue($border, $border_color);
break;
case BORDER_VALUE_WIDTH:
$width_handler = CSS::get_handler(CSS_BORDER_WIDTH);
$border_width = $width_handler->parse($subvalue);
$width_handler->setValue($border, $border_width);
break;
case BORDER_VALUE_STYLE:
$style_handler = CSS::get_handler(CSS_BORDER_STYLE);
$border_style = $style_handler->parse($subvalue);
$style_handler->setValue($border, $border_style);
break;
};
};
return $border;
}
function getPropertyCode() {
return CSS_BORDER;
}
function getPropertyName() {
return 'border';
}
function detect_border_value_type($value) {
$color = _parse_color_declaration($value, $success);
if ($success) { return BORDER_VALUE_COLOR; };
// if (preg_match("/\b(transparent|black|silver|gray|white|maroon|red|purple|fuchsia|green|lime|olive|yellow|navy|blue|teal|aqua|rgb(.*?))\b/i",$value)) { return BORDER_VALUE_COLOR; };
// // We must detect hecadecimal values separately, as #-sign will not match the \b metacharacter at the beginning of previous regexp
// if (preg_match("/#([[:xdigit:]]{3}|[[:xdigit:]]{6})\b/i",$value)) { return BORDER_VALUE_COLOR; };
// Note that unit name is in general not required, so that we can meet rule like "border: 0" in CSS!
if (preg_match("/\b(thin|medium|thick|[+-]?\d+(.\d*)?(em|ex|px|in|cm|mm|pt|pc)?)\b/i",$value)) { return BORDER_VALUE_WIDTH; };
if (preg_match("/\b(none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset)\b/",$value)) { return BORDER_VALUE_STYLE; };
return;
}
}
$border = new CSSBorder();
CSS::register_css_property($border);
CSS::register_css_property(new CSSBorderColor($border));
CSS::register_css_property(new CSSBorderWidth($border));
CSS::register_css_property(new CSSBorderStyle($border));
CSS::register_css_property(new CSSBorderTop($border, 'top'));
CSS::register_css_property(new CSSBorderRight($border, 'right'));
CSS::register_css_property(new CSSBorderBottom($border, 'bottom'));
CSS::register_css_property(new CSSBorderLeft($border, 'left'));
CSS::register_css_property(new CSSBorderLeftColor($border));
CSS::register_css_property(new CSSBorderTopColor($border));
CSS::register_css_property(new CSSBorderRightColor($border));
CSS::register_css_property(new CSSBorderBottomColor($border));
CSS::register_css_property(new CSSBorderLeftStyle($border));
CSS::register_css_property(new CSSBorderTopStyle($border));
CSS::register_css_property(new CSSBorderRightStyle($border));
CSS::register_css_property(new CSSBorderBottomStyle($border));
CSS::register_css_property(new CSSBorderLeftWidth($border));
CSS::register_css_property(new CSSBorderTopWidth($border));
CSS::register_css_property(new CSSBorderRightWidth($border));
CSS::register_css_property(new CSSBorderBottomWidth($border));
?>

View File

@@ -1,34 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/css.border.left.color.inc.php,v 1.1 2006/09/07 18:38:13 Konstantin Exp $
class CSSBorderLeftColor extends CSSSubProperty {
function CSSBorderLeftColor(&$owner) {
$this->CSSSubProperty($owner);
}
function setValue(&$owner_value, &$value) {
$owner_value->left->setColor($value);
}
function getValue(&$owner_value) {
return $owner_value->left->color->copy();
}
function getPropertyCode() {
return CSS_BORDER_LEFT_COLOR;
}
function getPropertyName() {
return 'border-left-color';
}
function parse($value) {
if ($value == 'inherit') {
return CSS_PROPERTY_INHERIT;
}
return parse_color_declaration($value);
}
}
?>

View File

@@ -1,23 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/css.border.left.inc.php,v 1.1 2006/09/07 18:38:13 Konstantin Exp $
class CSSBorderLeft extends CSSSubFieldProperty {
function getPropertyCode() {
return CSS_BORDER_LEFT;
}
function getPropertyName() {
return 'border-left';
}
function parse($value) {
if ($value == 'inherit') {
return CSS_PROPERTY_INHERIT;
};
$border = CSSBorder::parse($value);
return $border->left;
}
}
?>

View File

@@ -1,34 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/css.border.left.style.inc.php,v 1.1 2006/09/07 18:38:13 Konstantin Exp $
class CSSBorderLeftStyle extends CSSSubProperty {
function CSSBorderLeftStyle(&$owner) {
$this->CSSSubProperty($owner);
}
function setValue(&$owner_value, &$value) {
$owner_value->left->style = $value;
}
function getValue(&$owner_value) {
return $owner_value->left->style;
}
function getPropertyCode() {
return CSS_BORDER_LEFT_STYLE;
}
function getPropertyName() {
return 'border-left-style';
}
function parse($value) {
if ($value == 'inherit') {
return CSS_PROPERTY_INHERIT;
}
return CSSBorderStyle::parse_style($value);
}
}
?>

View File

@@ -1,40 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/css.border.left.width.inc.php,v 1.2 2007/02/04 17:08:18 Konstantin Exp $
class CSSBorderLeftWidth extends CSSSubProperty {
function CSSBorderLeftWidth(&$owner) {
$this->CSSSubProperty($owner);
}
function setValue(&$owner_value, &$value) {
if ($value != CSS_PROPERTY_INHERIT) {
$owner_value->left->width = $value->copy();
} else {
$owner_value->left->width = $value;
};
}
function getValue(&$owner_value) {
return $owner_value->left->width;
}
function getPropertyCode() {
return CSS_BORDER_LEFT_WIDTH;
}
function getPropertyName() {
return 'border-left-width';
}
function parse($value) {
if ($value == 'inherit') {
return CSS_PROPERTY_INHERIT;
}
$width_handler = CSS::get_handler(CSS_BORDER_WIDTH);
$width = $width_handler->parse_value($value);
return $width;
}
}
?>

View File

@@ -1,34 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/css.border.right.color.inc.php,v 1.1 2006/09/07 18:38:13 Konstantin Exp $
class CSSBorderRightColor extends CSSSubProperty {
function CSSBorderRightColor(&$owner) {
$this->CSSSubProperty($owner);
}
function setValue(&$owner_value, &$value) {
$owner_value->right->setColor($value);
}
function getValue(&$owner_value) {
return $owner_value->right->color->copy();
}
function getPropertyCode() {
return CSS_BORDER_RIGHT_COLOR;
}
function getPropertyName() {
return 'border-right-color';
}
function parse($value) {
if ($value == 'inherit') {
return CSS_PROPERTY_INHERIT;
}
return parse_color_declaration($value);
}
}
?>

View File

@@ -1,23 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/css.border.right.inc.php,v 1.1 2006/09/07 18:38:13 Konstantin Exp $
class CSSBorderRight extends CSSSubFieldProperty {
function getPropertyCode() {
return CSS_BORDER_RIGHT;
}
function getPropertyName() {
return 'border-right';
}
function parse($value) {
if ($value == 'inherit') {
return CSS_PROPERTY_INHERIT;
};
$border = CSSBorder::parse($value);
return $border->right;
}
}
?>

View File

@@ -1,34 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/css.border.right.style.inc.php,v 1.1 2006/09/07 18:38:13 Konstantin Exp $
class CSSBorderRightStyle extends CSSSubProperty {
function CSSBorderRightStyle(&$owner) {
$this->CSSSubProperty($owner);
}
function setValue(&$owner_value, &$value) {
$owner_value->right->style = $value;
}
function getValue(&$owner_value) {
return $owner_value->right->style;
}
function getPropertyCode() {
return CSS_BORDER_RIGHT_STYLE;
}
function getPropertyName() {
return 'border-right-style';
}
function parse($value) {
if ($value == 'inherit') {
return CSS_PROPERTY_INHERIT;
}
return CSSBorderStyle::parse_style($value);
}
}
?>

View File

@@ -1,40 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/css.border.right.width.inc.php,v 1.2 2007/02/04 17:08:18 Konstantin Exp $
class CSSBorderRightWidth extends CSSSubProperty {
function CSSBorderRightWidth(&$owner) {
$this->CSSSubProperty($owner);
}
function setValue(&$owner_value, &$value) {
if ($value != CSS_PROPERTY_INHERIT) {
$owner_value->right->width = $value->copy();
} else {
$owner_value->right->width = $value;
};
}
function getValue(&$owner_value) {
return $owner_value->right->width;
}
function getPropertyCode() {
return CSS_BORDER_RIGHT_WIDTH;
}
function getPropertyName() {
return 'border-right-width';
}
function parse($value) {
if ($value == 'inherit') {
return CSS_PROPERTY_INHERIT;
}
$width_handler = CSS::get_handler(CSS_BORDER_WIDTH);
$width = $width_handler->parse_value($value);
return $width;
}
}
?>

View File

@@ -1,115 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/css.border.style.inc.php,v 1.6 2006/11/11 13:43:52 Konstantin Exp $
require_once(HTML2PS_DIR.'value.border.style.class.php');
class CSSBorderStyle extends CSSSubProperty {
var $_defaultValue;
function CSSBorderStyle(&$owner) {
$this->CSSSubProperty($owner);
$this->_defaultValue = new BorderStyle(BS_NONE,
BS_NONE,
BS_NONE,
BS_NONE);
}
function setValue(&$owner_value, &$value) {
if ($value != CSS_PROPERTY_INHERIT) {
$owner_value->top->style = $value->top;
$owner_value->right->style = $value->right;
$owner_value->bottom->style = $value->bottom;
$owner_value->left->style = $value->left;
} else {
$owner_value->top->style = CSS_PROPERTY_INHERIT;
$owner_value->right->style = CSS_PROPERTY_INHERIT;
$owner_value->bottom->style = CSS_PROPERTY_INHERIT;
$owner_value->left->style = CSS_PROPERTY_INHERIT;
};
}
function getValue(&$owner_value) {
return new BorderStyle($owner_value->top->style,
$owner_value->right->style,
$owner_value->bottom->style,
$owner_value->left->style);
}
function getPropertyCode() {
return CSS_BORDER_STYLE;
}
function getPropertyName() {
return 'border-style';
}
function default_value() {
return $this->_defaultValue;
}
function parse_style($value) {
switch ($value) {
case "solid":
return BS_SOLID;
case "dashed":
return BS_DASHED;
case "dotted":
return BS_DOTTED;
case "double":
return BS_DOUBLE;
case "inset":
return BS_INSET;
case "outset":
return BS_OUTSET;
case "groove":
return BS_GROOVE;
case "ridge":
return BS_RIDGE;
default:
return BS_NONE;
};
}
function parse_in($value) {
$values = explode(" ",$value);
switch (count($values)) {
case 1:
$v1 = $this->parse_style($values[0]);
return array($v1, $v1, $v1, $v1);
case 2:
$v1 = $this->parse_style($values[0]);
$v2 = $this->parse_style($values[1]);
return array($v1, $v2, $v1, $v2);
case 3:
$v1 = $this->parse_style($values[0]);
$v2 = $this->parse_style($values[1]);
$v3 = $this->parse_style($values[2]);
return array($v1, $v2, $v3, $v2);
case 4:
$v1 = $this->parse_style($values[0]);
$v2 = $this->parse_style($values[1]);
$v3 = $this->parse_style($values[2]);
$v4 = $this->parse_style($values[3]);
return array($v1, $v2, $v3, $v4);
default:
return $this->default_value();
};
}
function parse($value) {
if ($value == 'inherit') {
return CSS_PROPERTY_INHERIT;
}
$values = $this->parse_in($value);
return new BorderStyle($values[0],
$values[1],
$values[2],
$values[3]);
}
}
?>

View File

@@ -1,34 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/css.border.top.color.inc.php,v 1.1 2006/09/07 18:38:13 Konstantin Exp $
class CSSBorderTopColor extends CSSSubProperty {
function CSSBorderTopColor(&$owner) {
$this->CSSSubProperty($owner);
}
function setValue(&$owner_value, &$value) {
$owner_value->top->setColor($value);
}
function getValue(&$owner_value) {
return $owner_value->top->color->copy();
}
function getPropertyCode() {
return CSS_BORDER_TOP_COLOR;
}
function getPropertyName() {
return 'border-top-color';
}
function parse($value) {
if ($value == 'inherit') {
return CSS_PROPERTY_INHERIT;
}
return parse_color_declaration($value);
}
}
?>

View File

@@ -1,23 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/css.border.top.inc.php,v 1.1 2006/09/07 18:38:13 Konstantin Exp $
class CSSBorderTop extends CSSSubFieldProperty {
function getPropertyCode() {
return CSS_BORDER_TOP;
}
function getPropertyName() {
return 'border-top';
}
function parse($value) {
if ($value == 'inherit') {
return CSS_PROPERTY_INHERIT;
};
$border = CSSBorder::parse($value);
return $border->left;
}
}
?>

View File

@@ -1,34 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/css.border.top.style.inc.php,v 1.1 2006/09/07 18:38:13 Konstantin Exp $
class CSSBorderTopStyle extends CSSSubProperty {
function CSSBorderTopStyle(&$owner) {
$this->CSSSubProperty($owner);
}
function setValue(&$owner_value, &$value) {
$owner_value->top->style = $value;
}
function getValue(&$owner_value) {
return $owner_value->top->style;
}
function getPropertyCode() {
return CSS_BORDER_TOP_STYLE;
}
function getPropertyName() {
return 'border-top-style';
}
function parse($value) {
if ($value == 'inherit') {
return CSS_PROPERTY_INHERIT;
}
return CSSBorderStyle::parse_style($value);
}
}
?>

View File

@@ -1,40 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/css.border.top.width.inc.php,v 1.2 2007/02/04 17:08:18 Konstantin Exp $
class CSSBorderTopWidth extends CSSSubProperty {
function CSSBorderTopWidth(&$owner) {
$this->CSSSubProperty($owner);
}
function setValue(&$owner_value, &$value) {
if ($value != CSS_PROPERTY_INHERIT) {
$owner_value->top->width = $value->copy();
} else {
$owner_value->top->width = $value;
};
}
function getValue(&$owner_value) {
return $owner_value->top->width;
}
function getPropertyCode() {
return CSS_BORDER_TOP_WIDTH;
}
function getPropertyName() {
return 'border-top-width';
}
function parse($value) {
if ($value == 'inherit') {
return CSS_PROPERTY_INHERIT;
}
$width_handler = CSS::get_handler(CSS_BORDER_WIDTH);
$width = $width_handler->parse_value($value);
return $width;
}
}
?>

View File

@@ -1,104 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/css.border.width.inc.php,v 1.4 2007/02/04 17:08:19 Konstantin Exp $
require_once(HTML2PS_DIR.'value.border.width.class.php');
class CSSBorderWidth extends CSSSubProperty {
var $_defaultValue;
function CSSBorderWidth(&$owner) {
$this->CSSSubProperty($owner);
$this->_defaultValue = new BorderWidth(Value::fromData(0, UNIT_PT),
Value::fromData(0, UNIT_PT),
Value::fromData(0, UNIT_PT),
Value::fromData(0, UNIT_PT));
}
function setValue(&$owner_value, &$value) {
if ($value != CSS_PROPERTY_INHERIT) {
$owner_value->top->width = $value->top;
$owner_value->right->width = $value->right;
$owner_value->bottom->width = $value->bottom;
$owner_value->left->width = $value->left;
} else {
$owner_value->top->width = CSS_PROPERTY_INHERIT;
$owner_value->right->width = CSS_PROPERTY_INHERIT;
$owner_value->bottom->width = CSS_PROPERTY_INHERIT;
$owner_value->left->width = CSS_PROPERTY_INHERIT;
};
}
function getValue(&$owner_value) {
return new BorderWidth($owner_value->top->width,
$owner_value->right->width,
$owner_value->bottom->width,
$owner_value->left->width);
}
function getPropertyCode() {
return CSS_BORDER_WIDTH;
}
function getPropertyName() {
return 'border-width';
}
function default_value() {
return $this->_defaultValue;
}
function parse_value($value) {
switch (strtolower($value)) {
case 'thin':
return Value::fromString('1px');
case 'medium':
return Value::fromString('3px');
case 'thick':
return Value::fromString('5px');
default:
return Value::fromString($value);
};
}
function parse_in($value) {
$values = explode(' ', $value);
switch (count($values)) {
case 1:
$v1 = $this->parse_value($values[0]);
return array($v1, $v1, $v1, $v1);
case 2:
$v1 = $this->parse_value($values[0]);
$v2 = $this->parse_value($values[1]);
return array($v1, $v2, $v1, $v2);
case 3:
$v1 = $this->parse_value($values[0]);
$v2 = $this->parse_value($values[1]);
$v3 = $this->parse_value($values[2]);
return array($v1, $v2, $v3, $v2);
case 4:
$v1 = $this->parse_value($values[0]);
$v2 = $this->parse_value($values[1]);
$v3 = $this->parse_value($values[2]);
$v4 = $this->parse_value($values[3]);
return array($v1, $v2, $v3, $v4);
default:
return $this->default_value();
};
}
function parse($value) {
if ($value == 'inherit') {
return CSS_PROPERTY_INHERIT;
}
$values = $this->parse_in($value);
return new BorderWidth($values[0],
$values[1],
$values[2],
$values[3]);
}
}
?>

View File

@@ -1,56 +0,0 @@
<?php
// $Header: /cvsroot/html2ps/css.bottom.inc.php,v 1.6 2006/11/11 13:43:52 Konstantin Exp $
require_once(HTML2PS_DIR.'value.bottom.php');
/**
* 'bottom'
* Value: <length> | <percentage> | auto | inherit
* Initial: auto
* Applies to: positioned elements
* Inherited: no
* Percentages: refer to height of containing block
* Media: visual
* Computed value: for 'position:relative', see section Relative
* Positioning. For 'position:static', 'auto'. Otherwise: if
* specified as a length, the corresponding absolute length; if
* specified as a percentage, the specified value; otherwise, 'auto'.
*
* Like 'top', but specifies how far a box's bottom margin edge is
* offset above the bottom of the box's containing block. For
* relatively positioned boxes, the offset is with respect to the
* bottom edge of the box itself. Note: For absolutely positioned
* elements whose containing block is based on a block-level element,
* this property is an offset from the padding edge of that element.
*/
class CSSBottom extends CSSPropertyHandler {
function CSSBottom() {
$this->CSSPropertyHandler(false, false);
$this->_autoValue = ValueBottom::fromString('auto');
}
function _getAutoValue() {
return $this->_autoValue->copy();
}
function default_value() {
return $this->_getAutoValue();
}
function getPropertyCode() {
return CSS_BOTTOM;
}
function getPropertyName() {
return 'bottom';
}
function parse($value) {
return ValueBottom::fromString($value);
}
}
CSS::register_css_property(new CSSBottom);
?>

Some files were not shown because too many files have changed in this diff Show More