Reception123 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/373735 )

Change subject: Convert GraphViz to use extension registration
......................................................................

Convert GraphViz to use extension registration

Bug: T173209
Change-Id: I8c8a47b13ca79be5789f796fe77e2b4fff28cb03
---
M GraphViz.php
M GraphViz_body.php
A extension.json
3 files changed, 111 insertions(+), 93 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GraphViz 
refs/changes/35/373735/1

diff --git a/GraphViz.php b/GraphViz.php
index 77acb12..7e1b59d 100644
--- a/GraphViz.php
+++ b/GraphViz.php
@@ -30,97 +30,14 @@
  * @file
  * @ingroup Extensions
  */
-
-define( 'GraphViz_VERSION', '2.1.0' );
-
-/**
- * The GraphViz settings class.
- */
-class GraphVizSettings {
-       /**
-        * dot executable path
-        * Windows Default: C:/Programme/ATT/Graphviz/bin/
-        * Other Platform : /usr/local/bin/dot
-        *
-        * '/' will be converted to '\\' later on, so feel free how to write 
your path C:/ or C:\\
-        *
-        * @var string $execPath
-        */
-       public $execPath;
-
-       /**
-        * mscgen executable path
-        * Commonly '/usr/bin/', '/usr/local/bin/' or (if set) '$DOT_PATH/'.
-        *
-        * '/' will be converted to '\\' later on, so feel free how to write 
your path C:/ or C:\\
-        *
-        * @var string $mscgenPath
-        */
-       public $mscgenPath;
-
-       /**
-        * default image type for the output of dot or mscgen
-        * The "default default" is png.
-        *
-        * @var string $defaultImageType
-        */
-       public $defaultImageType;
-
-       /**
-        * Whether or not to automatically create category pages for images 
created by this extension.
-        * yes|no (case insensitive). The default is no.
-        *
-        * @var string $createCategoryPages
-        */
-       public $createCategoryPages;
-
-       /**
-        * Constructor for setting configuration variable defaults.
-        */
-       public function __construct() {
-               // Set execution path
-               if ( stristr( PHP_OS, 'WIN' ) && !stristr( PHP_OS, 'Darwin' ) ) 
{
-                       $this->execPath = 'C:/Program Files/Graphviz/bin/';
-               } else {
-                       $this->execPath = '/usr/bin/';
-               }
-
-               $this->mscgenPath = '';
-               $this->defaultImageType = 'png';
-               $this->createCategoryPages = 'no';
-       }
-};
-
-if ( defined( 'MEDIAWIKI' ) ) {
-       $GLOBALS['wgGraphVizSettings'] = new GraphVizSettings();
-
-       // self executing anonymous function to prevent global scope assumptions
-       call_user_func( function () {
-               $dir = __DIR__ . '/';
-
-               $GLOBALS['wgMessagesDirs']['GraphViz'] = $dir . 'i18n';
-               $GLOBALS['wgAutoloadClasses']['GraphViz'] = $dir . 
"GraphViz_body.php";
-               $GLOBALS['wgAutoloadClasses']['GraphRenderParms'] = $dir . 
"GraphRenderParms.php";
-               $GLOBALS['wgAutoloadClasses']['UploadLocalFile'] = $dir . 
"UploadLocalFile.php";
-               $GLOBALS['wgAutoloadClasses']['UploadFromLocalFile'] = $dir . 
"UploadLocalFile.php";
-               $GLOBALS['wgHooks']['ParserFirstCallInit'][] = 
'GraphViz::onParserInit';
-               $GLOBALS['wgHooks']['ArticleDeleteComplete'][] = 
'GraphViz::onArticleDeleteComplete';
-               $GLOBALS['wgHooks']['UnitTestsList'][] = 
'GraphViz::onUnitTestsList';
-               $GLOBALS['wgHooks']['PageContentSave'][] = 
'GraphViz::onPageContentSave';
-               $GLOBALS['wgHooks']['RejectParserCacheValue'][] = 
'GraphViz::onRejectParserCacheValue';
-               $GLOBALS['wgExtensionCredits']['parserhook'][] = [
-                       'name' => 'Graphviz',
-                       'path' => __FILE__,
-                       'version' => GraphViz_VERSION,
-                       'author' => [
-                               '[http://wickle.com CoffMan]',
-                               '[mailto://arno.ven...@gmail.com 
MasterOfDesaster]',
-                               '[http://hummel-universe.net Thomas Hummel]',
-                               '[mailto://welt...@gmail.com Keith Welter]'
-                       ],
-                       'url' => 
'https://www.mediawiki.org/wiki/Extension:GraphViz',
-                       'descriptionmsg' => 'graphviz-desc',
-                       'license-name' => 'GPL-2.0+'
-               ];
-       } );
+if ( function_exists( 'wfLoadExtension' ) ) {
+       wfLoadExtension( 'GraphViz' );
+       $wgMessageDirs['GraphViz'] = __DIR__ . '/i18n';
+       wfWarn(
+               'Deprecated PHP entry point used for GraphViz extension. ' .
+               'Please use wfLoadExtension instead, ' .
+               'see https://www.mediawiki.org/wiki/Extension_registration for 
more details.'
+       );
+} else {
+       die( 'This version of the GraphViz extension requires MediaWiki 1.29+' 
);
 }
diff --git a/GraphViz_body.php b/GraphViz_body.php
index cc0e786..d6bcf5d 100644
--- a/GraphViz_body.php
+++ b/GraphViz_body.php
@@ -1227,4 +1227,61 @@
 
                return $uploadSubdir;
        }
+       /**
+ * The GraphViz settings class.
+ */
+       class GraphVizSettings {
+       /**
+        * dot executable path
+        * Windows Default: C:/Programme/ATT/Graphviz/bin/
+        * Other Platform : /usr/local/bin/dot
+        *
+        * '/' will be converted to '\\' later on, so feel free how to write 
your path C:/ or C:\\
+        *
+        * @var string $execPath
+        */
+       public $execPath;
+
+       /**
+        * mscgen executable path
+        * Commonly '/usr/bin/', '/usr/local/bin/' or (if set) '$DOT_PATH/'.
+        *
+        * '/' will be converted to '\\' later on, so feel free how to write 
your path C:/ or C:\\
+        *
+        * @var string $mscgenPath
+        */
+       public $mscgenPath;
+
+       /**
+        * default image type for the output of dot or mscgen
+        * The "default default" is png.
+        *
+        * @var string $defaultImageType
+        */
+       public $defaultImageType;
+
+       /**
+        * Whether or not to automatically create category pages for images 
created by this extension.
+        * yes|no (case insensitive). The default is no.
+        *
+        * @var string $createCategoryPages
+        */
+       public $createCategoryPages;
+
+       /**
+        * Constructor for setting configuration variable defaults.
+        */
+       public function __construct() {
+               // Set execution path
+               if ( stristr( PHP_OS, 'WIN' ) && !stristr( PHP_OS, 'Darwin' ) ) 
{
+                       $this->execPath = 'C:/Program Files/Graphviz/bin/';
+               } else {
+                       $this->execPath = '/usr/bin/';
+               }
+
+               $this->mscgenPath = '';
+               $this->defaultImageType = 'png';
+               $this->createCategoryPages = 'no';
+       }
+};
 }
diff --git a/extension.json b/extension.json
new file mode 100644
index 0000000..8ceca61
--- /dev/null
+++ b/extension.json
@@ -0,0 +1,44 @@
+{
+       "name": "GraphViz",
+       "version": "2.1.0",
+       "type": "parserhook",
+       "author": [
+               "Keith Welter",
+               "https://meta.wikimedia.org/wiki/User:Coffman Victor FariƱa",
+               "[https://www.mediawiki.org/wiki/User:Matthewpearson Matthew 
Pearson]",
+               "[https://www.mediawiki.org/wiki/User:Hummel-riegel Thomas 
Hummel]",
+               "Gregory Szorc"
+       ],
+       "url": "https://www.mediawiki.org/wiki/Extension:GraphViz";,
+       "descriptionmsg": "graphviz-desc",
+       "license-name": "GPL-2.0+",
+       "AutoloadClasses": {
+               "GraphViz": "GraphViz_body.php",
+               "UploadFromLocalFile": "UploadLocalFile.php",
+               "UploadLocalFile": "UploadLocalFile.php",
+               "GraphRenderParms": "GraphRenderParms.php"
+       },
+       "MessagesDirs": {
+               "GraphViz": [
+                       "i18n"
+               ]
+       },
+       "config": {
+               "AdminCanReadAll": {
+                       "value": true,
+                       "description": "Sysop users can read all restricted 
pages"
+               },
+               "GraphVizRedirect": {
+                       "value": true,
+                       "description": "Do not redirect from page in search 
results to restricted pages"
+               }
+       },
+       "Hooks": {
+               "ParserFirstCallInit": "GraphViz::onParserInit",
+               "ArticleDeleteComplete": "GraphViz::onArticleDeleteComplete",
+               "UnitTestsList": "GraphViz::onUnitTestsList",
+               "PageContentSave": "GraphViz::onPageContentSave",
+               "RejectParserCacheValue": "GraphViz::onRejectParserCacheValue"
+       },
+       "manifest_version": 2
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/373735
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8c8a47b13ca79be5789f796fe77e2b4fff28cb03
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GraphViz
Gerrit-Branch: master
Gerrit-Owner: Reception123 <utilizator.receptie...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to