65 lines
1.9 KiB
PHP
65 lines
1.9 KiB
PHP
<?php
|
|
/**
|
|
*
|
|
* @file
|
|
* @ingroup Extensions
|
|
* @author Bennet Bleßmann
|
|
* @copyright © 2021 Bennet Bleßmann
|
|
* @license GNU General Public Licence 2.0 or later
|
|
*/
|
|
|
|
if( !defined( 'MEDIAWIKI' ) ) {
|
|
echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" );
|
|
die( 1 );
|
|
}
|
|
|
|
class TagIntern {
|
|
|
|
/*
|
|
* Outputs it's Input if user is logged in or comming from the ip range of the CAU
|
|
* otherwise returns empty string, use nocau-intern for the inverse case
|
|
*/
|
|
static function internCAU(?string $input, array $args, Parser $parser, PPFrame $frame){
|
|
$parser->getOutput()->updateCacheExpiry(0); // disable Cache
|
|
$user = $parser->getUserIdentity();
|
|
|
|
if ( $user->isRegistered() || FSMod::isCAUIP() ) {
|
|
return $parser->recursiveTagParse($input,$frame);
|
|
}else {
|
|
return "";
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Outputs it's Input if user is neither logged in nor comming from the ip range of the CAU
|
|
* otherwise returns emty string, use cau-intern for inverse case
|
|
*/
|
|
static function noInternCAU(?string $input, array $args, Parser $parser, PPFrame $frame){
|
|
$user = $parser->getUserIdentity();
|
|
|
|
if ( $user->isRegistered() || FSMod::isCAUIP() ) {
|
|
return "";
|
|
}else {
|
|
return $parser->recursiveTagParse($input,$frame);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static function internRender(?string $input, array $args, Parser $parser, PPFrame $frame) {
|
|
|
|
$parser->getOutput()->updateCacheExpiry(0); // disable Cache
|
|
$user = $parser->getUserIdentity();
|
|
|
|
if ($user->isRegistered()) {
|
|
if (isset($args["content"]) && $args["content"] == "mediawiki" ) {
|
|
return $parser->recursiveTagParse($input,$frame);
|
|
} else {
|
|
// legacy fallback
|
|
return '<strong>Intern >> </strong>' . $input . '<strong> << Intern</strong>';
|
|
}
|
|
} else {
|
|
return '';
|
|
}
|
|
}
|
|
}
|