本文整理汇总了PHP中Frame::get_node方法的典型用法代码示例。如果您正苦于以下问题:PHP Frame::get_node方法的具体用法?PHP Frame::get_node怎么用?PHP Frame::get_node使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Frame
的用法示例。
在下文中一共展示了Frame::get_node方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rtrim
static function translate_attributes(Frame $frame)
{
$node = $frame->get_node();
$tag = $node->tagName;
if (!isset(self::$__ATTRIBUTE_LOOKUP[$tag])) {
return;
}
$valid_attrs = self::$__ATTRIBUTE_LOOKUP[$tag];
$attrs = $node->attributes;
$style = rtrim($node->getAttribute(self::$_style_attr), "; ");
if ($style != "") {
$style .= ";";
}
foreach ($attrs as $attr => $attr_node) {
if (!isset($valid_attrs[$attr])) {
continue;
}
$value = $attr_node->value;
$target = $valid_attrs[$attr];
// Look up $value in $target, if $target is an array:
if (is_array($target)) {
if (isset($target[$value])) {
$style .= " " . self::_resolve_target($node, $target[$value], $value);
}
} else {
// otherwise use target directly
$style .= " " . self::_resolve_target($node, $target, $value);
}
}
if (!is_null($style)) {
$style = ltrim($style);
$node->setAttribute(self::$_style_attr, $style);
}
}
示例2: render
function render(Frame $frame)
{
$style = $frame->get_style();
list($x, $y, $w, $h) = $frame->get_border_box();
$this->_set_opacity($frame->get_opacity($style->opacity));
if ($frame->get_node()->nodeName === "body") {
$h = $frame->get_containing_block("h") - $style->length_in_pt(array($style->margin_top, $style->padding_top, $style->border_top_width, $style->border_bottom_width, $style->padding_bottom, $style->margin_bottom), $style->width);
}
// Draw our background, border and content
if (($bg = $style->background_color) !== "transparent") {
$this->_canvas->filled_rectangle($x, $y, $w, $h, $bg);
}
if (($url = $style->background_image) && $url !== "none") {
$this->_background_image($url, $x, $y, $w, $h, $style);
}
$this->_render_border($frame);
$this->_render_outline($frame);
if (DEBUG_LAYOUT && DEBUG_LAYOUT_BLOCKS) {
$this->_debug_layout($frame->get_border_box(), "red");
if (DEBUG_LAYOUT_PADDINGBOX) {
$this->_debug_layout($frame->get_padding_box(), "red", array(0.5, 0.5));
}
}
if (DEBUG_LAYOUT && DEBUG_LAYOUT_LINES && $frame->get_decorator()) {
foreach ($frame->get_decorator()->get_line_boxes() as $line) {
$frame->_debug_layout(array($line->x, $line->y, $line->w, $line->h), "orange");
}
}
}
示例3: dispose
/**
* "Destructor": forcibly free all references held by this frame
*
* @param bool $recursive if true, call dispose on all children
*/
function dispose($recursive = false)
{
if ($recursive) {
while ($child = $this->_first_child) {
$child->dispose(true);
}
}
// Remove this frame from the tree
if ($this->_prev_sibling) {
$this->_prev_sibling->_next_sibling = $this->_next_sibling;
}
if ($this->_next_sibling) {
$this->_next_sibling->_prev_sibling = $this->_prev_sibling;
}
if ($this->_parent && $this->_parent->_first_child === $this) {
$this->_parent->_first_child = $this->_next_sibling;
}
if ($this->_parent && $this->_parent->_last_child === $this) {
$this->_parent->_last_child = $this->_prev_sibling;
}
if ($this->_parent) {
$this->_parent->get_node()->removeChild($this->_node);
}
$this->_style->dispose();
unset($this->_style);
$this->_original_style->dispose();
unset($this->_original_style);
}
示例4: render
function render(Frame $frame)
{
if (!$this->_dompdf->get_option("enable_javascript")) {
return;
}
$this->insert($frame->get_node()->nodeValue);
}
示例5: render
function render(Frame $frame)
{
if (!DOMPDF_ENABLE_JAVASCRIPT) {
return;
}
$this->insert($frame->get_node()->nodeValue);
}
示例6: count
function add_frame_to_line(Frame $frame)
{
if (!$frame->is_in_flow()) {
return;
}
$style = $frame->get_style();
$frame->set_containing_line($this->_line_boxes[$this->_cl]);
if ($frame instanceof Inline_Frame_Decorator) {
if ($frame->get_node()->nodeName === "br") {
$this->maximize_line_height($style->length_in_pt($style->line_height), $frame);
$this->add_line(true);
}
return;
}
if ($this->get_current_line_box()->w == 0 && $frame->is_text_node() && !$frame->is_pre()) {
$frame->set_text(ltrim($frame->get_text()));
$frame->recalculate_width();
}
$w = $frame->get_margin_width();
if ($w == 0) {
return;
}
$line = $this->_line_boxes[$this->_cl];
if ($line->left + $line->w + $line->right + $w > $this->get_containing_block("w")) {
$this->add_line();
}
$frame->position();
$current_line = $this->_line_boxes[$this->_cl];
$current_line->add_frame($frame);
if ($frame->is_text_node()) {
$current_line->wc += count(preg_split("/\\s+/", trim($frame->get_text())));
}
$this->increase_line_width($w);
$this->maximize_line_height($frame->get_margin_height(), $frame);
}
开发者ID:EfncoPlugins,项目名称:web-portal-lite-client-portal-secure-file-sharing-private-messaging,代码行数:35,代码来源:block_frame_decorator.cls.php
示例7: list
/**
* Class constructor
*
* @param Frame $frame the bullet frame to decorate
* @param DOMPDF $dompdf the document's dompdf object
*/
function __construct(Frame $frame, DOMPDF $dompdf)
{
$style = $frame->get_style();
$url = $style->list_style_image;
$frame->get_node()->setAttribute("src", $url);
$this->_img = new Image_Frame_Decorator($frame, $dompdf);
parent::__construct($this->_img, $dompdf);
list($width, $height) = dompdf_getimagesize($this->_img->get_image_url());
// Resample the bullet image to be consistent with 'auto' sized images
// See also Image_Frame_Reflower::get_min_max_width
// Tested php ver: value measured in px, suffix "px" not in value: rtrim unnecessary.
$this->_width = (double) rtrim($width, "px") * 72 / DOMPDF_DPI;
$this->_height = (double) rtrim($height, "px") * 72 / DOMPDF_DPI;
//If an image is taller as the containing block/box, the box should be extended.
//Neighbour elements are overwriting the overlapping image areas.
//Todo: Where can the box size be extended?
//Code below has no effect.
//See block_frame_reflower _calculate_restricted_height
//See generated_frame_reflower, Dompdf:render() "list-item", "-dompdf-list-bullet"S.
//Leave for now
//if ($style->min_height < $this->_height ) {
// $style->min_height = $this->_height;
//}
//$style->height = "auto";
}
示例8:
function __construct(Frame $frame, DOMPDF $dompdf)
{
if ($frame->get_node()->nodeName !== "#text") {
throw new DOMPDF_Exception("Text_Decorator can only be applied to #text nodes.");
}
parent::__construct($frame, $dompdf);
$this->_text_spacing = null;
}
示例9: render
function render(Frame $frame) {
$style = $frame->get_style();
$node = $frame->get_node();
list($x, $y, $w, $h) = $frame->get_border_box();
$this->_set_opacity( $frame->get_opacity( $style->opacity ) );
if ( $node->nodeName === "body" ) {
$h = $frame->get_containing_block("h") - $style->length_in_pt(array(
$style->margin_top,
$style->border_top_width,
$style->border_bottom_width,
$style->margin_bottom),
$style->width);
}
// Handle anchors & links
if ( $node->nodeName === "a" && $href = $node->getAttribute("href") ) {
$this->_canvas->add_link($href, $x, $y, $w, $h);
}
// Draw our background, border and content
list($tl, $tr, $br, $bl) = $style->get_computed_border_radius($w, $h);
if ( $tl + $tr + $br + $bl > 0 ) {
$this->_canvas->clipping_roundrectangle( $x, $y, $w, $h, $tl, $tr, $br, $bl );
}
if ( ($bg = $style->background_color) !== "transparent" ) {
$this->_canvas->filled_rectangle( $x, $y, $w, $h, $bg );
}
if ( ($url = $style->background_image) && $url !== "none" ) {
$this->_background_image($url, $x, $y, $w, $h, $style);
}
if ( $tl + $tr + $br + $bl > 0 ) {
$this->_canvas->clipping_end();
}
$border_box = array($x, $y, $w, $h);
$this->_render_border($frame, $border_box);
$this->_render_outline($frame, $border_box);
if (DEBUG_LAYOUT && DEBUG_LAYOUT_BLOCKS) {
$this->_debug_layout($frame->get_border_box(), "red");
if (DEBUG_LAYOUT_PADDINGBOX) {
$this->_debug_layout($frame->get_padding_box(), "red", array(0.5, 0.5));
}
}
if (DEBUG_LAYOUT && DEBUG_LAYOUT_LINES && $frame->get_decorator()) {
foreach ($frame->get_decorator()->get_line_boxes() as $line) {
$frame->_debug_layout(array($line->x, $line->y, $line->w, $line->h), "orange");
}
}
}
示例10: list
function __construct(Frame $frame, DOMPDF $dompdf)
{
$style = $frame->get_style();
$url = $style->list_style_image;
$frame->get_node()->setAttribute("src", $url);
$this->_img = new Image_Frame_Decorator($frame, $dompdf);
parent::__construct($this->_img, $dompdf);
list($width, $height) = dompdf_getimagesize($this->_img->get_image_url());
$this->_width = (double) rtrim($width, "px") * 72 / DOMPDF_DPI;
$this->_height = (double) rtrim($height, "px") * 72 / DOMPDF_DPI;
}
开发者ID:EfncoPlugins,项目名称:web-portal-lite-client-portal-secure-file-sharing-private-messaging,代码行数:11,代码来源:list_bullet_image_frame_decorator.cls.php
示例11: list
/**
* Class constructor
*
* @param Frame $frame the bullet frame to decorate
* @param DOMPDF $dompdf the document's dompdf object
*/
function __construct(Frame $frame, DOMPDF $dompdf)
{
$url = $frame->get_style()->list_style_image;
$frame->get_node()->setAttribute("src", $url);
$this->_img = new Image_Frame_Decorator($frame, $dompdf);
parent::__construct($this->_img, $dompdf);
list($width, $height) = getimagesize($this->_img->get_image_url());
// Resample the bullet image to be consistent with 'auto' sized images
$this->_width = (double) rtrim($width, "px") * 72 / DOMPDF_DPI;
$this->_height = (double) rtrim($height, "px") * 72 / DOMPDF_DPI;
}
示例12: split
/**
* split this frame at $child.
*
* The current frame is cloned and $child and all children following
* $child are added to the clone. The clone is then passed to the
* current frame's parent->split() method.
*
* @param Frame $child
* @param boolean $force_pagebreak
*/
function split($child = null, $force_pagebreak = false)
{
if (is_null($child)) {
$this->get_parent()->split($this, $force_pagebreak);
return;
}
if ($child->get_parent() !== $this)
throw new DOMPDF_Exception("Unable to split: frame is not a child of this one.");
$node = $this->_frame->get_node();
// mark the frame as splitted (don't use the find_***_parent cache)
//$this->_splitted = true;
$split = $this->copy($node->cloneNode());
$split->reset();
$split->get_original_style()->text_indent = 0;
// The body's properties must be kept
if ($node->nodeName !== "body") {
// Style reset on the first and second parts
$style = $this->_frame->get_style();
$style->margin_bottom = 0;
$style->padding_bottom = 0;
$style->border_bottom = 0;
// second
$orig_style = $split->get_original_style();
$orig_style->text_indent = 0;
$orig_style->margin_top = 0;
$orig_style->padding_top = 0;
$orig_style->border_top = 0;
}
$this->get_parent()->insert_child_after($split, $this);
// Add $frame and all following siblings to the new split node
$iter = $child;
while ($iter) {
$frame = $iter;
$iter = $iter->get_next_sibling();
$frame->reset();
$split->append_child($frame);
}
$this->get_parent()->split($split, $force_pagebreak);
}
示例13: split
/**
* split this frame at $child.
*
* The current frame is cloned and $child and all children following
* $child are added to the clone. The clone is then passed to the
* current frame's parent->split() method.
*
* @param Frame $child
*/
function split($child = null)
{
if (is_null($child)) {
$this->get_parent()->split($this);
return;
}
if ($child->get_parent() !== $this) {
throw new DOMPDF_Exception("Unable to split: frame is not a child of this one.");
}
$split = $this->copy($this->_frame->get_node()->cloneNode());
$split->reset();
$this->get_parent()->insert_child_after($split, $this);
// Add $frame and all following siblings to the new split node
$iter = $child;
while ($iter) {
$frame = $iter;
$iter = $iter->get_next_sibling();
$frame->reset();
$split->append_child($frame);
}
$this->get_parent()->split($split);
}
示例14: _page_break_allowed
/**
* Determine if a page break is allowed before $frame
*
* @param Frame $frame the frame to check
* @return bool true if a break is allowed, false otherwise
*/
protected function _page_break_allowed(Frame $frame)
{
/**
*
* http://www.w3.org/TR/CSS21/page.html#allowed-page-breaks
* /*
* In the normal flow, page breaks can occur at the following places:
*
* 1. In the vertical margin between block boxes. When a page
* break occurs here, the used values of the relevant
* 'margin-top' and 'margin-bottom' properties are set to '0'.
* 2. Between line boxes inside a block box.
*
* These breaks are subject to the following rules:
*
* * Rule A: Breaking at (1) is allowed only if the
* 'page-break-after' and 'page-break-before' properties of
* all the elements generating boxes that meet at this margin
* allow it, which is when at least one of them has the value
* 'always', 'left', or 'right', or when all of them are
* 'auto'.
*
* * Rule B: However, if all of them are 'auto' and the
* nearest common ancestor of all the elements has a
* 'page-break-inside' value of 'avoid', then breaking here is
* not allowed.
*
* * Rule C: Breaking at (2) is allowed only if the number of
* line boxes between the break and the start of the enclosing
* block box is the value of 'orphans' or more, and the number
* of line boxes between the break and the end of the box is
* the value of 'widows' or more.
*
* * Rule D: In addition, breaking at (2) is allowed only if
* the 'page-break-inside' property is 'auto'.
*
* If the above doesn't provide enough break points to keep
* content from overflowing the page boxes, then rules B and D are
* dropped in order to find additional breakpoints.
*
* If that still does not lead to sufficient break points, rules A
* and C are dropped as well, to find still more break points.
*
* [endquote]
*
* We will also allow breaks between table rows. However, when
* splitting a table, the table headers should carry over to the
* next page (but they don't yet).
*/
$block_types = array("block", "list-item", "table");
// echo "\nbreak_allowed: " . $frame->get_node()->nodeName ."\n";
$display = $frame->get_style()->display;
// Block Frames (1):
if (in_array($display, $block_types)) {
// Avoid breaks within table-cells
if ($this->_in_table) {
// echo "In table: " . $this->_in_table ."\n";
return false;
}
// Rules A & B
if ($frame->get_style()->page_break_before == "avoid") {
// echo "before: avoid\n";
return false;
}
// Find the preceeding block-level sibling
$prev = $frame->get_prev_sibling();
while ($prev && !in_array($prev->get_style()->display, $block_types)) {
$prev = $prev->get_prev_sibling();
}
// Does the previous element allow a page break after?
if ($prev && $prev->get_style()->page_break_after == "avoid") {
// echo "after: avoid\n";
return false;
}
// If both $prev & $frame have the same parent, check the parent's
// page_break_inside property.
$parent = $frame->get_parent();
if ($prev && $parent && $parent->get_style()->page_break_inside == "avoid") {
// echo "parent inside: avoid\n";
return false;
}
// To prevent cascading page breaks when a top-level element has
// page-break-inside: avoid, ensure that at least one frame is
// on the page before splitting.
if ($parent->get_node()->nodeName == "body" && !$prev) {
// We are the body's first child
// echo "Body's first child.\n";
return false;
}
// If the frame is the first block-level frame, use the value from
// $frame's parent instead.
if (!$prev && $parent) {
return $this->_page_break_allowed($parent);
}
//.........这里部分代码省略.........
示例15: foreach
function add_frame_to_line(Frame $frame)
{
// Handle inline frames (which are effectively wrappers)
if ($frame instanceof Inline_Frame_Decorator) {
// Add each child of the inline frame to the line individually
foreach ($frame->get_children() as $child) {
$this->add_frame_to_line($child);
}
return;
}
if ($frame->get_margin_width() == 0) {
return;
}
$w = $frame->get_margin_width();
// Debugging code:
// pre_r("\nAdding frame to line:");
// pre_r("Me: " . $this->get_node()->nodeName . " (" . (string)$this->get_node() . ")");
// pre_r("Node: " . $frame->get_node()->nodeName . " (" . (string)$frame->get_node() . ")");
// if ( $frame->get_node()->nodeName == "#text" )
// pre_r($frame->get_node()->nodeValue);
// pre_r("Line width: " . $this->_lines[$this->_cl]["w"]);
// pre_r("Frame width: " . $w);
// pre_r("Frame height: " . $frame->get_margin_height());
// pre_r("Containing block width: " . $this->get_containing_block("w"));
// End debugging
if ($this->_lines[$this->_cl]["w"] + $w >= $this->get_containing_block("w")) {
$this->add_line();
}
$frame->position();
$this->_lines[$this->_cl]["frames"][] = $frame;
if ($frame->get_node()->nodeName == "#text") {
$this->_lines[$this->_cl]["wc"] += count(preg_split("/\\s+/", $frame->get_text()));
}
$this->_lines[$this->_cl]["w"] += $w;
$this->_lines[$this->_cl]["h"] = max($this->_lines[$this->_cl]["h"], $frame->get_margin_height());
}