<?php
# Further documentation for configuration settings may be found at:
# https://www.mediawiki.org/wiki/Manual:Configuration_settings

# Protect against web entry
if ( !defined( 'MEDIAWIKI' ) ) {
    exit;
}

## Uncomment this to disable output compression
# $wgDisableOutputCompression = true;

$wgSitename = getenv("WG_SITENAME");
$wgMetaNamespace = "Meta";

$wgScriptPath = getenv("WG_SCRIPT_PATH");

$wgServer = getenv("WG_SERVER");

$wgUploadPath = getenv("WG_UPLOAD_PATH");

# Article path
$wgArticlePath = "/wiki/$1";
$wgUploadDirectory = "/var/www/localstore/images";

## The URL path to static resources (images, scripts, etc.)
$wgResourceBasePath = $wgScriptPath;

## UPO means: this is also a user preference option

$wgEnableEmail = getenv("WG_ENABLE_EMAIL");
$wgEnableUserEmail = true; # UPO

$wgEmergencyContact = getenv("WG_EMERGENCY_CONTACT");
$wgPasswordSender = getenv("WG_PASSWORD_SENDER");

$wgEnotifUserTalk = false; # UPO
$wgEnotifWatchlist = false; # UPO
$wgEmailAuthentication = true;

## Database settings
$wgDBtype = getenv("WG_DB_TYPE");
$wgDBserver = getenv("WG_DB_SERVER");
$wgDBname = getenv("WG_DB_NAME");
$wgDBuser = getenv("WG_DB_USER");
$wgDBpassword = getenv("WG_DB_PASSWORD");
$wgDBport = getenv("WG_DB_PORT");

# Postgres specific settings
if (getenv("WG_DB_MWSCHEMA")) {
    $wgDBmwschema = getenv("WG_DB_MWSCHEMA");
}

# SQLite-specific settings
$wgSQLiteDataDir = getenv("WG_DATABASE_DIR");

## Shared memory settings
if(php_sapi_name() == "cli") {
    $wgMainCacheType    = CACHE_NONE;
} else {
    $wgMainCacheType    = CACHE_ACCEL;
}
$wgMemCachedServers = [];

$wgEnableUploads = getenv("WG_ENABLE_UPLOADS");
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "/usr/bin/convert";

$wgUseInstantCommons = false;

# telemetry
$wgPingback = false;

## If you use ImageMagick (or any other shell command) on a
## Linux server, this will need to be set to the name of an
## available UTF-8 locale
$wgShellLocale = "C.UTF-8";

## Set $wgCacheDirectory to a writable directory on the web server
## to make your wiki go slightly faster. The directory should not
## be publically accessible from the web.
#$wgCacheDirectory = "$IP/cache";

# Site language code, should be one of the list in ./languages/data/Names.php
$wgLanguageCode = getenv("WG_LANGUAGE_CODE");

$wgSecretKey = getenv("WG_SECRET_KEY");

# Changing this will log out all existing sessions.
$wgAuthenticationTokenVersion = "1";

# Site upgrade key. Must be set to a string (default provided) to turn on the
# web installer while LocalSettings.php is in place
$wgUpgradeKey = "15ae97f94f551121";

## For attaching licensing metadata to pages, and displaying an
## appropriate copyright notice / icon. GNU Free Documentation
## License and Creative Commons licenses are supported so far.
$wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright
$wgRightsUrl = "";
$wgRightsText = "";
$wgRightsIcon = "";

# Path to the GNU diff3 utility. Used for conflict resolution.
$wgDiff3 = "/usr/bin/diff3";

$wgGroupPermissions['*']['createaccount'] = !!getenv("ALLOW_PUBLIC_REGISTRATION");
$wgGroupPermissions['*']['edit'] = !!getenv("ALLOW_PUBLIC_EDIT");
$wgGroupPermissions['*']['read'] = !!getenv("ALLOW_PUBLIC_READ");

## Default skin: you can change the default skin. Use the internal symbolic
## names, ie 'vector', 'monobook':
$wgDefaultSkin = "vector";

# Enabled skins.
# The following skins were automatically enabled:
wfLoadSkin( 'MonoBook' );
wfLoadSkin( 'Timeless' );
wfLoadSkin( 'Vector' );

# Enabled extensions. Most of the extensions are enabled by adding
# wfLoadExtensions('ExtensionName');
# to LocalSettings.php. Check specific extension documentation for more details.
# The following extensions were automatically enabled:
wfLoadExtension( 'CategoryTree' );
wfLoadExtension( 'Cite' );
wfLoadExtension( 'CodeEditor' );
wfLoadExtension( 'ImageMap' );
wfLoadExtension( 'InputBox' );
#wfLoadExtension( 'OATHAuth' );
wfLoadExtension( 'ParserFunctions' );
wfLoadExtension( 'PdfHandler' );
wfLoadExtension( 'SyntaxHighlight_GeSHi' );
wfLoadExtension( 'WikiEditor' );

# End of automatically generated settings.
# Add more configuration options below.

# Load our extensions
wfLoadExtension( 'JsonConfig' );  # Configuration via Special Wiki Pages containing JSON
wfLoadExtension( 'TemplateStyles' );  # Embedd Styles from Wiki Pages containing CSS
wfLoadExtension( 'Scribunto' );  # Lua scripting
wfLoadExtension( 'SemanticScribunto' );  # Lua scripting using semantic information
#wfLoadExtension( 'Mermaid' );  # Diagrams and flowcharts, AUTOMATICALLY ENABLED as part of semanticBundle!
wfLoadExtension( 'VisualEditor' ); # WYSIWYG editor, already installed in 1.35+
wfLoadExtension( 'TemplateData' ); # Template schema information, already installed in 1.35+

# scribunto configuration
$wgScribuntoDefaultEngine = 'luastandalone';

require_once '/var/www/html/extensions/SemanticBundle/SemanticBundle.php';

# Turn on SemanticMediaWiki
enableSemantics( getenv("SEMANTIC_URL") );

# Set Subpages on
$wgNamespacesWithSubpages[NS_MAIN] = 1;

# Enable long error messages
if (getenv("DEBUG")) {
    $wgShowExceptionDetails = true;
    $wgShowDBErrorBacktrace = true;
    $wgShowSQLErrors = true;
}

#  Local configuration for MediaWiki
ini_set( 'max_execution_time', 1000 );
ini_set('memory_limit', '-1'); 

# Move the SMW config directory
$smwgConfigFileDir = '/var/www/localstore/smwconfig';

# Logo, 135x135px
$wgLogo = "/wiki/Special:Redirect/file/Logo.png";

# Footer icons

if (getenv("DISABLE_ICONS")) {
    unset( $wgFooterIcons['poweredby'] ); 
}

# Responsive
$wgVectorResponsive = true;