jenkins-bot has submitted this change and it was merged.
Change subject: Added abstract JCDataContent
......................................................................
Added abstract JCDataContent
The new class will be the base for geojson & tabular.
It supports license and localized information fields.
Change-Id: I3e6b8c3eb38855403587f7defdbd99025a4d0e76
---
M JsonConfig.php
A includes/JCDataContent.php
M modules/JsonConfig.css
3 files changed, 62 insertions(+), 0 deletions(-)
Approvals:
MaxSem: Looks good to me, approved
jenkins-bot: Verified
diff --git a/JsonConfig.php b/JsonConfig.php
index 16c9022..2ced91c 100644
--- a/JsonConfig.php
+++ b/JsonConfig.php
@@ -46,6 +46,7 @@
'JCContent',
'JCContentHandler',
'JCContentView',
+ 'JCDataContent',
'JCDefaultContentView',
'JCDefaultObjContentView',
'JCObjContent',
diff --git a/includes/JCDataContent.php b/includes/JCDataContent.php
new file mode 100644
index 0000000..f9ae379
--- /dev/null
+++ b/includes/JCDataContent.php
@@ -0,0 +1,56 @@
+<?php
+
+namespace JsonConfig;
+
+use Html;
+use ParserOptions;
+use ParserOutput;
+use Title;
+
+/**
+ * @package JsonConfig
+ */
+abstract class JCDataContent extends JCObjContent {
+
+ /**
+ * Derived classes must implement this method to perform custom
validation
+ * using the check(...) calls
+ */
+ public function validateContent() {
+
+ if ( !$this->thorough() ) {
+ // We are not doing any modifications to the original,
so no need to validate it
+ return;
+ }
+
+ // TODO: handle well-known licenses and link to them
+ $this->test( 'license', JCValidators::isString() );
+ $this->test( 'info', JCValidators::isLocalizedString() );
+ }
+
+ public function renderInfo( $lang ) {
+ $info = $this->getField( 'info' );
+
+ if ( $info && !$info->error() ) {
+ $info = JCUtils::pickLocalizedString(
$info->getValue(), $lang );
+ $html = Html::element( 'p', [ 'class' =>
'mw-jsonconfig-info' ], $info );
+ } else {
+ $html = '';
+ }
+
+ return $html;
+ }
+
+ public function renderLicense() {
+ $license = $this->getField( 'license' );
+
+ if ( $license && !$license->error() ) {
+ $html = Html::element( 'p', [ 'class' =>
'mw-jsonconfig-license' ],
+ $license->getValue() );
+ } else {
+ $html = '';
+ }
+
+ return $html;
+ }
+}
diff --git a/modules/JsonConfig.css b/modules/JsonConfig.css
index 019c310..1923da3 100644
--- a/modules/JsonConfig.css
+++ b/modules/JsonConfig.css
@@ -29,6 +29,11 @@
font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco,
Courier, monospace;
}
+.mw-jsonconfig-info, .mw-jsonconfig-license {
+ display: inline-block;
+ font-style: italic;
+}
+
.mw-jsonconfig tr {
margin-bottom: 0.5em;
}
--
To view, visit https://gerrit.wikimedia.org/r/282987
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3e6b8c3eb38855403587f7defdbd99025a4d0e76
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/JsonConfig
Gerrit-Branch: master
Gerrit-Owner: Yurik <[email protected]>
Gerrit-Reviewer: MaxSem <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits