Esempio n. 1
0
 protected function deprecateJavaScriptConditionalCompilationCode($js)
 {
     return SpeedOut_Utils::safePregReplace('~/\\*\\s*?(@.*?\\*/)~s', '/* DEPRECATED: \\1', $js);
 }
Esempio n. 2
0
 /**
  * Get URL for external or URI for local path of some link
  * @static
  * @param $link
  * @param string $baseDir
  * @return string|null
  */
 public static function getRealLink($link, $baseDir = null)
 {
     if (self::isExternalLink($link)) {
         return $link;
     } else {
         $path = ($baseDir && self::isRelativeLink($link) ? $baseDir : self::getDocRoot()) . '/' . SpeedOut_Utils::safePregReplace('~\\?.*~', '', $link);
         return self::getPathUri($path, false);
     }
 }
Esempio n. 3
0
 protected function removeHtmlComments(&$html)
 {
     return SpeedOut_Utils::safePregReplace('~<!--.*?-->~s', '', $html);
 }
Esempio n. 4
0
 /**
  * @expectedException SpeedOut_Exception
  */
 public function testSafePregReplaceThrowsException()
 {
     SpeedOut_Utils::safePregReplace('~[yz]', 'x', 'xyz');
 }
Esempio n. 5
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);
 }