request->baseUrl."/site/wf?p=",$jsonfile->parse->text->{'*'});
$replaceWikiImgURLs = str_replace("/ggbnwiki/uploads", "https://wiki.ggbn.org/ggbnwiki/uploads", $replaceInternalWikiURLs);
$replaceTableClass = str_replace("wikitable", "wikitable table table-striped", $replaceWikiImgURLs);
$replaceWikiFilePath = str_replace(Yii::$app->request->baseUrl."/site/wf?p=File", "https://wiki.ggbn.org/ggbn/File", $replaceTableClass);
$pagetext = "
".$jsonfile->parse->title."
";
return $pagetext;
}
function getNewsMembers() {
ini_set ( 'default_socket_timeout', 3 );
//Section title and image only needed for first four entries, hence do loop for section numbers 1-4
$newsOutput = [ ];
$all = @file_get_contents("https://wiki.ggbn.org/ggbnwiki/api.php?action=parse&page=News&format=json");
try { $jsonnewsall = json_decode ( $all );
$sectionNumber= [];
foreach($jsonnewsall->parse->sections as $index => $test)
{
if (strpos($test->line, 'joins') !== false) {
$sectionNumber[] = $index + 1;
}
}
$x = array_slice($sectionNumber, 0, 4);
$newsOutput = WikiAPI::getNews($x);
}
catch ( Exception $e ) {
$jsonnewsall = [ ];
}
return $newsOutput;
}
function getNews($x) {
ini_set ( 'default_socket_timeout', 3 );
//Section title and image only needed for first four entries, hence do loop for section numbers 1-4
$newsOutput = [ ];
//for ($x = 1; $x <= 4; $x++) {
foreach($x as $y) {
$news = @file_get_contents ( "https://wiki.ggbn.org/ggbnwiki/api.php?action=parse§ion=".$y."&page=News&format=json" );
if (! $news)
$news = [ ];
else {
if (strpos ( $news, "internal_api_error" ) > 0)
return [ ];
else
try {
$jsonnews = json_decode ( $news );
$newsitemtitle = $jsonnews->parse->sections[0]->line;
$newsitemanchor = $jsonnews->parse->sections[0]->anchor;
if (isset($jsonnews->parse->images[0])) {
//Get full image url (add "File:" !)
$newsimagegetpageid = @file_get_contents("https://wiki.ggbn.org/ggbnwiki/api.php?action=parse&page=File:".$jsonnews->parse->images[0]."&format=json");
$jsonnewsimagegetpageid = json_decode ( $newsimagegetpageid );
$imagepageid = $jsonnewsimagegetpageid->parse->pageid;
$newsimage = @file_get_contents ( "https://wiki.ggbn.org/ggbnwiki/api.php?action=query&titles=File:".$jsonnews->parse->images[0]."&format=json&prop=imageinfo&iiprop=url");
$jsonnewsimage = json_decode ( $newsimage );
$pageid = strval($imagepageid);
$newsitemimage = $jsonnewsimage->query->pages->$pageid->imageinfo[0]->url;
}
else { $newsitemimage = ""; }
$newsitem = array('item' => array('title' => $newsitemtitle, 'anchor' => $newsitemanchor, 'image' => $newsitemimage));
array_push($newsOutput, $newsitem);
} catch ( Exception $e ) {
$news = [ ];
}
}
}
return $newsOutput;
}
/*TODO: delete when old portal is switched off */
function getNewsoldpage() {
ini_set ( 'default_socket_timeout', 3 );
//Section title and image only needed for first four entries, hence do loop for section numbers 1-4
$newsOutput = [ ];
for ($x = 1; $x <= 4; $x++) {
$news = @file_get_contents ( "https://wiki.ggbn.org/ggbnwiki/api.php?action=parse§ion=".$x."&page=News&format=json" );
if (! $news)
$news = [ ];
else {
if (strpos ( $news, "internal_api_error" ) > 0)
return [ ];
else
try {
$jsonnews = json_decode ( $news );
$newsitemtitle = $jsonnews->parse->sections[0]->line;
$newsitemanchor = $jsonnews->parse->sections[0]->anchor;
$newsitem = array('item' => array('title' => $newsitemtitle, 'anchor' => $newsitemanchor));
array_push($newsOutput, $newsitem);
} catch ( Exception $e ) {
$news = [ ];
}
}
}
return $newsOutput;
}
}