Gospel Translations:Technology/Multi-wiki project/trans bot.php
From Gospel Translations
(Difference between revisions)
(New page: <div style="background-color: #EAEAEA; border: 1px solid #CCC; padding: 10px;"> <source lang="php" line="true"> <?php // I'm a DEMO bot. You don't have to use this file unless you want to....) |
|||
| Line 2: | Line 2: | ||
<source lang="php" line="true"> | <source lang="php" line="true"> | ||
<?php | <?php | ||
| - | |||
| - | + | // define these BEFORE including basic_bot.php if you want to override the settings in basic_bot.php: | |
| - | + | ||
| - | + | ||
| - | // define these BEFORE including | + | |
// define('USERID','2'); | // define('USERID','2'); | ||
// define('USERNAME','RCBot'); | // define('USERNAME','RCBot'); | ||
// define('PASSWORD','RCBotPassword'); | // define('PASSWORD','RCBotPassword'); | ||
| - | require_once(' | + | require_once('basic_bot.php'); // the bot framework we use when making "new BasicBot()" |
| - | + | require_once('Snoopy.class.php'); // the bot framework is based on Snoopy | |
| - | require_once('Snoopy.class.php'); | + | |
| - | require_once('/home/gospeltr/public_html/w/languages/Names.php'); | + | // get a list of languages supported by MediaWiki from the MediaWiki files |
| - | global $wgLanguageNames; | + | require_once('/home/gospeltr/public_html/w/languages/Names.php'); |
| - | $ | + | global $wgLanguageNames; |
| - | + | ||
| + | // get a timestamp | ||
| + | $timestamp = date("Ymd"); | ||
| + | |||
| + | // this serialize()'d php array contains information about the translations | ||
| + | // and languages that we have on the wiki | ||
| + | $dbFile = '/home/gospeltr/public_html/w/extensions/dabble/cache/db.php'; | ||
| + | |||
| + | // ------------------------------------------------------ | ||
| + | // Start the action by reading the query string and | ||
| + | // determining what function to execute | ||
| + | // ------------------------------------------------------ | ||
| - | // | + | // Print a form if no instructions are passed through a query value 'whattodo' |
if(!isset($_GET['whattodo'])) { | if(!isset($_GET['whattodo'])) { | ||
print <<<EOT | print <<<EOT | ||
<h2>What language should we process?</h2> | <h2>What language should we process?</h2> | ||
<form action="trans_bot.php" method="GET" name="bot"> | <form action="trans_bot.php" method="GET" name="bot"> | ||
| - | <input type=" | + | <input type="hidden" name="lang" value="Spanish"> <!--//right now "es" is the only valid value, so this is hidden --> |
| - | <input type=" | + | <input type="hidden" name="lc" size="2" value="es"> <!--// the language code, same as above --> |
| - | <input type="text" name="page" value="page to scrape"> | + | <input type="text" name="page" value="page to scrape"> <!--//what page should this script pull data from? --> |
| - | < | + | <select name="whattodo"> |
| + | <option selected value="">Select...</OPTION> | ||
| + | <option>run</option> | ||
| + | <option>print</option> | ||
| + | <option>titles</option> | ||
| + | <option>see db</option> | ||
| + | </select> | ||
<input type="submit" value="submit"> | <input type="submit" value="submit"> | ||
</form> | </form> | ||
EOT; | EOT; | ||
| - | |||
exit; | exit; | ||
} | } | ||
| + | // get the library of translations loaded up | ||
| + | $ldb = unserialize(file_get_contents($dbFile)); | ||
| + | $LANGS = $ldb['l']; | ||
| + | $TERMS = $ldb['g']; | ||
| + | $db = $ldb['t']; | ||
| + | $RL = $_GET['lang']; | ||
| + | $allTranslations; | ||
| + | |||
| + | // This is a debugging option to see if this script is building its array correctly | ||
| + | // Use it to find out what titles are getting paired with what translations | ||
if($_GET['whattodo'] === 'print') { | if($_GET['whattodo'] === 'print') { | ||
| + | |||
// get the library of translations loaded up | // get the library of translations loaded up | ||
| - | $ldb = unserialize(file_get_contents($ | + | $ldb = unserialize(file_get_contents($dbFile)); |
| + | |||
| + | // for simplicity, assign unique arrays to different parts of $ldb | ||
| + | // $LANGS for all language info | ||
$LANGS = $ldb['l']; | $LANGS = $ldb['l']; | ||
| + | // $TERMS for some glossary words/translations used in the website interface | ||
$TERMS = $ldb['g']; | $TERMS = $ldb['g']; | ||
| + | // $db for translated resources, in the form $db['Language']['Resource title']['Attribute'] = > 'Value' | ||
| + | // e.g., $db['Spanish']['Gospel Implications']['Publisher'] => 'Ligonier Ministries' | ||
$db = $ldb['t']; | $db = $ldb['t']; | ||
| + | // $RL, short for resource language, as determined by the form input | ||
$RL = $_GET['lang']; | $RL = $_GET['lang']; | ||
| + | // a blank array that we'll use later to load up title=>translated_title key/value pairs | ||
$allTranslations; | $allTranslations; | ||
// go grab the list of articles and titles | // go grab the list of articles and titles | ||
| - | $fetcher = new | + | // this instance of BasicBot uses the function ScrapePage (see basic_bot.php for details) |
| + | $fetcher = new BasicBot(); | ||
$fetcher->wikiFilter($_GET['page'],'ScrapePage',$summary=''); | $fetcher->wikiFilter($_GET['page'],'ScrapePage',$summary=''); | ||
| + | // show the results of $fetcher | ||
print_r($allTranslations); | print_r($allTranslations); | ||
| Line 54: | Line 87: | ||
} | } | ||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | + | if($_GET['whattodo'] === 'see db') | |
| - | + | print_r($db); | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | $ | + | |
// go grab the list of articles and titles | // go grab the list of articles and titles | ||
| - | $fetcher = new | + | $fetcher = new BasicBot(); |
$fetcher->wikiFilter($_GET['page'],'ScrapePage',$summary=''); | $fetcher->wikiFilter($_GET['page'],'ScrapePage',$summary=''); | ||
| Line 83: | Line 98: | ||
$flip = array_flip($allTranslations); | $flip = array_flip($allTranslations); | ||
| - | $copyBot = new | + | $copyBot = new BasicBot(); |
$copyBot->ArrayFilterAll($myl,'PostCode',$summary='Automated: Added transclusion reference and categories to article source',$allTranslations); | $copyBot->ArrayFilterAll($myl,'PostCode',$summary='Automated: Added transclusion reference and categories to article source',$allTranslations); | ||
| Line 186: | Line 201: | ||
[[Category:{$db[$resLang][$res]['Author']}]] | [[Category:{$db[$resLang][$res]['Author']}]] | ||
[[Category:{$db[$resLang][$res]['Publisher']}]] | [[Category:{$db[$resLang][$res]['Publisher']}]] | ||
| - | [[Category:{$db[$resLang][$res]['Book/series']}]]<!-- | + | [[Category:{$db[$resLang][$res]['Book/series']}]] |
| + | [[Category:$timestamp]]<!-- | ||
###### Needs Review template | ###### Needs Review template | ||
{{ #ifeq: {{#language:{{#titleparts:{{PAGENAME}}|{{{levels}}}|{{#expr: {{{levels}}} +1 }}}}}} | English | |{{ #ifeq: {{{reviewed}}} | Final Version | | {{ #ifeq: {{{reviewed}}} | Peer Reviewed | {{PeerReviewed}} | {{NeedsReview}}}}}}}} | {{ #ifeq: {{#language:{{#titleparts:{{PAGENAME}}|{{{levels}}}|{{#expr: {{{levels}}} +1 }}}}}} | English | |{{ #ifeq: {{{reviewed}}} | Final Version | | {{ #ifeq: {{{reviewed}}} | Peer Reviewed | {{PeerReviewed}} | {{NeedsReview}}}}}}}} | ||
| Line 246: | Line 262: | ||
[[Category:{$db[$resLang][$res]['Author']}]] | [[Category:{$db[$resLang][$res]['Author']}]] | ||
[[Category:{$db[$resLang][$res]['Publisher']}]] | [[Category:{$db[$resLang][$res]['Publisher']}]] | ||
| - | [[Category:{$db[$resLang][$res]['Book/series']}]]<!-- | + | [[Category:{$db[$resLang][$res]['Book/series']}]] |
| + | [[Category:$timestamp]]<!-- | ||
###### Needs Review template | ###### Needs Review template | ||
{{ #ifeq: {{#language:{{#titleparts:{{PAGENAME}}|{{{levels}}}|{{#expr: {{{levels}}} +1 }}}}}} | English | |{{ #ifeq: {{{reviewed}}} | Final Version | | {{ #ifeq: {{{reviewed}}} | Peer Reviewed | {{PeerReviewed}} | {{NeedsReview}}}}}}}} | {{ #ifeq: {{#language:{{#titleparts:{{PAGENAME}}|{{{levels}}}|{{#expr: {{{levels}}} +1 }}}}}} | English | |{{ #ifeq: {{{reviewed}}} | Final Version | | {{ #ifeq: {{{reviewed}}} | Peer Reviewed | {{PeerReviewed}} | {{NeedsReview}}}}}}}} | ||
| Line 267: | Line 284: | ||
// $data_line is english_title:::trans_title | // $data_line is english_title:::trans_title | ||
$translation = explode(':::', $tvalue); | $translation = explode(':::', $tvalue); | ||
| + | |||
// load up $allTranslations[foreign] = english | // load up $allTranslations[foreign] = english | ||
| + | |||
| + | // replace spaces with underscores in foreign title (for wiki compatibility) | ||
$foreign = str_ireplace(" ","_", $translation[1]); | $foreign = str_ireplace(" ","_", $translation[1]); | ||
| + | // make $titleParts by splitting up the english title by / marks | ||
| + | $titleParts = explode('/', $translation[0]); | ||
| - | |||
$lastPart = end($titleParts); | $lastPart = end($titleParts); | ||
$res = str_ireplace('/'.$lastPart, '', $translation[0]); | $res = str_ireplace('/'.$lastPart, '', $translation[0]); | ||
| Line 285: | Line 306: | ||
} | } | ||
| + | if($_GET['whattodo'] === 'print') | ||
| + | print_r($temp_array); | ||
| + | |||
// $flip will be $..[eng] => foreign | // $flip will be $..[eng] => foreign | ||
$flip = array_flip($allTranslations); | $flip = array_flip($allTranslations); | ||
| Line 298: | Line 322: | ||
return $content; | return $content; | ||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
} | } | ||
| Line 323: | Line 327: | ||
?> | ?> | ||
| + | |||
</source> | </source> | ||
</div> | </div> | ||
Current revision as of 21:14, 2 September 2008
<?php// define these BEFORE including basic_bot.php if you want to override the settings in basic_bot.php:// define('USERID','2');// define('USERNAME','RCBot');// define('PASSWORD','RCBotPassword');require_once('basic_bot.php'); // the bot framework we use when making "new BasicBot()"
require_once('Snoopy.class.php'); // the bot framework is based on Snoopy
// get a list of languages supported by MediaWiki from the MediaWiki filesrequire_once('/home/gospeltr/public_html/w/languages/Names.php');
global $wgLanguageNames;
// get a timestamp$timestamp = date("Ymd");
// this serialize()'d php array contains information about the translations// and languages that we have on the wiki$dbFile = '/home/gospeltr/public_html/w/extensions/dabble/cache/db.php';
// ------------------------------------------------------// Start the action by reading the query string and// determining what function to execute// ------------------------------------------------------// Print a form if no instructions are passed through a query value 'whattodo'if(!isset($_GET['whattodo'])) {
print <<<EOT
<h2>What language should we process?</h2><form action="trans_bot.php" method="GET" name="bot"><input type="hidden" name="lang" value="Spanish"> <!--//right now "es" is the only valid value, so this is hidden --><input type="hidden" name="lc" size="2" value="es"> <!--// the language code, same as above --><input type="text" name="page" value="page to scrape"> <!--//what page should this script pull data from? --><select name="whattodo"><option selected value="">Select...</OPTION><option>run</option><option>print</option><option>titles</option><option>see db</option></select><input type="submit" value="submit"></form>EOT;
exit;
}// get the library of translations loaded up$ldb = unserialize(file_get_contents($dbFile));
$LANGS = $ldb['l'];
$TERMS = $ldb['g'];
$db = $ldb['t'];
$RL = $_GET['lang'];
$allTranslations;
// This is a debugging option to see if this script is building its array correctly// Use it to find out what titles are getting paired with what translationsif($_GET['whattodo'] === 'print') {
// get the library of translations loaded up$ldb = unserialize(file_get_contents($dbFile));
// for simplicity, assign unique arrays to different parts of $ldb// $LANGS for all language info$LANGS = $ldb['l'];
// $TERMS for some glossary words/translations used in the website interface$TERMS = $ldb['g'];
// $db for translated resources, in the form $db['Language']['Resource title']['Attribute'] = > 'Value'// e.g., $db['Spanish']['Gospel Implications']['Publisher'] => 'Ligonier Ministries'$db = $ldb['t'];
// $RL, short for resource language, as determined by the form input$RL = $_GET['lang'];
// a blank array that we'll use later to load up title=>translated_title key/value pairs$allTranslations;
// go grab the list of articles and titles// this instance of BasicBot uses the function ScrapePage (see basic_bot.php for details)$fetcher = new BasicBot();
$fetcher->wikiFilter($_GET['page'],'ScrapePage',$summary='');
// show the results of $fetcherprint_r($allTranslations);
exit;
}if($_GET['whattodo'] === 'see db')
print_r($db);
// go grab the list of articles and titles$fetcher = new BasicBot();
$fetcher->wikiFilter($_GET['page'],'ScrapePage',$summary='');
$myl = array_keys($allTranslations);
$flip = array_flip($allTranslations);
$copyBot = new BasicBot();
$copyBot->ArrayFilterAll($myl,'PostCode',$summary='Automated: Added transclusion reference and categories to article source',$allTranslations);
function PostCode( $content, $params ){
global $wgLanguageNames;
global $db;
global $TERMS;
global $RL;
$resLang = $RL;
global $passv;
$res = $params[$passv];
/////////////////////// break the language code off the title$titleParts = explode('/', $res);
$lastPart = end($titleParts);
// test for any 2-3 letter sequence ending the title after a /if(isset($wgLanguageNames[$lastPart])) {
$old_res = $res;
$res = str_ireplace('/'.$lastPart, '', $res);
}else {
print "Error: $res is not a foreign resource";
exit;
}// Decide whether this belongs to a book or a seriesif ($db[$resLang][$res]['Media Type'] == 'Chapter' || $db[$resLang][$res]['Media Type'] == 'Book')
$stext = 'Book';
else$stext = 'Series';
$flip = array_flip($params);
if ($db[$resLang][$res]['Media Type'] == 'Book'){
$book = $db[$resLang][$res]['Book/series'];
$toc = "===".$TERMS['Table of Contents'][$resLang] . "=== \n";
$chaps = count($db['TOC'][$book]);
for ($i=1; $i<=$chaps; $i++) {
$chapter = $db['TOC'][$book][$i];
//$chapter = str_ireplace($book.'/', '', $chapter);$chapter = $chapter . '/' . $lastPart;
$tch = $flip[$chapter];
$tch = str_replace('_', ' ', $tch);
$short_tch = explode('/', $tch);
$toc = $toc . "[[$tch|{$short_tch[1]}]] \n\n";
}// print $allTranslations;// print "\n\n";// print $toc;// exit;return <<<TOC
<div id="tran-mh"><div style="float:right"><table style="border: 1px solid rgb(148, 148, 148); margin: 0 0pt 10px 10px; padding: 3px 4px 5px 4px; background-color: rgb(233, 242, 254); color: rgb(51, 51, 51); font-family: Verdana,Arial,Helvetica,sans-serif; font-size: 10px; line-height: 13px; width: 200px;" cellspacing="0" cellpadding="0"><tr><td colspan="2" style="padding: 10px 0; text-align:center"><font style="font-size: 12px; font-weight: bold;">{$TERMS['About This'][$resLang]} {$TERMS[$db[$resLang][$res]['Media Type']][$resLang]}</font></td></tr><tr><td valign="top" width="85"><strong>{$TERMS['Publisher'][$resLang]}:</strong></td><td valign="top">[[:Category:{$db[$resLang][$res]['Publisher']}|{$db[$resLang][$res]['Publisher']}]]</td></tr><tr><td valign="top"><strong>{$TERMS['Author'][$resLang]}:</strong></td><td valign="top">[[:Category:{$db[$resLang][$res]['Author']}|{$db[$resLang][$res]['Author']}]] $satext</td></tr><tr><td valign="top"><strong>{$TERMS[$stext][$resLang]}:</strong></td><td valign="top">[[:Category:{$db[$resLang][$res]['Book/series']}|{$db[$resLang][$res]['Book/series']}]]</td></tr><tr><td valign="top"><strong>{$TERMS['Topic'][$resLang]}:</strong></td><td valign="top">[[:Category:{$TERMS[$db[$resLang][$res]['Topic']][$resLang]}|{$TERMS[$db[$resLang][$res]['Topic']][$resLang]}]]</td></tr><tr><td valign="top"><strong>{$TERMS['Subtopic'][$resLang]}:</strong></td><td valign="top">[[:Category:{$TERMS[$db[$resLang][$res]['Subtopic']][$resLang]}|{$TERMS[$db[$resLang][$res]['Subtopic']][$resLang]}]]</td></tr><tr><td valign="top" style="padding-bottom: 4px;"><strong>{$TERMS['Date'][$resLang]}:</strong></td><td valign="top" style="padding-bottom: 4px;">[[:Category:{$db[$resLang][$res]['Date']}|{$db[$resLang][$res]['Date']}]]</td></tr><tr><td valign="top" style="border-top: 1px solid #999; padding-top: 4px; margin-top: 4px;"><strong>{$TERMS['Status'][$resLang]}:</strong></td><td valign="top" style="border-top: 1px solid #999; padding-top: 4px; margin-top: 4px;">[[:Category:{$db[$resLang][$res]['Review Status']}|{$db[$resLang][$res]['Review Status']}]]</td></tr><tr><td valign="top"><strong>{$TERMS['Translator'][$resLang]}:</strong></td><td valign="top">[[:Category:{$db[$resLang][$res]['Translator']}|{$db[$resLang][$res]['Translator']}]]</td></tr><tr><td style="padding-bottom: 4px;"><strong>{$TERMS['Reviewer'][$resLang]}:</strong></td><td style="padding-bottom: 4px;">[[:Category:{$db[$resLang][$res]['Reviewer']}|{$db[$resLang][$res]['Reviewer']}]]</td></tr></table></div>[[Category:{$db[$resLang][$res]['Review Status']}]][[Category:{$TERMS[$db[$resLang][$res]['Media Type']][$resLang]}]][[Category:{$TERMS[$db[$resLang][$res]['Topic']][$resLang]}]][[Category:{$TERMS[$db[$resLang][$res]['Subtopic']][$resLang]}]][[Category:{$db[$resLang][$res]['Author']}]][[Category:{$db[$resLang][$res]['Publisher']}]][[Category:{$db[$resLang][$res]['Book/series']}]][[Category:$timestamp]]<!--###### Needs Review template{{ #ifeq: {{#language:{{#titleparts:{{PAGENAME}}|{{{levels}}}|{{#expr: {{{levels}}} +1 }}}}}} | English | |{{ #ifeq: {{{reviewed}}} | Final Version | | {{ #ifeq: {{{reviewed}}} | Peer Reviewed | {{PeerReviewed}} | {{NeedsReview}}}}}}}}--></div>$tocTOC;
}else {
return <<<TRB
<div id="tran-mh"><div style="float:right"><table style="border: 1px solid rgb(148, 148, 148); margin: 0 0pt 10px 10px; padding: 3px 4px 5px 4px; background-color: rgb(233, 242, 254); color: rgb(51, 51, 51); font-family: Verdana,Arial,Helvetica,sans-serif; font-size: 10px; line-height: 13px; width: 200px;" cellspacing="0" cellpadding="0"><tr><td colspan="2" style="padding: 10px 0; text-align:center"><font style="font-size: 12px; font-weight: bold;">{$TERMS['About This'][$resLang]} {$TERMS[$db[$resLang][$res]['Media Type']][$resLang]}</font></td></tr><tr><td valign="top" width="85"><strong>{$TERMS['Publisher'][$resLang]}:</strong></td><td valign="top">[[:Category:{$db[$resLang][$res]['Publisher']}|{$db[$resLang][$res]['Publisher']}]]</td></tr><tr><td valign="top"><strong>{$TERMS['Author'][$resLang]}:</strong></td><td valign="top">[[:Category:{$db[$resLang][$res]['Author']}|{$db[$resLang][$res]['Author']}]] $satext</td></tr><tr><td valign="top"><strong>{$TERMS[$stext][$resLang]}:</strong></td><td valign="top">[[:Category:{$db[$resLang][$res]['Book/series']}|{$db[$resLang][$res]['Book/series']}]]</td></tr><tr><td valign="top"><strong>{$TERMS['Topic'][$resLang]}:</strong></td><td valign="top">[[:Category:{$TERMS[$db[$resLang][$res]['Topic']][$resLang]}|{$TERMS[$db[$resLang][$res]['Topic']][$resLang]}]]</td></tr><tr><td valign="top"><strong>{$TERMS['Subtopic'][$resLang]}:</strong></td><td valign="top">[[:Category:{$TERMS[$db[$resLang][$res]['Subtopic']][$resLang]}|{$TERMS[$db[$resLang][$res]['Subtopic']][$resLang]}]]</td></tr><tr><td valign="top" style="padding-bottom: 4px;"><strong>{$TERMS['Date'][$resLang]}:</strong></td><td valign="top" style="padding-bottom: 4px;">[[:Category:{$db[$resLang][$res]['Date']}|{$db[$resLang][$res]['Date']}]]</td></tr><tr><td valign="top" style="border-top: 1px solid #999; padding-top: 4px; margin-top: 4px;"><strong>{$TERMS['Status'][$resLang]}:</strong></td><td valign="top" style="border-top: 1px solid #999; padding-top: 4px; margin-top: 4px;">[[:Category:{$db[$resLang][$res]['Review Status']}|{$db[$resLang][$res]['Review Status']}]]</td></tr><tr><td valign="top"><strong>{$TERMS['Translator'][$resLang]}:</strong></td><td valign="top">[[:Category:{$db[$resLang][$res]['Translator']}|{$db[$resLang][$res]['Translator']}]]</td></tr><tr><td style="padding-bottom: 4px;"><strong>{$TERMS['Reviewer'][$resLang]}:</strong></td><td style="padding-bottom: 4px;">[[:Category:{$db[$resLang][$res]['Reviewer']}|{$db[$resLang][$res]['Reviewer']}]]</td></tr></table></div>[[Category:{$db[$resLang][$res]['Review Status']}]][[Category:{$TERMS[$db[$resLang][$res]['Media Type']][$resLang]}]][[Category:{$TERMS[$db[$resLang][$res]['Topic']][$resLang]}]][[Category:{$TERMS[$db[$resLang][$res]['Subtopic']][$resLang]}]][[Category:{$db[$resLang][$res]['Author']}]][[Category:{$db[$resLang][$res]['Publisher']}]][[Category:{$db[$resLang][$res]['Book/series']}]][[Category:$timestamp]]<!--###### Needs Review template{{ #ifeq: {{#language:{{#titleparts:{{PAGENAME}}|{{{levels}}}|{{#expr: {{{levels}}} +1 }}}}}} | English | |{{ #ifeq: {{{reviewed}}} | Final Version | | {{ #ifeq: {{{reviewed}}} | Peer Reviewed | {{PeerReviewed}} | {{NeedsReview}}}}}}}}--></div>{{:gt_en:{$params[$passv]}}}TRB;
}}function ScrapePage($content){
global $allTranslations;
global $wgLanguageNames;
global $db;
global $RL;
$data_lines = explode(']]]', $content);
array_pop($data_lines);
foreach ($data_lines as $tvalue){
// $data_line is english_title:::trans_title$translation = explode(':::', $tvalue);
// load up $allTranslations[foreign] = english// replace spaces with underscores in foreign title (for wiki compatibility)$foreign = str_ireplace(" ","_", $translation[1]);
// make $titleParts by splitting up the english title by / marks$titleParts = explode('/', $translation[0]);
$lastPart = end($titleParts);
$res = str_ireplace('/'.$lastPart, '', $translation[0]);
// set aside the resource temporarily if it is a book part$short_res = $titleParts[0]."/".$titleParts[1];
if(isset($db[$RL][$short_res]['Media Type'])){
if ($db[$RL][$short_res]['Media Type'] == 'Chapter') {
$temp_array[$translation[0]] = $foreign;
}}// ........otherwise just load it upelse$allTranslations[$foreign] = $translation[0];
}if($_GET['whattodo'] === 'print')
print_r($temp_array);
// $flip will be $..[eng] => foreign$flip = array_flip($allTranslations);
foreach ($temp_array as $eng=>$for){
$temp_res_array = explode('/', $eng);
$temp_book = $temp_res_array[0].'/'.$temp_res_array[2];
$for_book = $flip[$temp_book];
$for_full_title = $for_book.'/'.$for;
$allTranslations[$for_full_title] = $eng;
}//print_r($temp_array);return $content;
}echo "Done --" . $passv;
?>