function render(Frame $frame) { $style = $frame->get_style(); list($x, $y, $w, $h) = $frame->get_padding_box(); $this->_set_opacity($frame->get_opacity($style->opacity)); // 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"); } } }
function render(Frame $frame) { $style = $frame->get_style(); $bullet_style = $style->list_style_type; $bullet_size = List_Bullet_Frame_Decorator::BULLET_SIZE; $line_height = $style->length_in_pt($style->line_height, $frame->get_containing_block("w")); $fill = false; switch ($bullet_style) { default: case "disc": $fill = true; case "circle": if (!$fill) { $fill = false; } list($x, $y) = $frame->get_position(); $x += $bullet_size / 2; $y += $line_height / 2 + $bullet_size / 4; $r = $bullet_size / 4; $this->_canvas->circle($x, $y, $r, $style->color, null, null, $fill); break; case "square": list($x, $y) = $frame->get_position(); $w = $bullet_size / 2; $x += $bullet_size / 2 - $w / 2; $y += $line_height / 2; $this->_canvas->filled_rectangle($x, $y, $w, $w, $style->color); break; } }
protected function _build_tree_r(DomNode $node) { $frame = new Frame($node); $id = $frame->get_id(); $this->_registry[$id] = $frame; if (!$node->hasChildNodes()) { return $frame; } $children = array(); for ($i = 0; $i < $node->childNodes->length; $i++) { $children[] = $node->childNodes->item($i); } foreach ($children as $child) { $node_name = mb_strtolower($child->nodeName); if (in_array($node_name, self::$_HIDDEN_TAGS)) { if ($node_name !== "head" && $node_name !== "style") { $child->parentNode->removeChild($child); } continue; } if ($node_name === "#text" && $child->nodeValue == "") { $child->parentNode->removeChild($child); continue; } if ($node_name === "img" && $child->getAttribute("src") == "") { $child->parentNode->removeChild($child); continue; } $frame->append_child($this->_build_tree_r($child), false); } return $frame; }
function apply_page_style(Frame $frame, $page_number) { $style = $frame->get_style(); $page_styles = $style->get_stylesheet()->get_page_styles(); // http://www.w3.org/TR/CSS21/page.html#page-selectors if (count($page_styles) > 1) { $odd = $page_number % 2 == 1; $first = $page_number == 1; $style = clone $page_styles["base"]; // FIXME RTL if ($odd && isset($page_styles[":right"])) { $style->merge($page_styles[":right"]); } if ($odd && isset($page_styles[":odd"])) { $style->merge($page_styles[":odd"]); } // FIXME RTL if (!$odd && isset($page_styles[":left"])) { $style->merge($page_styles[":left"]); } if (!$odd && isset($page_styles[":even"])) { $style->merge($page_styles[":even"]); } if ($first && isset($page_styles[":first"])) { $style->merge($page_styles[":first"]); } $frame->set_style($style); } }
function render(Frame $frame) { if (!DOMPDF_ENABLE_JAVASCRIPT) { return; } $this->insert($frame->get_node()->nodeValue); }
function render(Frame $frame) { if (!$this->_dompdf->get_option("enable_javascript")) { return; } $this->insert($frame->get_node()->nodeValue); }
function apply_page_style(Frame $frame, $page_number) { $style = $frame->get_style(); $page_styles = $style->get_stylesheet()->get_page_styles(); if (count($page_styles) > 1) { $odd = $page_number % 2 == 1; $first = $page_number == 1; $style = clone $page_styles["base"]; if ($odd && isset($page_styles[":right"])) { $style->merge($page_styles[":right"]); } if ($odd && isset($page_styles[":odd"])) { $style->merge($page_styles[":odd"]); } if (!$odd && isset($page_styles[":left"])) { $style->merge($page_styles[":left"]); } if (!$odd && isset($page_styles[":even"])) { $style->merge($page_styles[":even"]); } if ($first && isset($page_styles[":first"])) { $style->merge($page_styles[":first"]); } $frame->set_style($style); } }
/** * 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"; }
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); } }
function __construct(Frame $frame, DOMPDF $dompdf) { if ( !$frame->is_text_node() ) throw new DOMPDF_Exception("Text_Decorator can only be applied to #text nodes."); parent::__construct($frame, $dompdf); $this->_text_spacing = null; }
/** * Render frames recursively * * @param Frame $frame the frame to render */ function render(Frame $frame) { global $_dompdf_debug; if ($_dompdf_debug) { echo $frame; flush(); } $display = $frame->get_style()->display; switch ($display) { case "block": case "list-item": case "inline-block": case "table": case "table-row-group": case "table-header-group": case "table-footer-group": case "inline-table": $this->_render_frame("block", $frame); break; case "inline": if ($frame->get_node()->nodeName === "#text") { $this->_render_frame("text", $frame); } else { $this->_render_frame("inline", $frame); } break; case "table-cell": $this->_render_frame("table-cell", $frame); break; case "-dompdf-list-bullet": $this->_render_frame("list-bullet", $frame); break; case "-dompdf-image": $this->_render_frame("image", $frame); break; case "none": $node = $frame->get_node(); if ($node->nodeName === "script") { if ($node->getAttribute("type") === "text/php" || $node->getAttribute("language") === "php") { // Evaluate embedded php scripts $this->_render_frame("php", $frame); } elseif ($node->getAttribute("type") === "text/javascript" || $node->getAttribute("language") === "javascript") { // Insert JavaScript $this->_render_frame("javascript", $frame); } } // Don't render children, so skip to next iter return; default: break; } // Check for begin frame callback $this->_check_callbacks("begin_frame", $frame); foreach ($frame->get_children() as $child) { $this->render($child); } // Check for end frame callback $this->_check_callbacks("end_frame", $frame); }
function __construct(Frame $frame) { if ($frame->get_node()->nodeName != "#text") { throw new DOMPDF_Exception("Text_Decorator can only be applied to #text nodes."); } parent::__construct($frame); $this->_text_spacing = null; }
function copy(DomNode $node) { $frame = new Frame($node); $frame->set_style(clone $this->_frame->get_original_style()); $deco = Frame_Factory::decorate_frame($frame); $deco->set_root($this->_root); return $deco; }
function deep_copy() { $frame = new Frame($this->get_node()->cloneNode()); $frame->set_style(clone $this->_frame->get_original_style()); $deco = Frame_Factory::decorate_frame($frame, $this->_dompdf); $deco->set_root($this->_root); foreach ($this->get_children() as $child) { $deco->append_child($child->deep_copy()); } return $deco; }
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; }
/** * 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; }
public function showFrame() { $idFrame = $this->data->id; $report = MApp::getService('fnbr20', '', 'reportframe'); $frame = new Frame($idFrame); $this->data->frame->entry = $frame->getEntryObject(); $this->data->fe = $report->getFEData($idFrame); $this->data->frame->entry->description = $report->decorate($this->data->frame->entry->description, $this->data->fe['styles']); $this->data->relations = $report->getRelations($frame); $this->render(); }
function render(Frame $frame) { $style = $frame->get_style(); list($x, $y, $w, $h) = $frame->get_padding_box(); // Draw our background, border and content if (($bg = $style->background_color) !== "transparent") { $this->_canvas->filled_rectangle($x, $y, $w, $h, $style->background_color); } if (($url = $style->background_image) && $url !== "none") { $this->_background_image($url, $x, $y, $w, $h, $style); } $this->_render_border($frame); }
public function getTitle($idLanguage = '') { $criteria = $this->getCriteria()->select('lu.name luName, name, lu.idLu')->orderBy('name'); Base::relation($criteria, 'lu', 'subcorpus', 'rel_hassubcorpus'); $criteria->where("idSubCorpus = {$this->idSubCorpus}"); $result = $criteria->asQuery()->getResult(); $frame = new Frame(); $criteriaFrame = $frame->getCriteria()->select('frame.entries.name as name'); Base::Relation($criteriaFrame, 'lu', 'frame', 'rel_evokes'); Base::entryLanguage($criteriaFrame); $criteriaFrame->where("lu.idLu = '{$result[0]['idLu']}'"); $resultFrame = $criteriaFrame->asQuery()->getResult(); return $resultFrame[0]['name'] . '.' . $result[0]['luName'] . ' [' . $result[0]['name'] . ']'; }
function get_min_max_width() { if (!is_null($this->_min_max_cache)) { return $this->_min_max_cache; } $style = $this->_frame->get_style(); // Account for margins & padding $dims = array($style->padding_left, $style->padding_right, $style->border_left_width, $style->border_right_width, $style->margin_left, $style->margin_right); $cb_w = $this->_frame->get_containing_block("w"); $delta = $style->length_in_pt($dims, $cb_w); // Handle degenerate case if (!$this->_frame->get_first_child()) { return $this->_min_max_cache = array($delta, $delta, "min" => $delta, "max" => $delta); } $low = array(); $high = array(); for ($iter = $this->_frame->get_children()->getIterator(); $iter->valid(); $iter->next()) { $inline_min = 0; $inline_max = 0; // Add all adjacent inline widths together to calculate max width while ($iter->valid() && in_array($iter->current()->get_style()->display, Style::$INLINE_TYPES)) { $child = $iter->current(); $minmax = $child->get_min_max_width(); if (in_array($iter->current()->get_style()->white_space, array("pre", "nowrap"))) { $inline_min += $minmax["min"]; } else { $low[] = $minmax["min"]; } $inline_max += $minmax["max"]; $iter->next(); } if ($inline_max > 0) { $high[] = $inline_max; } if ($inline_min > 0) { $low[] = $inline_min; } if ($iter->valid()) { list($low[], $high[]) = $iter->current()->get_min_max_width(); continue; } } $min = count($low) ? max($low) : 0; $max = count($high) ? max($high) : 0; // Use specified width if it is greater than the minimum defined by the // content. If the width is a percentage ignore it for now. $width = $style->width; if ($width !== "auto" && !is_percent($width)) { $width = $style->length_in_pt($width, $cb_w); if ($min < $width) { $min = $width; } if ($max < $width) { $max = $width; } } $min += $delta; $max += $delta; return $this->_min_max_cache = array($min, $max, "min" => $min, "max" => $max); }
/** * @memcheck */ public function testBuild700000() { $frame = new Frame(); $frame->withBody(str_pad("x", 700000, "x")); $frame->withOpcode(Frame::OP_BINARY); $frame->withMasking("mask"); $parsed = Frame::parse($frame->build()); $this->assertEquals(str_pad("x", 700000, "x"), $parsed->getBody()); $this->assertEquals(Frame::OP_BINARY, $frame->getOpcode()); $this->assertFalse($frame->getFinalFlag()); $this->assertTrue($frame->hasMasking()); $this->assertEquals("mask", $frame->getMasking()); }
public function __construct($options = array()) { parent::__construct($options); if ($this->_reader === null) { return; } fread($this->_reader, $this->_size); }
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); } 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"); } } }
function render(Frame $frame) { $style = $frame->get_style(); $this->_set_opacity($frame->get_opacity($style->opacity)); $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"); } } }
public static function decodeServerResponse($backtrace) { $result = new Backtrace(); $result->frames = array(); foreach ($backtrace as $frame) { $result->frames[] = Frame::decodeServerResponse($frame); } return $result; }
function render(Frame $frame) { $style = $frame->get_style(); // Draw our background, border and content if (($bg = $style->background_color) !== "transparent") { list($x, $y, $w, $h) = $frame->get_padding_box(); $this->_canvas->filled_rectangle($x, $y, $w, $h, $style->background_color); } // FIXME: need to enable & test this eventually // if ( ($img = $style->background_image) !== "none" ) { // list($x, $y, $w, $h) = $frame->get_padding_box(); // list($bx, $by) = $style->background_position; // $bx = $style->length_in_pt($bx, $w); // $by = $style->length_in_pt($by, $h); // $this->_canvas->image($img, $x + $bx, $y + $by); // } $this->_render_border($frame); }
public static function _fromJSON($backtrace) { $result = new Backtrace(); $result->frames = array(); foreach ($backtrace as $frame) { $result->frames[] = Frame::_fromJSON($frame); } return $result; }
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"); } } }
function insert_child_after(Frame $new_child, Frame $ref, $update_node = true) { while ($new_child instanceof Frame_Decorator) { $new_child = $new_child->_frame; } while ($ref instanceof Frame_Decorator) { $ref = $ref->_frame; } $this->_frame->insert_child_after($new_child, $ref, $update_node); }
public static function _fromProtobuffer(pb\Backtrace $backtrace) { $result = new Backtrace(); $result->frames = array(); $size = $backtrace->getFramesCount(); for ($i = 0; $i < $size; ++$i) { $result->frames[$i] = Frame::_fromProtobuffer($backtrace->getFramesAt($i)); } return $result; }