PageRenderTime 51ms CodeModel.GetById 20ms app.highlight 2ms RepoModel.GetById 18ms app.codeStats 0ms

/svn-assets/cssurlrewrite.php

http://showslow.googlecode.com/
PHP | 33 lines | 22 code | 11 blank | 0 comment | 5 complexity | 41e99d82c468959dfa47cea237c8d450 MD5 | raw file
 1<?php
 2require_once(dirname(__FILE__).'/asset_functions.php');
 3require_once(dirname(__FILE__).'/config.php');
 4
 5if (preg_match('/_deploy.css$/', $argv[1])) {
 6	exit;
 7}
 8
 9if (!preg_match('/.css$/', $argv[1])) {
10	exit;
11}
12
13$css = implode('', file($argv[1]));
14
15function replace_css_url($matches) {
16	global $baseCSSURLprefix;
17
18	$url = $matches[1];
19
20	$pos = strpos($url, $baseCSSURLprefix);
21
22	if ($pos !== FALSE && $pos == 0) {
23		$url = substr($url, strlen($baseCSSURLprefix));	
24	}
25
26	return "url('".assetURL($url)."')";
27}
28
29$output = fopen(preg_replace('/.css$/', '_deploy.css', $argv[1]), 'w');
30
31fwrite($output, preg_replace_callback('/url\(\s*[\'"](.*?)[\'"]?\s*\)/i', 'replace_css_url', $css));
32
33fclose($output);