本文整理汇总了PHP中record_warnings函数的典型用法代码示例。如果您正苦于以下问题:PHP record_warnings函数的具体用法?PHP record_warnings怎么用?PHP record_warnings使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了record_warnings函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: apply_styles
/**
* applies all current styles to a particular document tree
*
* apply_styles() applies all currently loaded styles to the provided
* {@link Frame_Tree}. Aside from parsing CSS, this is the main purpose
* of this class.
*
* @param Frame_Tree $tree
*/
function apply_styles(Frame_Tree $tree)
{
// Use XPath to select nodes. This would be easier if we could attach
// Frame objects directly to DOMNodes using the setUserData() method, but
// we can't do that just yet. Instead, we set a _node attribute_ in
// Frame->set_id() and use that as a handle on the Frame object via
// Frame_Tree::$_registry.
// We create a scratch array of styles indexed by frame id. Once all
// styles have been assigned, we order the cached styles by specificity
// and create a final style object to assign to the frame.
// FIXME: this is not particularly robust...
$styles = array();
$xp = new DOMXPath($tree->get_dom());
// Add generated content
foreach ($this->_styles as $selector => $style) {
if (strpos($selector, ":before") === false && strpos($selector, ":after") === false) {
continue;
}
$query = $this->_css_selector_to_xpath($selector, true);
// Retrieve the nodes
$nodes = @$xp->query($query["query"]);
if ($nodes == null) {
record_warnings(E_USER_WARNING, "The CSS selector '{$selector}' is not valid", __FILE__, __LINE__);
continue;
}
foreach ($nodes as $i => $node) {
foreach ($query["pseudo_elements"] as $pos) {
if (($src = $this->_image($style->content)) !== "none") {
$new_node = $node->ownerDocument->createElement("img_generated");
$new_node->setAttribute("src", $src);
} else {
$new_node = $node->ownerDocument->createElement("dompdf_generated");
}
$new_node->setAttribute($pos, $pos);
$tree->insert_node($node, $new_node, $pos);
}
}
}
// Apply all styles in stylesheet
foreach ($this->_styles as $selector => $style) {
$query = $this->_css_selector_to_xpath($selector);
// Retrieve the nodes
$nodes = @$xp->query($query["query"]);
if ($nodes == null) {
record_warnings(E_USER_WARNING, "The CSS selector '{$selector}' is not valid", __FILE__, __LINE__);
continue;
}
foreach ($nodes as $node) {
// Retrieve the node id
if ($node->nodeType != XML_ELEMENT_NODE) {
// Only DOMElements get styles
continue;
}
$id = $node->getAttribute("frame_id");
// Assign the current style to the scratch array
$spec = $this->_specificity($selector);
$styles[$id][$spec][] = $style;
}
}
// Now create the styles and assign them to the appropriate frames. (We
// iterate over the tree using an implicit Frame_Tree iterator.)
$root_flg = false;
foreach ($tree->get_frames() as $frame) {
// pre_r($frame->get_node()->nodeName . ":");
if (!$root_flg && $this->_page_style) {
$style = $this->_page_style;
$root_flg = true;
} else {
$style = $this->create_style();
}
// Find nearest DOMElement parent
$p = $frame;
while ($p = $p->get_parent()) {
if ($p->get_node()->nodeType == XML_ELEMENT_NODE) {
break;
}
}
// Styles can only be applied directly to DOMElements; anonymous
// frames inherit from their parent
if ($frame->get_node()->nodeType != XML_ELEMENT_NODE) {
if ($p) {
$style->inherit($p->get_style());
}
$frame->set_style($style);
continue;
}
$id = $frame->get_id();
// Handle HTML 4.0 attributes
Attribute_Translator::translate_attributes($frame);
if (($str = $frame->get_node()->getAttribute(Attribute_Translator::$_style_attr)) !== "") {
// Lowest specificity
//.........这里部分代码省略.........
示例2: apply_styles
function apply_styles(Frame_Tree $tree)
{
$styles = array();
$xp = new DOMXPath($tree->get_dom());
foreach ($this->_styles as $selector => $style) {
if (strpos($selector, ":before") === false && strpos($selector, ":after") === false) {
continue;
}
$query = $this->_css_selector_to_xpath($selector, true);
$nodes = @$xp->query($query["query"]);
if ($nodes == null) {
record_warnings(E_USER_WARNING, "The CSS selector '{$selector}' is not valid", __FILE__, __LINE__);
continue;
}
foreach ($nodes as $i => $node) {
foreach ($query["pseudo_elements"] as $pos) {
if ($node->hasAttribute("dompdf_{$pos}_frame_id")) {
continue;
}
if (($src = $this->_image($style->content)) !== "none") {
$new_node = $node->ownerDocument->createElement("img_generated");
$new_node->setAttribute("src", $src);
} else {
$new_node = $node->ownerDocument->createElement("dompdf_generated");
}
$new_node->setAttribute($pos, $pos);
$new_frame_id = $tree->insert_node($node, $new_node, $pos);
$node->setAttribute("dompdf_{$pos}_frame_id", $new_frame_id);
}
}
}
foreach ($this->_styles as $selector => $style) {
$query = $this->_css_selector_to_xpath($selector);
$nodes = @$xp->query($query["query"]);
if ($nodes == null) {
record_warnings(E_USER_WARNING, "The CSS selector '{$selector}' is not valid", __FILE__, __LINE__);
continue;
}
foreach ($nodes as $node) {
if ($node->nodeType != XML_ELEMENT_NODE) {
continue;
}
$id = $node->getAttribute("frame_id");
$spec = $this->_specificity($selector);
$styles[$id][$spec][] = $style;
}
}
$root_flg = false;
foreach ($tree->get_frames() as $frame) {
if (!$root_flg && $this->_page_styles["base"]) {
$style = $this->_page_styles["base"];
$root_flg = true;
} else {
$style = $this->create_style();
}
$p = $frame;
while ($p = $p->get_parent()) {
if ($p->get_node()->nodeType == XML_ELEMENT_NODE) {
break;
}
}
if ($frame->get_node()->nodeType != XML_ELEMENT_NODE) {
if ($p) {
$style->inherit($p->get_style());
}
$frame->set_style($style);
continue;
}
$id = $frame->get_id();
Attribute_Translator::translate_attributes($frame);
if (($str = $frame->get_node()->getAttribute(Attribute_Translator::$_style_attr)) !== "") {
$styles[$id][1][] = $this->_parse_properties($str);
}
if (($str = $frame->get_node()->getAttribute("style")) !== "") {
$str = preg_replace("'/\\*.*?\\*/'si", "", $str);
$spec = $this->_specificity("!attr");
$styles[$id][$spec][] = $this->_parse_properties($str);
}
if (isset($styles[$id])) {
$applied_styles = $styles[$frame->get_id()];
ksort($applied_styles);
if (DEBUGCSS) {
$debug_nodename = $frame->get_node()->nodeName;
print "<pre>\n[{$debug_nodename}\n";
foreach ($applied_styles as $spec => $arr) {
printf("specificity: 0x%08x\n", $spec);
foreach ($arr as $s) {
print "[\n";
$s->debug_print();
print "]\n";
}
}
}
foreach ($applied_styles as $arr) {
foreach ($arr as $s) {
$style->merge($s);
}
}
}
if ($p) {
//.........这里部分代码省略.........
开发者ID:EfncoPlugins,项目名称:web-portal-lite-client-portal-secure-file-sharing-private-messaging,代码行数:101,代码来源:stylesheet.cls.php
示例3: load_css_file
/**
* load and parse a CSS file
*
* @param string $file
*/
function load_css_file($file)
{
global $_dompdf_warnings;
// Prevent circular references
if (isset($this->_loaded_files[$file])) {
return;
}
$this->_loaded_files[$file] = true;
$parsed_url = explode_url($file);
list($this->_protocol, $this->_base_host, $this->_base_path, $filename) = $parsed_url;
if (!DOMPDF_ENABLE_REMOTE && ($this->_protocol != "" && $this->_protocol != "file://")) {
record_warnings(E_USER_WARNING, "Remote CSS file '{$file}' requested, but DOMPDF_ENABLE_REMOTE is false.", __FILE__, __LINE__);
return;
}
// Fix submitted by Nick Oostveen for aliased directory support:
if ($this->_protocol == "") {
$file = $this->_base_path . $filename;
} else {
$file = build_url($this->_protocol, $this->_base_host, $this->_base_path, $filename);
}
set_error_handler("record_warnings");
$css = file_get_contents($file);
restore_error_handler();
if ($css == "") {
record_warnings(E_USER_WARNING, "Unable to load css file {$file}", __FILE__, __LINE__);
return;
}
$this->_parse_css($css);
}
示例4: load_css_file
/**
* load and parse a CSS file
*
* @param string $file
*/
function load_css_file($file)
{
global $_dompdf_warnings;
// Prevent circular references
if (array_key_exists($file, $this->_loaded_files)) {
return;
}
$this->_loaded_files[$file] = true;
list($this->_protocol, $this->_base_host, $this->_base_path, $filename) = explode_url($file);
if (!DOMPDF_ENABLE_REMOTE && ($this->_protocol != "" && $this->_protocol != "file://")) {
record_warnings(E_USER_ERROR, "Remote CSS file '{$file}' requested, but DOMPDF_ENABLE_REMOTE is false.", __FILE__, __LINE__);
return;
}
if ($this->_protocol == "") {
$file = $this->_base_path . $filename;
}
set_error_handler("record_warnings");
$css = file_get_contents($file);
restore_error_handler();
if ($css == "") {
record_warnings(E_USER_ERROR, "Unable to load css file {$file}", __FILE__, __LINE__);
return;
}
$this->_parse_css($css);
}