/.theme
 * 
 * It does also add a little piece of code to all module files which had theme functions to
 * include the theme file
 * 
 * @author Franz Heinzmann, 2006
 */

$modules = scandir('modules');

  // drop '.','..','CVS','.CVS'
foreach ($modules as $key => $value) {
  if ($value == "." || $value == ".." || $value == "CVS" || $value == ".CVS")
    unset($modules[$key]);
}

foreach ($modules as $module) {
  
  echo "Processing module ".$module.":\n";
  
  $module_code = file_get_contents('modules/'.$module.'/'.$module.'.module');
  
  $matches = array();
  
    // the magic begins ... get all themefiles, together with their phpdoc comment block
  $num_matches = preg_match_all ("!(/\*\*[^/]*?\*/)?\r.{1}function theme_.*?\r[\s]?\}!s", $module_code, &$matches);
  
  echo $num_matches." theme functions found. ";
  
  if ($num_matches > 0) {
      // let's start with the php tag and cvs id
    $theme_code = "