示例#1
0
 function test_unprefixNodeAttrs()
 {
     $doc = phpQuery::newDocument('<img src="p1/img0.jpg" srcset="p1/img1.jpg 1000w, img2.jpg" href="link.html"/>');
     $img = phpQuery::pq('img', $doc)->elements[0];
     $img = HtmlUtils::unprefixNodeAttrs($img, 'src, srcset,href,dummy', 'p1/');
     $this->assertEquals('img0.jpg', $img->getAttribute('src'));
     $this->assertEquals('img1.jpg 1000w, img2.jpg', $img->getAttribute('srcset'));
     $this->assertEquals('link.html', $img->getAttribute('href'));
 }
示例#2
0
文件: Utils.php 项目: anpone/sitecake
 /**
  * Checks if the given URL is a Sitecake resource URL.
  * 
  * @param  string  $url a URL to be tested
  * @return boolean      true if the URL is a Sitecake resource URL
  */
 public static function isResourceUrl($url)
 {
     $re = '/^.*(files|images)\\/.*\\-sc[0-9a-f]{13}[^\\.]*\\..+$/';
     return HtmlUtils::isRelativeURL($url) && preg_match($re, $url) && strpos($url, 'javascript:') !== 0 && strpos($url, '#') !== 0;
 }
示例#3
0
文件: Page.php 项目: anpone/sitecake
 public function appendCodeToHead($code)
 {
     HtmlUtils::appendToHead($this->doc, $code);
 }
示例#4
0
 /**
  * Converts the given HTML document into a phpQueryObject document if not
  * already.
  * 
  * @param  string|phpQueryObject $obj the input HTML document. It could be a HTML string or already
  *                                    a phpQueryObject
  * @return phpQueryObject      the resulting HTML document 
  */
 public static function toDoc($obj)
 {
     return is_object($obj) ? $obj : HtmlUtils::strToDoc($obj);
 }