protected function inlineImportCallback($matches)
 {
     $replacement = '';
     if (isset($matches[2])) {
         $uri = trim($matches[2], '\'"');
     } else {
         $uri = trim($matches[1], '\'"');
     }
     // modify relative path to be relative to root, rather than
     // directory of CSS file
     if ($this->isRelative($uri)) {
         $uri = $this->sourceDirectory . '/' . $uri;
         $uri = new Concentrate_Path($uri);
         $uri = (string) $uri->evaluate();
     }
     if (!$this->inlinedFiles->contains($uri)) {
         // recursively inline the import
         $inliner = Concentrate_Inliner::factory($this->root, $uri, $this->destinationFilename, $this->inlinedFiles);
         $content = $inliner->load($inliner->filename);
         $replacement = "\n/* at-import inlined file \"{$uri}\" */\n";
         $replacement .= $inliner->inlineImports($content);
         $this->inlinedFiles->add($uri);
     }
     return $replacement;
 }
Beispiel #2
0
 public function pack($root, array $sourceFiles, $destinationFile)
 {
     $packedFiles = new Concentrate_FileList();
     $content = '';
     foreach ($sourceFiles as $sourceFile) {
         $inliner = Concentrate_Inliner::factory($root, $sourceFile, $destinationFile, $packedFiles);
         $content .= $inliner->getInlineContent();
     }
     $filename = $root . DIRECTORY_SEPARATOR . $destinationFile;
     if (!file_exists($filename) && !is_writable($root) || file_exists($filename) && !is_writable($filename)) {
         throw new Concentrate_FileException("The file '{$filename}' could not be written.");
     }
     file_put_contents($filename, $content);
     return $this;
 }