protected function deprecateJavaScriptConditionalCompilationCode($js) { return SpeedOut_Utils::safePregReplace('~/\\*\\s*?(@.*?\\*/)~s', '/* DEPRECATED: \\1', $js); }
/** * 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); } }
protected function removeHtmlComments(&$html) { return SpeedOut_Utils::safePregReplace('~<!--.*?-->~s', '', $html); }
/** * @expectedException SpeedOut_Exception */ public function testSafePregReplaceThrowsException() { SpeedOut_Utils::safePregReplace('~[yz]', 'x', 'xyz'); }
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); }