Page MenuHomeGitPull.it

No OneTemporary

Authored By
Unknown
Size
4 KB
Referenced Files
None
Subscribers
None
diff --git "a/include/class-wb\\DataValueMonolingualText.php" "b/include/class-wb\\DataValueMonolingualText.php"
new file mode 100644
index 0000000..0a7fc66
--- /dev/null
+++ "b/include/class-wb\\DataValueMonolingualText.php"
@@ -0,0 +1,67 @@
+<?php
+# Boz-MW - Another MediaWiki API handler in PHP
+# Copyright (C) 2019 Valerio Bozzolan
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Wikibase
+namespace wb;
+
+/**
+ * A DataValue for a monolingual text
+ *
+ * @see https://www.mediawiki.org/wiki/Wikibase/DataModel#Monolingual_texts
+ */
+class DataValueMonolingualText extends DataValue {
+
+ /**
+ * Constructor
+ *
+ * @param string $language Language (e.g. 'it', 'en', ...)
+ * @param string $text Text
+ */
+ public function __construct( $language, $text ) {
+ parent::__construct( DataType::MONOLINGUAL_TEXT, [
+ 'text' => $text,
+ 'language' => $language,
+ ] );
+ }
+
+ /**
+ * Get the text
+ *
+ * @return string
+ */
+ public function getText() {
+ return $this->getValue()->text;
+ }
+
+ /**
+ * Get the language
+ *
+ * @return string
+ */
+ public function getLanguage() {
+ return $this->getValue()->language;
+ }
+
+ /**
+ * @return string
+ */
+ public function __toString() {
+ $text = $this->getText();
+ $language = $this->getLanguage();
+ return "$text [$language]";
+ }
+}
diff --git "a/include/class-wb\\SnakMonolingualText.php" "b/include/class-wb\\SnakMonolingualText.php"
new file mode 100644
index 0000000..ac4d273
--- /dev/null
+++ "b/include/class-wb\\SnakMonolingualText.php"
@@ -0,0 +1,43 @@
+<?php
+# Boz-MW - Another MediaWiki API handler in PHP
+# Copyright (C) 2019 Valerio Bozzolan
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Wikibase
+namespace wb;
+
+/**
+ * A Snak for a monolingual text
+ *
+ * @see https://www.mediawiki.org/wiki/Wikibase/DataModel#Monolingual_texts
+ */
+class SnakMonolingualText extends Snak {
+
+ /**
+ * Constructor
+ *
+ * @param string $property Wikidata property as 'P123'
+ * @param string $lang Language (e.g. 'it', 'en')
+ * @param string $text Text
+ */
+ public function __construct( $property, $lang, $text ) {
+ return parent::__construct(
+ 'value',
+ $property,
+ DataType::MONOLINGUAL_TEXT,
+ new DataValueMonolingualText( $lang, $text )
+ );
+ }
+}
diff --git "a/include/class-wb\\StatementMonolingualText.php" "b/include/class-wb\\StatementMonolingualText.php"
new file mode 100644
index 0000000..73efeb5
--- /dev/null
+++ "b/include/class-wb\\StatementMonolingualText.php"
@@ -0,0 +1,39 @@
+<?php
+# Boz-MW - Another MediaWiki API handler in PHP
+# Copyright (C) 2019 Valerio Bozzolan
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Wikibase
+namespace wb;
+
+/**
+ * Statement suitable for a monolingual text
+ *
+ * @see https://www.mediawiki.org/wiki/Wikibase/DataModel#Monolingual_text
+ */
+class StatementMonolingualText extends Statement {
+
+ /**
+ * Constructor
+ *
+ * @param string $property Wikidata property as 'P123'
+ * @param string $lang Language (e.g. 'it', 'en')
+ * @param string $text Text
+ */
+ public function __construct( $property, $language, $text ) {
+ parent::__construct( new SnakMonolingualText( $property, $language, $text ) );
+ }
+
+}

File Metadata

Mime Type
text/x-diff
Expires
Thu, Nov 19, 03:04 (7 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2264069
Default Alt Text
(4 KB)

Event Timeline