mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-12-22 13:45:02 +00:00
Make interwiki_* functions not crash if the interwiki index hasn't been configured yet
This commit is contained in:
parent
7507867ca7
commit
76263f770c
1 changed files with 13 additions and 1 deletions
|
@ -3,7 +3,7 @@ register_module([
|
|||
"name" => "Interwiki links",
|
||||
"version" => "0.1",
|
||||
"author" => "Starbeamrainbowlabs",
|
||||
"description" => "Adds interwiki link support. Point the se",
|
||||
"description" => "Adds interwiki link support. Set the interwiki_index_location setting at an index file to activate support.",
|
||||
"id" => "feature-interwiki-links",
|
||||
"code" => function() {
|
||||
global $settings;
|
||||
|
@ -15,13 +15,21 @@ register_module([
|
|||
else
|
||||
$env->interwiki_index = json_decode(file_get_contents($paths->interwiki_index));
|
||||
}
|
||||
|
||||
// TODO: Fill this in
|
||||
add_help_section("22-interwiki-links", "Interwiki Links", "");
|
||||
}
|
||||
]);
|
||||
|
||||
/**
|
||||
* Updates the interwiki index cache file.
|
||||
* If the interwiki_index_location isn't defined, then this function will do
|
||||
* nothing.
|
||||
*/
|
||||
function interwiki_index_update() {
|
||||
if(empty($settings->interwiki_index_location))
|
||||
return;
|
||||
|
||||
$env->interwiki_index = new stdClass();
|
||||
$interwiki_csv_handle = fopen($settings->interwiki_index_location, "r");
|
||||
if($interwiki_csv_handle === false)
|
||||
|
@ -60,6 +68,10 @@ function interwiki_pagename_parse($interwiki_pagename) {
|
|||
*/
|
||||
function interwiki_pagename_resolve($interwiki_pagename) {
|
||||
global $env;
|
||||
|
||||
if(empty($env->interwiki_index))
|
||||
return null;
|
||||
|
||||
// If it's not an interwiki link, then don't bother confusing ourselves
|
||||
if(strpos($interwiki_pagename, ":") === false)
|
||||
return null;
|
||||
|
|
Loading…
Reference in a new issue