A little php

From Virtualsoil

How do you create more than 100 pages with very similar content ? With some php (below) and the Wiki Special page for Importing XML, that's how!

<?php
/*This little program will generate pages in XML Wiki format for each of the 12 themes and 13 Genres combinations */
/* in my Story Wiki*/
//
//

/* the body of the pages is very similar, only one line changes, hence pbody1, pbody2 are the stuff before and after */
/* the line that changes */
$pbody1 = '<timestamp>2006-03-13T05:51:00Z</timestamp>
      <contributor><username>Admin</username><id>2</id></contributor>
      <text xml:space="preserve">';
$pbody2='

<!-- Fill in the dotted lines below -->
*Author   : ... (your name)  
*Status   : ... (Finished, On Hold or In Progress) 
*Published: ... (date) 
*Rating   : ... (R, G, PG13, PG, XXX) 
*Short Descripition: ...(a summary of your novel)

===Chapter 1===                   <!-- Copy and paste this line to add more chapters   -->

....paste your chapter here....</text>';
//
// 
//
/* XML for the file header */
	 $headerxml = '<mediawiki xmlns="http://www.mediawiki.org/xml/export-0.3/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.3/ http://www.mediawiki.org/xml/export-0.3.xsd" version="0.3" xml:lang="en">' ;
//
/* 12 Themes */
     $theme = array ("Anime", "Book","Cartoon","Comic-Manga","MiscFanFiction","Movie","Non-Fiction","OriginalFiction","TV","Videogame");
/* 13 Genres */
	 $genre = array ("Action-Adventure","Angst","Drama","General","Horror","Humor","Mystery","ORPG","Parody","Poetry","Romance","Sci-Fi","Suspense");
//
/* Generate 146 pages */
		echo ("$headerxml \
") ;
       for ($i = 0; $i < 12; $i++) {
	   $t1 = $theme[$i];
	   for ($j = 0; $j < 13; $j++) {
	    $g1 = $genre[$j] ;
		echo ("<page>\
");
		echo ("<id></id>\
");
		echo ("<title>ZpreloadEnglish".$t1.$g1."</title>\
");
		echo ("<restrictions>0</restrictions>\
"); //locking to sysop ?
		echo ("<revision>\
");
		echo ("<id></id>\
");	
		$ttempcall='{{StoryCat|English|'.$t1.'|'.$g1.'}}{{TOCleft}} <span style="display: none;">English, '.$t1.', '.$g1.'</span> <!-- leave this line here!!!  -->' ;
		echo ("$pbody1"."$ttempcall"."$pbody2"."\
");
		echo ("</revision>\
") ;
		echo ("</page>\
") ;
		}
        }
		echo ("</mediawiki>\
") ;
?>
Personal tools