Пример #1
0
 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();
 }
 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();
 }
Пример #3
0
 function FrameBox(&$root, &$pipeline)
 {
     // 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')) {
         pop_border();
         push_border(get_border());
     }
     $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
     //
     global $g_css;
     $old_css = $g_css;
     global $g_css_obj;
     $old_obj = $g_css_obj;
     scan_styles($tree, $pipeline);
     // Temporary hack: convert CSS rule array to CSS object
     $g_css_obj = new CSSObject();
     foreach ($g_css as $rule) {
         $g_css_obj->add_rule($rule, $pipeline);
     }
     // TODO: stinks. Rewrite
     //
     $frame_root = traverse_dom_tree_pdf($tree);
     $box_child =& create_pdf_box($frame_root, $pipeline);
     $this->add_child($box_child);
     // Restore old stylesheet
     //
     $g_css = $old_css;
     $g_css_obj = $old_obj;
     $pipeline->pop_base_url();
 }
 function process(&$data)
 {
     $data->set_content(html2xhtml($data->get_content()));
     return $data;
 }
Пример #5
0
Файл: book.php Проект: ha-y/cops
 public function getComment($withSerie = true)
 {
     $addition = "";
     $se = $this->getSerie();
     if (!is_null($se) && $withSerie) {
         $addition = $addition . "<strong>" . localize("content.series") . "</strong>" . str_format(localize("content.series.data"), $this->seriesIndex, htmlspecialchars($se->name)) . "<br />\n";
     }
     if (preg_match("/<\\/(div|p|a|span)>/", $this->comment)) {
         return $addition . html2xhtml($this->comment);
     } else {
         return $addition . htmlspecialchars($this->comment);
     }
 }
 function BoxPageMargin(&$pipeline, $at_rule)
 {
     $state =& $pipeline->get_current_css_state();
     $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->get_css_property(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->get_css_property(CSS_CONTENT);
         $content = $raw_content->render($pipeline->get_counters());
         $box =& InlineBox::create_from_text($content, WHITESPACE_PRE_LINE, $pipeline);
     }
     $this->add_child($box);
     $state->popState();
     $state->popState();
 }