Changeset 146592
- Timestamp:
- 08/17/2009 11:33:19 AM (17 years ago)
- File:
-
- 1 edited
-
script-compressor/trunk/script-compressor.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
script-compressor/trunk/script-compressor.php
r146576 r146592 199 199 $output_aft = ''; 200 200 $output_css = ''; 201 202 $shelve = $this->shelve('%<!--\[if .*\]>.+<!\[endif\]-->%s', $content); 201 203 202 204 if (preg_match_all($regex_js, $content, $matches, PREG_SET_ORDER)) { … … 241 243 } 242 244 245 $this->unshelve($shelve, $content); 246 243 247 if ($this->options['output_footer']) { 244 248 $this->output .= $output_aft; … … 247 251 return $content . $output_css . $output_aft; 248 252 } 253 } 254 255 /** 256 * Shelve strings which match pattern. 257 * 258 * @param string $pattern Preg pattern 259 * @param string $str Target strings 260 * @return array Shelved data 261 */ 262 function shelve($pattern, &$str) { 263 $data = array(); 264 if (preg_match_all($pattern, $str, $matches, PREG_SET_ORDER)) { 265 foreach ($matches as $match) { 266 $key = sprintf('__SHELVE_%s_%s__', count($data), time()); 267 $data[$key] = $match[0]; 268 $str = str_replace($match[0], $key, $str); 269 } 270 } 271 return $data; 272 } 273 274 /** 275 * Unshelve strings which shelved. 276 * 277 * @param string $data Shelved data 278 * @param string $str Target strings 279 */ 280 function unshelve($data, &$str) { 281 $str = str_replace(array_keys($data), array_values($data), $str); 249 282 } 250 283
Note: See TracChangeset
for help on using the changeset viewer.