// suggest a download Safe::header('Content-Type: application/zip'); Safe::header('Content-Disposition: attachment; filename="backup_parameters.zip"'); // send the archive content echo $zipfile->get(); // do not allow for regular rendering return; // backup current skin } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'skin') { // list files $context['text'] .= '<p>' . i18n::s('Listing files...') . BR . "\n"; // locate skin include_once '../scripts/scripts.php'; $file_path = $context['path_to_root'] . $context['skin']; $file_prefix = $context['path_to_root'] . 'skins/'; $datafiles = Scripts::list_files_at($file_path, TRUE, $file_prefix); if (is_array($datafiles)) { $context['text'] .= BR . sprintf(i18n::s('%d files have been found.'), count($datafiles)) . '</p>' . "\n"; // splash message $context['text'] .= '<p>' . i18n::s('On-going archive preparation...') . '</p>' . "\n"; // build a zip archive include_once '../shared/zipfile.php'; $zipfile = new zipfile(); // process every skin/current_skin/ file $index = 0; foreach ($datafiles as $datafile) { // let's go list($path, $filename) = $datafile; if ($path) { $file = $path . '/' . $filename; } else {
} if (count($footprints)) { $context['text'] .= sprintf(i18n::s('%d reference scripts have been copied.'), count($footprints)) . "\n"; } $context['text'] .= "</p>\n"; // purge documentation pages $context['text'] .= '<p>' . i18n::s('Purging the documentation pages...') . "</p>\n"; // get a parser include_once 'phpdoc.php'; $documentation = new PhpDoc(); // purge the existing documentation, if any $documentation->purge(); // list reference files $context['text'] .= '<p>' . i18n::s('Listing files...') . BR . "\n"; // locate reference files --include special nodes $references = Scripts::list_files_at($context['path_to_reference'], TRUE, $context['path_to_reference'], '.htaccess'); if (is_array($references)) { $context['text'] .= BR . sprintf(i18n::s('%d files have been found.'), count($references)) . "\n"; } $context['text'] .= "</p>\n"; // build documentation pages $context['text'] .= '<p>' . i18n::s('Building documentation pages...') . BR . "\n"; // analyse each script $index = 0; foreach ($references as $reference) { // use file content list($module, $name) = $reference; if ($module) { $file = $module . '/' . $name; } else { $file = $name;
/** * list all files below a certain path * * Also print '.' and '!' while scanning the path to animate the resulting screen, * if the verbose parameter is set to TRUE. * * Node names starting with a '.' character are skipped, except if they match the last parameter. * * @param string the absolute path to scan * @param boolean TRUE to animate the screen, FALSE to stay silent * @param string prefix to strip in path returned to caller * @param string to accept special names (e.g., '.htaccess') * @return an array of array(path, file name) * * @see scripts/build.php */ public static function list_files_at($path, $verbose = TRUE, $stripped = '', $special = NULL) { global $context, $script_count; // the list that is returned $files = array(); // sanity check $path = rtrim($path, '/'); // make a real path if ($handle = Safe::opendir($path)) { // list all nodes while (($node = Safe::readdir($handle)) !== FALSE) { // special directory names if ($node == '.' || $node == '..') { continue; } // process special nodes if ($node[0] == '.') { // skip this item if (!$special || strpos($node, $special) === FALSE) { continue; } } // make a real name $target = $path . '/' . $node; // scan a sub directory if (is_dir($target)) { // extend the list recursively $files = array_merge($files, Scripts::list_files_at($target, $verbose, $stripped, $special)); // animate the screen if ($verbose) { $context['text'] .= '!'; } if ($script_count++ > 50) { $script_count = 0; if ($verbose) { $context['text'] .= BR . "\n"; } } // scan a file } elseif (is_readable($target)) { // remove prefix, if any if ($stripped && strpos($path, $stripped) === 0) { $relative = substr($path, strlen($stripped)); } elseif ($stripped && strpos($stripped, $path) === 0) { $relative = ''; } else { $relative = $path; } // append the item to the list $files[] = array($relative, $node); // animate the screen if ($verbose) { $context['text'] .= '.'; } if ($script_count++ > 50) { $script_count = 0; if ($verbose) { $context['text'] .= BR . "\n"; } } } } Safe::closedir($handle); } return $files; }