jakob1111 / dokuwiki-plugin-flowcharts

Add flowcharts and diagrams to Dokuwiki with an incredibly simple syntax
GNU General Public License v2.0
7 stars 8 forks source link

Broken for Greebo due to internallink class #26

Open tsfstarr opened 2 years ago

tsfstarr commented 2 years ago

The current version does not work with Greebo. Replacing syntax.php with the 2018 version fixes it. It looks like the 2020 hogfather pull request, which changed the internallink class, broke it for Greebo.

bby-bishopclark commented 1 year ago

Are we unable to choose code compatible with each version via some IF statement? Compatibility is a great thing for reducing user churn if it's possible.

bby-bishopclark commented 1 year ago

Are we unable to choose code compatible with each version via some IF statement? Compatibility is a great thing for reducing user churn if it's possible.

(It should be noted this is just a minimal hack to get the service running again)


--- /usr/share/dokuwiki/lib/plugins/flowcharts/syntax.php~      2020-08-01 00:37:16.000000000 -0700
+++ /usr/share/dokuwiki/lib/plugins/flowcharts/syntax.php       2022-08-08 12:16:05.357527898 -0700
@@ -96,7 +96,12 @@
         $std_modes = array('internallink', 'media','externallink');

         foreach($std_modes as $m){
+            if(class_exists('dokuwiki\\Parsing\\ParserMode\\'.ucfirst('media'))) {
             $class = 'dokuwiki\\Parsing\\ParserMode\\'.ucfirst($m);
+           } else {
+               $class = "Doku_Parser_Mode_$m";
+           }
+
             $obj   = new $class();
             $modes[] = array(
                 'sort' => $obj->getSort(),
@@ -109,7 +114,12 @@
         $fmt_modes = array('strong','emphasis','underline','monospace',
                            'subscript','superscript','deleted');
         foreach($fmt_modes as $m){
+           if(class_exists('dokuwiki\\Parsing\\ParserMode\\'.ucfirst('media'))) {
             $obj   = new \dokuwiki\Parsing\ParserMode\Formatting($m);
+            } else {
+               $obj   = new Doku_Parser_Mode_formatting($m);
+            }
+
             $modes[] = array(
                 'sort' => $obj->getSort(),
                 'mode' => $m,
@@ -117,8 +127,17 @@
             );
         }

+
+        if(class_exists('dokuwiki\\Parsing\\ParserMode\\'.ucfirst('media'))) {
         // Create the parser and handler
         $Parser = new Parser(new Doku_Handler());
+       } else {
+            // Create the parser
+            $Parser = new Doku_Parser();
+
+            // Add the Handler
+            $Parser->Handler = new Doku_Handler();
+       }

         //add modes to parser
         foreach($modes as $mode){