Difference between revisions of "MediaWiki Extension/Extension IDLTags"

From Apache OpenOffice Wiki
Jump to: navigation, search
Line 46: Line 46:
 
Function renderIDL uses the function str_replace from PHP to convert to URL:
 
Function renderIDL uses the function str_replace from PHP to convert to URL:
  
<nowiki>
+
<nowiki>function renderIDL( $input, $args, $parser ) {
function renderIDL( $input, $args, $parser ) {
+
 
               $parser->disableCache();
 
               $parser->disableCache();
 
               $output = $parser->recursiveTagParse( $input );
 
               $output = $parser->recursiveTagParse( $input );
Line 59: Line 58:
 
Function renderIDL used to use the function ereg_replace from PHP to convert to URL:
 
Function renderIDL used to use the function ereg_replace from PHP to convert to URL:
  
function renderIDLM( $input, $args, $parser ) {
+
<nowiki>function renderIDLM( $input, $args, $parser ) {
 
         $parser->disableCache();
 
         $parser->disableCache();
 
         $output = $parser->recursiveTagParse( $input );
 
         $output = $parser->recursiveTagParse( $input );
Line 68: Line 67:
 
             $anchor.'" class="external text">'.$function.'</a>';
 
             $anchor.'" class="external text">'.$function.'</a>';
 
         return $output;
 
         return $output;
     }
+
     }</nowiki>
  
 
=== Function renderIDLS ===
 
=== Function renderIDLS ===
 
Function renderIDLS used to use the function ereg_replace from PHP to convert to URL:
 
Function renderIDLS used to use the function ereg_replace from PHP to convert to URL:
  
function renderIDLS( $input, $args, $parser ) {
+
<nowiki>function renderIDLS( $input, $args, $parser ) {
 
         $parser->disableCache();
 
         $parser->disableCache();
 
         $output = $parser->recursiveTagParse( $input );
 
         $output = $parser->recursiveTagParse( $input );
Line 79: Line 78:
 
         $output = '<a href="http://api.openoffice.org/docs/common/ref/' .
 
         $output = '<a href="http://api.openoffice.org/docs/common/ref/' .
 
             ereg_replace ('\.','/',$output).'.html" class="external  
 
             ereg_replace ('\.','/',$output).'.html" class="external  
text">'.$function.'</a>';
+
                            text">'.$function.'</a>';
 
         return $output;
 
         return $output;
  }
+
    }</nowiki>
  
 
=== Function renderIDLMODULE ===
 
=== Function renderIDLMODULE ===
 
Function renderIDLMODULE used to use the function ereg_replace from PHP to convert to URL:
 
Function renderIDLMODULE used to use the function ereg_replace from PHP to convert to URL:
  
function renderIDLM( $input, $args, $parser ) {
+
<nowiki>function renderIDLM( $input, $args, $parser ) {
 
         $parser->disableCache();
 
         $parser->disableCache();
 
         $output = $parser->recursiveTagParse( $input );
 
         $output = $parser->recursiveTagParse( $input );
Line 95: Line 94:
 
             $anchor.'" class="external text">'.$function.'</a>';
 
             $anchor.'" class="external text">'.$function.'</a>';
 
         return $output;
 
         return $output;
     }
+
     }</nowiki>
  
 
=== Function renderIDLTOPIC ===
 
=== Function renderIDLTOPIC ===
 
The use or purpose of this function is unknown. Tags in the wiki are commented out.
 
The use or purpose of this function is unknown. Tags in the wiki are commented out.
  
function renderIDLTOPIC( $input, $args, $parser ) {
+
<nowiki>function renderIDLTOPIC( $input, $args, $parser ) {
 
$parser->disableCache();
 
$parser->disableCache();
 
return '';
 
return '';
}
+
    }</nowiki>
  
A problem arose
+
== A problem arose ==
 
The extension worked for a long time, but since some time contents of a lot of pages of the Developers Guide were no longer displayed. Investigation learned that the text still was there, but that it wasn't rendered on the page.
 
The extension worked for a long time, but since some time contents of a lot of pages of the Developers Guide were no longer displayed. Investigation learned that the text still was there, but that it wasn't rendered on the page.
 
Editing the pages was still possible by tweaking the URL of the page from (as an example):
 
Editing the pages was still possible by tweaking the URL of the page from (as an example):
https://wiki.openoffice.org/wiki/Documentation/DevGuide/Documentation/DevGuide/FirstSteps/First Contact
+
[[https://wiki.openoffice.org/wiki/Documentation/DevGuide/Documentation/DevGuide/FirstSteps/First Contact]]
 
to
 
to
https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Documentation/DevGuide/FirstSteps/First Contact&action=edit
+
[[https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Documentation/DevGuide/FirstSteps/First Contact&action=edit]]
  
 
That would bring up the content of the page and the possibility to edit it.
 
That would bring up the content of the page and the possibility to edit it.
 
That investigation also led to the conclusion that effected pages contained one or more of the IDLS, IDLM of IDLMODULE tags. Further was determined that pages that only contained IDL tags were displayed correctly.
 
That investigation also led to the conclusion that effected pages contained one or more of the IDLS, IDLM of IDLMODULE tags. Further was determined that pages that only contained IDL tags were displayed correctly.
 +
 
It was likely that the extension IDLTags did no longer do his fabulous work. Arrigo Marchiori set us on the right track pointing out that the function ereg_replace was deprecated and removed from PHP 7.0.* and therefore can't be used anymore.
 
It was likely that the extension IDLTags did no longer do his fabulous work. Arrigo Marchiori set us on the right track pointing out that the function ereg_replace was deprecated and removed from PHP 7.0.* and therefore can't be used anymore.
 
The version of Mediawiki for AOo uses version 7.0.3 of PHP.
 
The version of Mediawiki for AOo uses version 7.0.3 of PHP.
 +
 
This broke the existing extension so that it didn't render the IDLM, IDLS and IDLMODULE tags anymore. As a result of this the content of pages on the Mediawiki that contained one or more of these tags were no longer displayed. They rendered full white.
 
This broke the existing extension so that it didn't render the IDLM, IDLS and IDLMODULE tags anymore. As a result of this the content of pages on the Mediawiki that contained one or more of these tags were no longer displayed. They rendered full white.
 
Therefore function renderIDLM, function renderIDLS and function renderIDLMODULE did no longer do their work and content of pages that contained one of these tags were no longer displayed correctly but only fully white rendered.
 
Therefore function renderIDLM, function renderIDLS and function renderIDLMODULE did no longer do their work and content of pages that contained one of these tags were no longer displayed correctly but only fully white rendered.
  
 +
== Fix ==
 
The functions needed to be adapted to use another function than ereg_replace. That function proved to be preg_replace and Carl Marcum worked his magic on this one.
 
The functions needed to be adapted to use another function than ereg_replace. That function proved to be preg_replace and Carl Marcum worked his magic on this one.
  
  
function renderIDLM( $input, $args, $parser ) {
+
<nowiki>function renderIDLM( $input, $args, $parser ) {
 
$parser->disableCache();
 
$parser->disableCache();
 
$output = $parser->recursiveTagParse( $input );
 
$output = $parser->recursiveTagParse( $input );
Line 131: Line 133:
 
$anchor.'" class="external text">'.$function.'</a>';
 
$anchor.'" class="external text">'.$function.'</a>';
 
return $output;
 
return $output;
}
+
}</nowiki>
 
 
 
 
function renderIDLS( $input, $args, $parser ) {
+
<nowiki>function renderIDLS( $input, $args, $parser ) {
 
$parser->disableCache();
 
$parser->disableCache();
 
$output = $parser->recursiveTagParse( $input );
 
$output = $parser->recursiveTagParse( $input );
Line 140: Line 142:
 
preg_replace ('/\./','/',$output).'.html" class="external text">'.$function.'</a>';
 
preg_replace ('/\./','/',$output).'.html" class="external text">'.$function.'</a>';
 
return $output;
 
return $output;
}
+
}/<nowiki>
 
 
 
 
function renderIDLMODULE( $input, $args, $parser ) {
+
<nowiki>function renderIDLMODULE( $input, $args, $parser ) {
 
$parser->disableCache();
 
$parser->disableCache();
 
$output = $parser->recursiveTagParse( $input );
 
$output = $parser->recursiveTagParse( $input );
Line 149: Line 151:
 
preg_replace ('/\./','/',$output).'/module-ix.html" class="external text">'.$output.'</a>';
 
preg_replace ('/\./','/',$output).'/module-ix.html" class="external text">'.$output.'</a>';
 
return $output;
 
return $output;
}
+
}</nowiki>
  
 
Using this new adapted functions the links in the DevGuide function again as of 2020-12-17.
 
Using this new adapted functions the links in the DevGuide function again as of 2020-12-17.
  
 
Thank you all.
 
Thank you all.

Revision as of 16:05, 18 December 2020

IDLTags extension for Mediawiki

The IDLTags extension was written by Clayton Cornell and Terry Ellison to manage the IDL links in the OpenOffice.org Developer's Guide. The extension converts Java paths, like com.sun.star.frame.Desktop to links back to the online IDL documentation, such as http://api.openoffice.org/docs/common/ref/com/sun/star/frame/Desktop.html which then gets redirected to https://www.openoffice.org/api/docs/common/ref/com/sun/star/frame/Desktop.html.

On the Mediawiki these links are, for instance, present on the pages of the OpenOffice Developers Guide. Yes, there are quiet a lot of them there. Supposedly it was designed to have to enter less characters in the wiki as possible. They invented some tags to use.

These are:

Tag Use
<idl> </idl> link
<idls> </idls> probably used for services
<idlm> </idlm> probably used for methodes
<idlmodule> </idlmodule> used for modules to lead to the index page
<idltopic> </idltopic>

This last tag is mentioned, but does not seem to have a function in the extension and will be ignored further.

On the wikipages these tags contain a part of the IDL reference to link back to:

<idl>com.sun.star.frame.Desktop</idl>

<idls>com.sun.star.lang.DisposedException</idls>

<idlm>com.sun.star.uno.XComponentContext:getServiceManager</idlm>

<idlmodule>com.sun.star.awt</idlmodule>

Use

This extension converts the content of the tag to a regular link. It is written in PHP and uses, besides functions from PHP, internal functions of Mediawiki.

Functions

It consist of five separate functions, one for each tag:

Function renderIDL

Function renderIDL uses the function str_replace from PHP to convert to URL:

function renderIDL( $input, $args, $parser ) {
               $parser->disableCache();
               $output = $parser->recursiveTagParse( $input );
               $output = '<a href="http://api.openoffice.org/docs/common/ref/' .
                str_replace ('.','/',$output).'.html" class="external 
                             text">'.$output.'</a>';
             return $output;
         }

Function renderIDLM

Function renderIDL used to use the function ereg_replace from PHP to convert to URL:

function renderIDLM( $input, $args, $parser ) {
         $parser->disableCache();
         $output = $parser->recursiveTagParse( $input );
         $page = ereg_replace ('\.','/',$output);
         $anchor = ereg_replace (':','.html#',$page);
         $function = ereg_replace ('^.*:','',$page);
         $output = '<a href="http://api.openoffice.org/docs/common/ref/' .
             $anchor.'" class="external text">'.$function.'</a>';
         return $output;
     }

Function renderIDLS

Function renderIDLS used to use the function ereg_replace from PHP to convert to URL:

function renderIDLS( $input, $args, $parser ) {
         $parser->disableCache();
         $output = $parser->recursiveTagParse( $input );
         $function = ereg_replace ('^.*\.','',$output);
         $output = '<a href="http://api.openoffice.org/docs/common/ref/' .
             ereg_replace ('\.','/',$output).'.html" class="external 
                            text">'.$function.'</a>';
         return $output;
    }

Function renderIDLMODULE

Function renderIDLMODULE used to use the function ereg_replace from PHP to convert to URL:

function renderIDLM( $input, $args, $parser ) {
         $parser->disableCache();
         $output = $parser->recursiveTagParse( $input );
         $page = ereg_replace ('\.','/',$output);
         $anchor = ereg_replace (':','.html#',$page);
         $function = ereg_replace ('^.*:','',$page);
         $output = '<a href="http://api.openoffice.org/docs/common/ref/' .
             $anchor.'" class="external text">'.$function.'</a>';
         return $output;
     }

Function renderIDLTOPIC

The use or purpose of this function is unknown. Tags in the wiki are commented out.

function renderIDLTOPIC( $input, $args, $parser ) {
		$parser->disableCache();
		return '';
     }

A problem arose

The extension worked for a long time, but since some time contents of a lot of pages of the Developers Guide were no longer displayed. Investigation learned that the text still was there, but that it wasn't rendered on the page. Editing the pages was still possible by tweaking the URL of the page from (as an example): [Contact] to [Contact&action=edit]

That would bring up the content of the page and the possibility to edit it. That investigation also led to the conclusion that effected pages contained one or more of the IDLS, IDLM of IDLMODULE tags. Further was determined that pages that only contained IDL tags were displayed correctly.

It was likely that the extension IDLTags did no longer do his fabulous work. Arrigo Marchiori set us on the right track pointing out that the function ereg_replace was deprecated and removed from PHP 7.0.* and therefore can't be used anymore. The version of Mediawiki for AOo uses version 7.0.3 of PHP.

This broke the existing extension so that it didn't render the IDLM, IDLS and IDLMODULE tags anymore. As a result of this the content of pages on the Mediawiki that contained one or more of these tags were no longer displayed. They rendered full white. Therefore function renderIDLM, function renderIDLS and function renderIDLMODULE did no longer do their work and content of pages that contained one of these tags were no longer displayed correctly but only fully white rendered.

Fix

The functions needed to be adapted to use another function than ereg_replace. That function proved to be preg_replace and Carl Marcum worked his magic on this one.


function renderIDLM( $input, $args, $parser ) {
		$parser->disableCache();
		$output = $parser->recursiveTagParse( $input );
		$page = preg_replace ('/\./','/',$output);
		$anchor = preg_replace ('/:/','.html#',$page);
		$function = preg_replace ('/^.*:/','',$page);
		$output = '<a href="http://api.openoffice.org/docs/common/ref/' . 
			$anchor.'" class="external text">'.$function.'</a>';
		return $output;
	}
function renderIDLS( $input, $args, $parser ) {
		$parser->disableCache();
		$output = $parser->recursiveTagParse( $input );
		$function = preg_replace ('/^.*\./','',$output);
		$output = '<a href="http://api.openoffice.org/docs/common/ref/' . 
			preg_replace ('/\./','/',$output).'.html" class="external text">'.$function.'</a>';
		return $output;
	}/<nowiki>
	 
 <nowiki>function renderIDLMODULE( $input, $args, $parser ) {
		$parser->disableCache();
		$output = $parser->recursiveTagParse( $input );
		$function = preg_replace ('/^.*\./','',$output);
		$output = '<a href="http://api.openoffice.org/docs/common/ref/' . 
			preg_replace ('/\./','/',$output).'/module-ix.html" class="external text">'.$output.'</a>';
		return $output;
	}

Using this new adapted functions the links in the DevGuide function again as of 2020-12-17.

Thank you all.

Personal tools