94 lines
3.1 KiB
PHP
94 lines
3.1 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 TagProceeding {
|
|
|
|
static function proceedingsRender(?string $input, array $args, Parser $parser, PPFrame $frame) {
|
|
|
|
$parser->getOutput()->updateCacheExpiry(0); // disable Cache
|
|
$user = $parser->getUserIdentity();
|
|
$outputl = '';
|
|
|
|
// checking for legacy proceeding
|
|
if ( array_key_exists('type', $args) && $args['type'] == 'legacy' ){
|
|
return "<pre>" . $input . "</pre>";
|
|
}
|
|
|
|
libxml_use_internal_errors(true);
|
|
|
|
$xml = simplexml_load_string(trim($input));
|
|
|
|
if ($xml === false) {
|
|
$errors = libxml_get_errors();
|
|
return FSMod::handle_xml_errors($errors, $input, $parser);
|
|
}
|
|
|
|
$elements = $xml->children();
|
|
|
|
$output_head = "<h2>Protokoll vom " . date("d.m.Y", strtotime($xml->datum)) . "</h2>\n\n";
|
|
|
|
$output_head .= "<h3>Anwesende</h3>\n";
|
|
$output_head .= str_ireplace(array("<anwesende>","</anwesende>"),array("<div>","</div>"),$xml->anwesende->asXML());
|
|
$output_toc = "\n<h3>Tagesordnungspunkte</h3>\n<ol>\n";
|
|
|
|
$output_content = "";
|
|
|
|
$top_number = 1;
|
|
|
|
foreach ( $elements as $element ) {
|
|
|
|
if ( $element->getName() == 'entwurf' ) {
|
|
if (!$user->isRegistered()) {
|
|
return "Dieses Protokoll wurde noch nicht veröffentlicht.";
|
|
} else {
|
|
$output_toc .= "<pre>Dieses Protokoll wurde noch nicht veröffentlicht.\n(Ein entwurf tag ist vorhanden, i.d.R. <entwurf />)</pre>\n" ;
|
|
}
|
|
}
|
|
|
|
if ( $element->getName() == 'top' ) {
|
|
$output_toc .= "<li><a href=\"#top" . $top_number . "\">" . trim($element->titel) . "</a></li>\n";
|
|
$output_content .= "<a name=\"top" . $top_number . "\"><h3>TOP " . $top_number++ . ": " . trim($element->titel) . "</h3></a>\n";
|
|
|
|
if (isset($element->text) && isset($element->text->ul)) {
|
|
$content = $element->text->ul->children();
|
|
$output_content .= "<ul>\n";
|
|
foreach ( $content as $topic ) {
|
|
if ( $topic->getName() == 'intern' ) {
|
|
if ( $user->isRegistered() ) {
|
|
$output_content .= "" . $topic->li->asXML() . "\n";
|
|
} else {
|
|
$output_content .= "<li>[(Weiteres) nicht öffentlich]</li>\n";
|
|
}
|
|
}
|
|
else {
|
|
if ( $user->isRegistered() ) {
|
|
$output_content .= preg_replace('/<intern>|<\/intern>/i', '', $topic->asXML() . "\n");
|
|
} else {
|
|
$output_content .= preg_replace('/<intern>(.)*<\/intern>/Uims', '[(Weiteres) nicht öffentlich]', $topic->asXML() . "\n");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
$output_content .= "</ul>\n";
|
|
}
|
|
|
|
}
|
|
|
|
return $output_head . $output_toc . "</ol>\n" . $output_content;
|
|
|
|
}
|
|
|
|
|
|
}
|