Skip to content

Commit

Permalink
Reorganize to new component structure.
Browse files Browse the repository at this point in the history
This is the second step in implementing the reorganization outlined in
http://lists.wikimedia.org/pipermail/wikidata-tech/2013-August/000204.html

All changes are internal organization. The only thing that changed
from the outside is that the old component specific entry points
no longer exist. These did not have any users, so this ought to not
cause any problems.

The next and final step in the reorganization is to move the contents
of the DataValuesCommon, DataValuesInterfaces and ValueView directories
into their own git repos, and to promote the contents of the DataValues
directory to the root of the git repo. That change will obviously
require users to change some things :)

Change-Id: Ie8e50a244fe9a6c9b193182343c3784671d15022
  • Loading branch information
JeroenDeDauw authored and DanweDE committed Sep 4, 2013
0 parents commit d56de82
Show file tree
Hide file tree
Showing 97 changed files with 9,971 additions and 0 deletions.
347 changes: 347 additions & 0 deletions COPYING

Large diffs are not rendered by default.

59 changes: 59 additions & 0 deletions DataValuesCommon.classes.php
@@ -0,0 +1,59 @@
<?php

return array(
'ValueFormatters\ValueFormatterFactory' => 'src/ValueFormatters/ValueFormatterFactory.php',

'ValueFormatters\GeoCoordinateFormatter' => 'src/ValueFormatters/GeoCoordinateFormatter.php',
'ValueFormatters\GlobeCoordinateFormatter' => 'src/ValueFormatters/GlobeCoordinateFormatter.php',
'ValueFormatters\IriFormatter' => 'src/ValueFormatters/IriFormatter.php',
'ValueFormatters\StringFormatter' => 'src/ValueFormatters/StringFormatter.php',
'ValueFormatters\TimeIsoFormatter' => 'src/ValueFormatters/TimeIsoFormatter.php',
'ValueFormatters\TimeFormatter' => 'src/ValueFormatters/TimeFormatter.php',

'ValueFormatters\Test\ValueFormatterFactoryTest' => 'tests/ValueFormatters/ValueFormatterFactoryTest.php',



'ValueParsers\ValueParserFactory' => 'src/ValueParsers/ValueParserFactory.php',
'ValueParsers\ApiParseValue' => 'src/ValueParsers/ApiParseValue.php',

'ValueParsers\BoolParser' => 'src/ValueParsers/BoolParser.php',
'ValueParsers\DdCoordinateParser' => 'src/ValueParsers/DdCoordinateParser.php',
'ValueParsers\DmCoordinateParser' => 'src/ValueParsers/DmCoordinateParser.php',
'ValueParsers\DmsCoordinateParser' => 'src/ValueParsers/DmsCoordinateParser.php',
'ValueParsers\FloatCoordinateParser' => 'src/ValueParsers/FloatCoordinateParser.php',
'ValueParsers\GeoCoordinateParser' => 'src/ValueParsers/GeoCoordinateParser.php',
'ValueParsers\GeoCoordinateParserBase' => 'src/ValueParsers/GeoCoordinateParserBase.php',
'ValueParsers\GlobeCoordinateParser' => 'src/ValueParsers/GlobeCoordinateParser.php',
'ValueParsers\FloatParser' => 'src/ValueParsers/FloatParser.php',
'ValueParsers\IntParser' => 'src/ValueParsers/IntParser.php',
'ValueParsers\NullParser' => 'src/ValueParsers/NullParser.php',
'ValueParsers\StringValueParser' => 'src/ValueParsers/StringValueParser.php',

'ValueParsers\Test\StringValueParserTest' => 'tests/ValueParsers/StringValueParserTest.php',
'ValueParsers\Test\ValueParserTestBase' => 'tests/ValueParsers/ValueParserTestBase.php',



'ValueValidators\ValueValidatorFactory' => 'src/ValueValidators/ValueValidatorFactory.php',

'ValueValidators\DimensionValidator' => 'src/ValueValidators/DimensionValidator.php',
'ValueValidators\ListValidator' => 'src/ValueValidators/ListValidator.php',
'ValueValidators\NullValidator' => 'src/ValueValidators/NullValidator.php',
'ValueValidators\RangeValidator' => 'src/ValueValidators/RangeValidator.php',
'ValueValidators\StringValidator' => 'src/ValueValidators/StringValidator.php',
'ValueValidators\TitleValidator' => 'src/ValueValidators/TitleValidator.php',



'DataValues\DataValueFactory' => 'src/DataValues/DataValueFactory.php',

'DataValues\GeoCoordinateValue' => 'src/DataValues/GeoCoordinateValue.php',
'DataValues\GlobeCoordinateValue' => 'src/DataValues/GlobeCoordinateValue.php',
'DataValues\IriValue' => 'src/DataValues/IriValue.php',
'DataValues\LatLongValue' => 'src/DataValues/LatLongValue.php',
'DataValues\MonolingualTextValue' => 'src/DataValues/MonolingualTextValue.php',
'DataValues\MultilingualTextValue' => 'src/DataValues/MultilingualTextValue.php',
'DataValues\QuantityValue' => 'src/DataValues/QuantityValue.php',
'DataValues\TimeValue' => 'src/DataValues/TimeValue.php',
);
157 changes: 157 additions & 0 deletions DataValuesCommon.mw.php
@@ -0,0 +1,157 @@
<?php

/**
* @deprecated
*/
define( 'ValueFormatters_VERSION', '0.1 alpha' );

/**
* @deprecated
*/
define( 'ValueParsers_VERSION', '0.1 alpha' );

/**
* @deprecated
*/
define( 'ValueValidators_VERSION', '0.1 alpha' );

global $wgValueFormatters;

/**
* @deprecated since 0.1 This is a global registry that provides no control over object lifecycle
*/
$wgValueFormatters = array(
'globecoordinate' => 'ValueFormatters\GlobeCoordinateFormatter',
'time' => 'ValueFormatters\TimeFormatter',
'string' => 'ValueFormatters\StringFormatter',
);

global $wgValueParsers;

/**
* @deprecated since 0.1 This is a global registry that provides no control over object lifecycle
*/
$wgValueParsers = array();

$wgValueParsers['bool'] = 'ValueParsers\BoolParser';
$wgValueParsers['float'] = 'ValueParsers\FloatParser';
$wgValueParsers['globecoordinate'] = 'ValueParsers\GlobeCoordinateParser';
$wgValueParsers['int'] = 'ValueParsers\IntParser';
$wgValueParsers['null'] = 'ValueParsers\NullParser';

global $wgValueValidators;

/**
* @deprecated since 0.1 This is a global registry that provides no control over object lifecycle
*/
$wgValueValidators = array();

$wgValueValidators['range'] = 'ValueValidators\RangeValidator';

global $wgExtensionCredits, $wgAPIModules, $wgHooks, $wgValueFormatters;

$wgExtensionCredits['datavalues'][] = array(
'path' => __DIR__,
'name' => 'DataValuesCommon',
'version' => DataValuesCommon_VERSION,
'author' => array(
'[https://www.mediawiki.org/wiki/User:Jeroen_De_Dauw Jeroen De Dauw]',
'[https://www.mediawiki.org/wiki/User:Danwe Daniel Werner]',
'[http://www.snater.com H. Snater]',
),
'url' => 'https://github.com/wikimedia/mediawiki-extensions-DataValuesCommon'
);

if ( defined( 'MW_PHPUNIT_TEST' ) ) {
require_once __DIR__ . '/tests/testLoader.php';
}

// API module registration
$wgAPIModules['parsevalue'] = 'ValueParsers\ApiParseValue';

/**
* Hook to add PHPUnit test cases.
* @see https://www.mediawiki.org/wiki/Manual:Hooks/UnitTestsList
*
* @since 0.1
*
* @param array $files
*
* @return boolean
*/
$wgHooks['UnitTestsList'][] = function( array &$files ) {
// @codeCoverageIgnoreStart
$directoryIterator = new RecursiveDirectoryIterator( __DIR__ . '/tests/' );

/**
* @var SplFileInfo $fileInfo
*/
foreach ( new RecursiveIteratorIterator( $directoryIterator ) as $fileInfo ) {
if ( substr( $fileInfo->getFilename(), -8 ) === 'Test.php' ) {
$files[] = $fileInfo->getPathname();
}
}

return true;
// @codeCoverageIgnoreEnd
};

/**
* Hook to add QUnit test cases.
* @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderTestModules
* @since 0.1
*
* @param array &$testModules
* @param \ResourceLoader &$resourceLoader
* @return boolean
*/
$wgHooks['ResourceLoaderTestModules'][] = function ( array &$testModules, \ResourceLoader &$resourceLoader ) {
// @codeCoverageIgnoreStart
$moduleTemplate = array(
'localBasePath' => __DIR__ . '/js/tests/ValueParsers',
'remoteExtPath' => 'DataValues/DataValuesCommon/js/tests/ValueParsers',
);

$testModules['qunit']['ext.valueParsers.tests'] = $moduleTemplate + array(
'scripts' => array(
'ValueParser.tests.js',
),
'dependencies' => array(
'valueParsers.parsers',
),
);

$testModules['qunit']['ext.valueParsers.factory'] = $moduleTemplate + array(
'scripts' => array(
'ValueParserFactory.tests.js',
),
'dependencies' => array(
'valueParsers.factory',
'valueParsers.parsers',
),
);

$testModules['qunit']['ext.valueParsers.parsers'] = $moduleTemplate + array(
'scripts' => array(
'parsers/BoolParser.tests.js',
'parsers/GlobeCoordinateParser.tests.js',
'parsers/FloatParser.tests.js',
'parsers/IntParser.tests.js',
'parsers/StringParser.tests.js',
'parsers/TimeParser.tests.js',
'parsers/NullParser.tests.js',
),
'dependencies' => array(
'ext.valueParsers.tests',
),
);

return true;
// @codeCoverageIgnoreEnd
};

// Resource Loader module registration
$GLOBALS['wgResourceModules'] = array_merge(
$GLOBALS['wgResourceModules'],
include( __DIR__ . '/js/ValueParsers.resources.php' )
);
55 changes: 55 additions & 0 deletions DataValuesCommon.php
@@ -0,0 +1,55 @@
<?php

if ( defined( 'DataValuesCommon_VERSION' ) ) {
// Do not initialize more then once.
return;
}

define( 'DataValuesCommon_VERSION', '0.1 alpha' );

// If one of the dependencies has not been loaded yet, attempt to include the Composer autoloader.
if ( !defined( 'DataValues_VERSION' ) && is_readable( __DIR__ . '/vendor/autoload.php' ) ) {
include_once( __DIR__ . '/vendor/autoload.php' );
}

// Attempt to include the DataValues lib if that hasn't been done yet.
// This is the path the DataValues entry point will be at when loaded as MediaWiki extension.
if ( !defined( 'DataValues_VERSION' ) && is_readable( __DIR__ . '/../DataValues/DataValues.php' ) ) {
include_once( __DIR__ . '/../DataValues/DataValues.php' );
}

// Attempt to include the DataValuesInterfaces lib if that hasn't been done yet.
// This is the path its entry point will be at when loaded as MediaWiki extension.
if ( !defined( 'DataValuesInterfaces_VERSION' ) && is_readable( __DIR__ . '/../DataValuesInterfaces/DataValuesInterfaces.php' ) ) {
include_once( __DIR__ . '/../DataValuesInterfaces/DataValuesInterfaces.php' );
}

// Only initialize the extension when all dependencies are present.
if ( !defined( 'DataValues_VERSION' ) ) {
throw new Exception( 'You need to have the DataValues library loaded in order to use DataValuesCommon' );
}

// Only initialize the extension when all dependencies are present.
if ( !defined( 'DataValuesInterfaces_VERSION' ) ) {
throw new Exception( 'You need to have the DataValuesInterfaces library loaded in order to use DataValuesCommon' );
}

// @codeCoverageIgnoreStart
spl_autoload_register( function ( $className ) {
static $classes = false;

if ( $classes === false ) {
$classes = include( __DIR__ . '/' . 'DataValuesCommon.classes.php' );
}

if ( array_key_exists( $className, $classes ) ) {
include_once __DIR__ . '/' . $classes[$className];
}
} );

if ( defined( 'MEDIAWIKI' ) ) {
call_user_func( function() {
require_once __DIR__ . '/DataValuesCommon.mw.php';
} );
}
// @codeCoverageIgnoreEnd
48 changes: 48 additions & 0 deletions composer.json
@@ -0,0 +1,48 @@
{
"name": "data-values/common",
"type": "library",
"description": "Contains common implementations of the interfaces defined by DataValuesInterfaces",
"keywords": [
"datavalues",
"valueparsers",
"valueformatters",
"valuevalidators",
"wikidata"
],
"homepage": "https://github.com/wikimedia/mediawiki-extensions-DataValuesCommon",
"license": "GPL-2.0+",
"authors": [
{
"name": "Jeroen De Dauw",
"email": "jeroendedauw@gmail.com",
"homepage": "http://jeroendedauw.com",
"role": "Developer"
},
{
"name": "Daniel Werner",
"email": "danweetz@web.de",
"homepage": "https://www.mediawiki.org/wiki/User:Danwe",
"role": "Developer"
},
{
"name": "H. Snater",
"email": "mediawiki@snater.com",
"homepage": "http://www.snater.com",
"role": "Developer"
}
],
"support": {
"issues": "https://bugzilla.wikimedia.org/",
"irc": "irc://irc.freenode.net/wikimedia-wikidata"
},
"require": {
"php": ">=5.3.0",
"data-values/data-values": "dev-master",
"data-values/interfaces": "dev-master"
},
"autoload": {
"files" : [
"DataValuesCommon.php"
]
}
}

0 comments on commit d56de82

Please sign in to comment.