function _zenophile_process in Zenophile 7
Same name and namespace in other branches
- 6.2 zenophile.module \_zenophile_process()
Process the file queue.
Parameters
$files: The files to process.
1 call to _zenophile_process()
- zenophile_create_submit in ./
zenophile.module - Submit function for zenophile_create().
File
- ./
zenophile.module, line 447 - Creates Zen subthemes quickly and easily.
Code
function _zenophile_process($files, $t_dir) {
// Reorder the queue according to weight
$weights = array();
foreach ($files as $file) {
$weights[] = $file['weight'];
}
array_multisort($weights, SORT_ASC, $files);
if (ZENOPHILE_DEBUG) {
if (function_exists('dpm')) {
dpm($files);
}
return;
}
foreach ($files as $file => $opts) {
$dest = "{$t_dir}/{$file}";
// If there's no "from", create a blank file/dir.
if ($opts['type'] === 'dir') {
// We can't copy directories, so don't bother checking the 'from' value.
// Just make an empty directory.
mkdir($dest, 0755);
}
elseif ($opts['type'] === 'file') {
if ($opts['from'] === '') {
// No 'from' value, so just make a blank file
touch($dest);
}
else {
// If the file is probably not a text, code or CSS file…
if (!preg_match('/\\.(php|css|js|info|inc|html?|te?xt)$/', $file)) {
// Simply copy the file. Don't do replacements.
copy($opts['from'], $dest);
}
else {
// Open the file, do replacements and save it
// First, add a replacement to "reset" CVS $ I d $ lines.
$opts['repl']['/\\$Id.*\\$/'] = '$I' . 'd$';
$text = file_get_contents($opts['from']);
$text = preg_replace(array_keys($opts['repl']), array_values($opts['repl']), $text);
// Avoid file_put_contents() for PHP 4 l4mz0rz
$h = fopen($dest, 'w');
fwrite($h, $text);
fclose($h);
}
}
}
}
}