+ $content = file( $entries );
+
+ // check if file is xml (subversion release <= 1.3) or not (subversion release = 1.4)
+ if ( preg_match( '/^<\?xml/', $content[0] ) ) {
+ // subversion is release <= 1.3
+ if ( !function_exists( 'simplexml_load_file' ) ) {
+ // We could fall back to expat... YUCK
+ return false;
+ }
+
+ $xml = simplexml_load_file( $entries );
+
+ if ( $xml ) {
+ foreach ( $xml->entry as $entry ) {
+ if ( $xml->entry[0]['name'] == '' ) {
+ // The directory entry should always have a revision marker.
+ if ( $entry['revision'] ) {
+ return intval( $entry['revision'] );
+ }
+ }
+ }
+ }
+ return false;
+ } else {
+ // subversion is release 1.4
+ return intval( $content[3] );
+ }
+}
+
+/**
+ * Generate a configuration file given user parameters and return the temporary filename.
+ * @param $doxygenTemplate String: full path for the template.
+ * @param $outputDirectory String: directory where the stuff will be output.
+ * @param $stripFromPath String: path that should be stripped out (usually mediawiki base path).
+ * @param $currentVersion String: Version number of the software
+ * @param $svnstat String: path to the svnstat file
+ * @param $input String: Path to analyze.
+ * @param $exclude String: Additionals path regex to exclude
+ * @param $exclude_patterns String: Additionals path regex to exclude
+ * (LocalSettings.php, AdminSettings.php, .svn and .git directories are always excluded)
+ */
+function generateConfigFile( $doxygenTemplate, $outputDirectory, $stripFromPath, $currentVersion, $svnstat, $input, $exclude, $exclude_patterns ) {
+
+ $template = file_get_contents( $doxygenTemplate );
+
+ // Replace template placeholders by correct values.
+ $replacements = array(
+ '{{OUTPUT_DIRECTORY}}' => $outputDirectory,
+ '{{STRIP_FROM_PATH}}' => $stripFromPath,
+ '{{CURRENT_VERSION}}' => $currentVersion,
+ '{{SVNSTAT}}' => $svnstat,
+ '{{INPUT}}' => $input,
+ '{{EXCLUDE}}' => $exclude,
+ '{{EXCLUDE_PATTERNS}}' => $exclude_patterns,
+ '{{HAVE_DOT}}' => `which dot` ? 'YES' : 'NO',
+ );
+ $tmpCfg = str_replace( array_keys( $replacements ), array_values( $replacements ), $template );
+ $tmpFileName = tempnam( wfTempDir(), 'mwdocgen-' );
+ file_put_contents( $tmpFileName , $tmpCfg ) or die( "Could not write doxygen configuration to file $tmpFileName\n" );
+
+ return $tmpFileName;
+}
+