Esempio n. 1
0
 protected function getLinksNodes($html)
 {
     $html = $this->removeHtmlComments($html);
     $linksData = array();
     foreach ($this->getLinksNodesRegexps() as $regexp) {
         if (SpeedOut_Utils::safePregMatchAll($regexp, $html, $m)) {
             foreach ($m[1] as $i => $link) {
                 if (!SpeedOut_Utils::isExternalLink($link) && $this->linksFilter->isMatch($link)) {
                     $linksData[$link] = $m[0][$i];
                 }
             }
         }
     }
     return $linksData;
 }
Esempio n. 2
0
 /**
  * @expectedException SpeedOut_Exception
  */
 public function testSafePregMatchAllThrowsException()
 {
     SpeedOut_Utils::safePregMatchAll('~(x)[~', 'x');
 }
Esempio n. 3
0
 protected function replaceImportsInLinkedData(&$linkedFileData, $linkPath)
 {
     $linkBaseDir = dirname($linkPath);
     $importsRegexp = '~@import\\s*?["\'](.*?)["\'].*?;~';
     $replaceLinksDataRegexps = array();
     $importedLinksPaths =& $this->handlingProcessData[__METHOD__ . 'importsLinksPaths'];
     if (!$importedLinksPaths) {
         $importedLinksPaths = array();
     }
     if (SpeedOut_Utils::safePregMatchAll($importsRegexp, $linkedFileData, $m)) {
         foreach ($m[1] as $i => $importLink) {
             $importLinkPath = SpeedOut_Utils::getLinkPath($importLink, $linkBaseDir);
             if (!SpeedOut_Utils::isExternalLink($importLink) && !in_array($importLinkPath, $importedLinksPaths) && $this->isValidInternalLink($importLinkPath, 'combined CSS data')) {
                 $importedLinksPaths[] = $importLinkPath;
                 $replaceLinksDataRegexps['~' . preg_quote($m[0][$i], '~') . '~'] = $this->getLinkData($importLinkPath);
             }
         }
     }
     foreach ($replaceLinksDataRegexps as $regexp => $replace) {
         $linkedFileData = SpeedOut_Utils::safePregReplace($regexp, $replace, $linkedFileData, 1);
     }
     $linkedFileData = SpeedOut_Utils::safePregReplace($importsRegexp, '', $linkedFileData);
 }