diff options
author | Alex Legler <alex@a3li.li> | 2014-12-23 17:49:26 +0100 |
---|---|---|
committer | Alex Legler <alex@a3li.li> | 2014-12-23 17:49:26 +0100 |
commit | e352fff59842ca14fbfd81ee1c4a64297bb598c5 (patch) | |
tree | 153f268484aa5cc41cacf912bdce8c4847df222d /GentooToolbox/properties | |
download | extensions-e352fff59842ca14fbfd81ee1c4a64297bb598c5.tar.gz extensions-e352fff59842ca14fbfd81ee1c4a64297bb598c5.tar.bz2 extensions-e352fff59842ca14fbfd81ee1c4a64297bb598c5.zip |
Add initial set of additional extensions
Diffstat (limited to 'GentooToolbox/properties')
-rw-r--r-- | GentooToolbox/properties/TranslationProperties.body.php | 54 | ||||
-rw-r--r-- | GentooToolbox/properties/TranslationProperties.i18n.php | 14 |
2 files changed, 68 insertions, 0 deletions
diff --git a/GentooToolbox/properties/TranslationProperties.body.php b/GentooToolbox/properties/TranslationProperties.body.php new file mode 100644 index 00000000..517059f3 --- /dev/null +++ b/GentooToolbox/properties/TranslationProperties.body.php @@ -0,0 +1,54 @@ +<?php +/** + * GentooToolbox + * + * @ingroup Extensions + * @author Alex Legler <a3li@gentoo.org> + * @version 1.0 + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later + */ + +class GTBXTranslationProperties { + + public static function setupProperties() { + SMWDIProperty::registerProperty('___LANG', '_str', wfMsgForContent('gtbx-prop-lang')); + SMWDIProperty::registerPropertyAlias('___LANG', 'Language'); + + SMWDIProperty::registerProperty('___TRANS', '_boo', wfMsgForContent('gtbx-prop-trans')); + SMWDIProperty::registerPropertyAlias('___TRANS', 'Is Translation Page'); + + return true; + } + + public function updateDataBefore($store, $data) { + $subject = $data->getSubject(); + $title = Title::makeTitle($subject->getNamespace(), $subject->getDBKey()); + $wikipage = WikiPage::factory($title); + + if (is_null($title) || is_null($wikipage)) { + return true; + } + + // Property 1: Is translation page + $property = new SMWDIProperty('___TRANS'); + $is_translation_page = !(TranslatablePage::isTranslationPage($title) === false); + $data_item = new SMWDIBoolean($is_translation_page); + + $data->addPropertyObjectValue($property, $data_item); + + // Property 2: Language? + $property = new SMWDIProperty('___LANG'); + global $wgLanguageCode; + $language_code = $wgLanguageCode; + + if ($is_translation_page) { + list( , $code ) = TranslateUtils::figureMessage( $title->getText() ); + $language_code = $code; + } + + $data_item = new SMWDIString($language_code); + + $data->addPropertyObjectValue($property, $data_item); + + } +} diff --git a/GentooToolbox/properties/TranslationProperties.i18n.php b/GentooToolbox/properties/TranslationProperties.i18n.php new file mode 100644 index 00000000..ae8a4dfb --- /dev/null +++ b/GentooToolbox/properties/TranslationProperties.i18n.php @@ -0,0 +1,14 @@ +<?php +/** + * GentooToolbox + * + * @ingroup Extensions + * @author Alex Legler <a3li@gentoo.org> + * @version 1.0 + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later + */ + +$messages['en'] = array( + 'gtbx-prop-lang' => 'Language', + 'gtbx-prop-trans' => 'Is Translation Page', +); |