diff --git "a/include/class-web\\LandscapeforWiki.php" "b/include/class-web\\LandscapeforWiki.php" new file mode 100644 index 0000000..5b0e3ac --- /dev/null +++ "b/include/class-web\\LandscapeforWiki.php" @@ -0,0 +1,63 @@ +. + +# website in the Internet +namespace web; + +/** + * MediaWiki instance that belongs to Landscapefor Cultural Association + * + * @see https://wiki.landscapefor.eu/ + * @see https://www.landscapefor.eu/ + */ +class LandscapeforWiki extends \mw\StaticSite { + + /** + * @override + */ + const UID = 'landscapeforwiki'; + + /** + * @override + */ + const API_URL = 'https://wiki.landscapefor.eu/api.php'; + + /** + * @override + */ + protected static function create() { + $site = parent::create(); + $site->setNamespaces( [ + new \mw\Ns( 1, 'Discussione' ), + new \mw\Ns( 2, 'Utente' ), + new \mw\Ns( 3, 'Discussioni utente' ), + new \mw\Ns( 4, 'Landscapefor' ), + new \mw\Ns( 5, 'Discussioni Landscapefor' ), + new \mw\Ns( 6, 'File' ), + new \mw\Ns( 7, 'Discussioni file' ), + new \mw\Ns( 9, 'Discussioni MediaWiki' ), + new \mw\Ns( 10, 'Template' ), + new \mw\Ns( 11, 'Discussioni template' ), + new \mw\Ns( 12, 'Aiuto' ), + new \mw\Ns( 13, 'Discussioni aiuto' ), + new \mw\Ns( 14, 'Categoria' ), + new \mw\Ns( 15, 'Discussioni categoria' ), + ] ); + return $site; + } + +} diff --git "a/include/class-web\\MediaWikis.php" "b/include/class-web\\MediaWikis.php" new file mode 100644 index 0000000..3472263 --- /dev/null +++ "b/include/class-web\\MediaWikis.php" @@ -0,0 +1,67 @@ +. + +# websites in the Internet +namespace web; + +/** + * All the MediaWiki instances in the Internet :^) + */ +abstract class MediaWikis { + + /** + * Get all the registered MediaWiki classes + * + * @return array + */ + protected static function allClasses() { + return [ + \wm\WikipediaIt ::class, + \wm\Wikidata ::class, + \wm\Commons ::class, + \web\LandscapeforWiki::class, + ]; + } + + /** + * Get all the registered MediaWiki instances + * + * @generator + */ + public static function all() { + foreach( self::allClasses() as $classname ) { + yield $classname::getInstance(); + } + } + + /** + * Get a specific MediaWiki instance from its UID + * + * + * @param $uid string + * @return mw\StaticSite|false + */ + public static function findFromUID( $uid ) { + foreach( self::all() as $one ) { + if( $one::UID === $uid ) { + return $one; + } + } + throw new \InvalidArgumentException( "unregistered wiki $uid" ); + } + +}