当前位置: 首页>>代码示例>>PHP>>正文


PHP Stylesheet::load_css_file方法代码示例

本文整理汇总了PHP中Stylesheet::load_css_file方法的典型用法代码示例。如果您正苦于以下问题:PHP Stylesheet::load_css_file方法的具体用法?PHP Stylesheet::load_css_file怎么用?PHP Stylesheet::load_css_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Stylesheet的用法示例。


在下文中一共展示了Stylesheet::load_css_file方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _process_html

 /**
  * Builds the {@link Frame_Tree}, loads any CSS and applies the styles to
  * the {@link Frame_Tree}
  */
 protected function _process_html()
 {
     $this->save_locale();
     $this->_tree->build_tree();
     $this->_css->load_css_file(Stylesheet::DEFAULT_STYLESHEET, Stylesheet::ORIG_UA);
     $acceptedmedia = Stylesheet::$ACCEPTED_GENERIC_MEDIA_TYPES;
     if (defined("DOMPDF_DEFAULT_MEDIA_TYPE")) {
         $acceptedmedia[] = DOMPDF_DEFAULT_MEDIA_TYPE;
     } else {
         $acceptedmedia[] = Stylesheet::$ACCEPTED_DEFAULT_MEDIA_TYPE;
     }
     // load <link rel="STYLESHEET" ... /> tags
     $links = $this->_xml->getElementsByTagName("link");
     foreach ($links as $link) {
         if (mb_strtolower($link->getAttribute("rel")) === "stylesheet" || mb_strtolower($link->getAttribute("type")) === "text/css") {
             //Check if the css file is for an accepted media type
             //media not given then always valid
             $formedialist = preg_split("/[\\s\n,]/", $link->getAttribute("media"), -1, PREG_SPLIT_NO_EMPTY);
             if (count($formedialist) > 0) {
                 $accept = false;
                 foreach ($formedialist as $type) {
                     if (in_array(mb_strtolower(trim($type)), $acceptedmedia)) {
                         $accept = true;
                         break;
                     }
                 }
                 if (!$accept) {
                     //found at least one mediatype, but none of the accepted ones
                     //Skip this css file.
                     continue;
                 }
             }
             $url = $link->getAttribute("href");
             $url = build_url($this->_protocol, $this->_base_host, $this->_base_path, $url);
             $this->_css->load_css_file($url, Stylesheet::ORIG_AUTHOR);
         }
     }
     // load <style> tags
     $styles = $this->_xml->getElementsByTagName("style");
     foreach ($styles as $style) {
         // Accept all <style> tags by default (note this is contrary to W3C
         // HTML 4.0 spec:
         // http://www.w3.org/TR/REC-html40/present/styles.html#adef-media
         // which states that the default media type is 'screen'
         if ($style->hasAttributes() && ($media = $style->getAttribute("media")) && !in_array($media, $acceptedmedia)) {
             continue;
         }
         $css = "";
         if ($style->hasChildNodes()) {
             $child = $style->firstChild;
             while ($child) {
                 $css .= $child->nodeValue;
                 // Handle <style><!-- blah --></style>
                 $child = $child->nextSibling;
             }
         } else {
             $css = $style->nodeValue;
         }
         // Set the base path of the Stylesheet to that of the file being processed
         $this->_css->set_protocol($this->_protocol);
         $this->_css->set_host($this->_base_host);
         $this->_css->set_base_path($this->_base_path);
         $this->_css->load_css($css);
     }
     $this->restore_locale();
 }
开发者ID:practo,项目名称:dompdf,代码行数:70,代码来源:dompdf.cls.php

示例2: _process_html

 /**
  * Builds the {@link Frame_Tree}, loads any CSS and applies the styles to
  * the {@link Frame_Tree}
  */
 protected function _process_html()
 {
     $this->_tree->build_tree();
     $this->_css->load_css_file(Stylesheet::DEFAULT_STYLESHEET, Stylesheet::ORIG_UA);
     $acceptedmedia = Stylesheet::$ACCEPTED_GENERIC_MEDIA_TYPES;
     $acceptedmedia[] = $this->get_option("default_media_type");
     // <base href="" />
     $base_nodes = $this->_xml->getElementsByTagName("base");
     if ($base_nodes->length && ($href = $base_nodes->item(0)->getAttribute("href"))) {
         list($this->_protocol, $this->_base_host, $this->_base_path) = explode_url($href);
     }
     // Set the base path of the Stylesheet to that of the file being processed
     $this->_css->set_protocol($this->_protocol);
     $this->_css->set_host($this->_base_host);
     $this->_css->set_base_path($this->_base_path);
     // Get all the stylesheets so that they are processed in document order
     $xpath = new DOMXPath($this->_xml);
     $stylesheets = $xpath->query("//*[name() = 'link' or name() = 'style']");
     foreach ($stylesheets as $tag) {
         switch (strtolower($tag->nodeName)) {
             // load <link rel="STYLESHEET" ... /> tags
             case "link":
                 if (mb_strtolower(stripos($tag->getAttribute("rel"), "stylesheet") !== false) || mb_strtolower($tag->getAttribute("type")) === "text/css") {
                     //Check if the css file is for an accepted media type
                     //media not given then always valid
                     $formedialist = preg_split("/[\\s\n,]/", $tag->getAttribute("media"), -1, PREG_SPLIT_NO_EMPTY);
                     if (count($formedialist) > 0) {
                         $accept = false;
                         foreach ($formedialist as $type) {
                             if (in_array(mb_strtolower(trim($type)), $acceptedmedia)) {
                                 $accept = true;
                                 break;
                             }
                         }
                         if (!$accept) {
                             //found at least one mediatype, but none of the accepted ones
                             //Skip this css file.
                             continue;
                         }
                     }
                     $url = $tag->getAttribute("href");
                     $url = build_url($this->_protocol, $this->_base_host, $this->_base_path, $url);
                     $this->_css->load_css_file($url, Stylesheet::ORIG_AUTHOR);
                 }
                 break;
                 // load <style> tags
             // load <style> tags
             case "style":
                 // Accept all <style> tags by default (note this is contrary to W3C
                 // HTML 4.0 spec:
                 // http://www.w3.org/TR/REC-html40/present/styles.html#adef-media
                 // which states that the default media type is 'screen'
                 if ($tag->hasAttributes() && ($media = $tag->getAttribute("media")) && !in_array($media, $acceptedmedia)) {
                     continue;
                 }
                 $css = "";
                 if ($tag->hasChildNodes()) {
                     $child = $tag->firstChild;
                     while ($child) {
                         $css .= $child->nodeValue;
                         // Handle <style><!-- blah --></style>
                         $child = $child->nextSibling;
                     }
                 } else {
                     $css = $tag->nodeValue;
                 }
                 $this->_css->load_css($css);
                 break;
         }
     }
 }
开发者ID:keshvenderg,项目名称:cloudshop,代码行数:75,代码来源:dompdf.cls.php

示例3: _process_html

 /**
  * Builds the {@link Frame_Tree}, loads any CSS and applies the styles to
  * the {@link Frame_Tree}
  */
 protected function _process_html()
 {
     $this->_tree->build_tree();
     $this->_css->load_css_file(Stylesheet::DEFAULT_STYLESHEET);
     // load <link rel="STYLESHEET" ... /> tags
     $links = $this->_xml->getElementsByTagName("link");
     foreach ($links as $link) {
         if (mb_strtolower($link->getAttribute("rel")) == "stylesheet" || mb_strtolower($link->getAttribute("type")) == "text/css") {
             $url = $link->getAttribute("href");
             $url = build_url($this->_protocol, $this->_base_host, $this->_base_path, $url);
             $this->_css->load_css_file($url);
         }
     }
     // load <style> tags
     $styles = $this->_xml->getElementsByTagName("style");
     foreach ($styles as $style) {
         // Accept all <style> tags by default (note this is contrary to W3C
         // HTML 4.0 spec:
         // http://www.w3.org/TR/REC-html40/present/styles.html#adef-media
         // which states that the default media type is 'screen'
         if ($style->hasAttributes() && ($media = $style->getAttribute("media")) && !in_array($media, Stylesheet::$ACCEPTED_MEDIA_TYPES)) {
             continue;
         }
         $css = "";
         if ($style->hasChildNodes()) {
             $child = $style->firstChild;
             while ($child) {
                 $css .= $child->nodeValue;
                 // Handle <style><!-- blah --></style>
                 $child = $child->nextSibling;
             }
         } else {
             $css = $style->nodeValue;
         }
         // Set the base path of the Stylesheet to that of the file being processed
         $this->_css->set_protocol($this->_protocol);
         $this->_css->set_host($this->_base_host);
         $this->_css->set_base_path($this->_base_path);
         $this->_css->load_css($css);
     }
 }
开发者ID:emeraldstudio,项目名称:somosmaestros,代码行数:45,代码来源:dompdf.cls.php


注:本文中的Stylesheet::load_css_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。