summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticFormsSelect
diff options
context:
space:
mode:
authorYaco <franco@reevo.org>2020-06-04 11:01:00 -0300
committerYaco <franco@reevo.org>2020-06-04 11:01:00 -0300
commitfc7369835258467bf97eb64f184b93691f9a9fd5 (patch)
treedaabd60089d2dd76d9f5fb416b005fbe159c799d /www/wiki/extensions/SemanticFormsSelect
first commit
Diffstat (limited to 'www/wiki/extensions/SemanticFormsSelect')
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/.gitignore11
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/.scrutinizer.yml28
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/.travis.yml38
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/COPYING103
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/ISSUE_TEMPLATE.md18
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/README.md101
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/RELEASE-NOTES.md91
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/SemanticFormsSelect.hooks.php38
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/composer.json64
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/extension.json63
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/i18n/ar.json8
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/i18n/ast.json8
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/i18n/be-tarask.json8
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/i18n/be.json8
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/i18n/br.json8
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/i18n/ca.json8
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/i18n/de.json8
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/i18n/en.json9
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/i18n/es.json8
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/i18n/fr.json8
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/i18n/gl.json8
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/i18n/ia.json8
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/i18n/li.json8
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/i18n/mk.json8
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/i18n/nb.json8
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/i18n/nl.json8
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/i18n/pl.json8
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/i18n/pt-br.json8
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/i18n/pt.json8
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/i18n/qqq.json9
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/i18n/roa-tara.json8
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/i18n/ru.json8
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/i18n/sr-ec.json8
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/i18n/tr.json8
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/i18n/uk.json8
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/i18n/zh-hans.json8
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/i18n/zh-hant.json9
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/phpunit.xml.dist28
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/res/scriptSelect.js490
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/res/select2.css42
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/res/select2.pngbin0 -> 613 bytes
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/src/ApiSemanticFormsSelect.php94
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/src/ApiSemanticFormsSelectRequestProcessor.php149
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/src/Output.php47
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/src/SelectField.php210
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/src/SemanticFormsSelectInput.php307
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/tests/bootstrap.php29
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/ApiSemanticFormsSelectRequestProcessorTest.php134
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/ApiSemanticFormsSelectTest.php95
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/OutputTest.php50
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/SelectFieldTest.php270
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/SemanticFormsSelectInputTest.php84
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/tests/travis/install-mediawiki.sh43
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/tests/travis/install-semantic-forms-select.sh73
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/tests/travis/run-tests.sh14
-rw-r--r--www/wiki/extensions/SemanticFormsSelect/tests/travis/upload-coverage-report.sh10
56 files changed, 2943 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticFormsSelect/.gitignore b/www/wiki/extensions/SemanticFormsSelect/.gitignore
new file mode 100644
index 00000000..0745b001
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/.gitignore
@@ -0,0 +1,11 @@
+*~
+*.kate-swp
+
+vendor/
+extensions/
+
+composer.phar
+composer.lock
+
+!.*
+.idea/ \ No newline at end of file
diff --git a/www/wiki/extensions/SemanticFormsSelect/.scrutinizer.yml b/www/wiki/extensions/SemanticFormsSelect/.scrutinizer.yml
new file mode 100644
index 00000000..6f59b5cb
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/.scrutinizer.yml
@@ -0,0 +1,28 @@
+filter:
+ excluded_paths:
+ - 'vendor/*'
+
+tools:
+ php_mess_detector:
+ config:
+ controversial_rules: { superglobals: false }
+ php_cpd: true
+ php_pdepend: true
+ php_code_coverage: false
+ php_code_sniffer: true
+ php_cs_fixer: true
+ php_loc: true
+ php_analyzer: true
+ sensiolabs_security_checker: true
+ external_code_coverage:
+ timeout: '900'
+
+checks:
+ php:
+ psr2_class_declaration: false
+ psr2_switch_declaration: false
+ sql_injection_vulnerabilities: true
+ security_vulnerabilities: true
+ no_eval: true
+ code_rating: true
+ duplication: true
diff --git a/www/wiki/extensions/SemanticFormsSelect/.travis.yml b/www/wiki/extensions/SemanticFormsSelect/.travis.yml
new file mode 100644
index 00000000..c1c2a52f
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/.travis.yml
@@ -0,0 +1,38 @@
+# http://docs.travis-ci.com/user/workers/container-based-infrastructure/
+sudo: false
+
+language: php
+
+# https://docs.travis-ci.com/user/trusty-ci-environment/
+dist: trusty
+
+matrix:
+ fast_finish: true
+ include:
+ - env: DB=mysql; MW=REL1_30; PHPUNIT=5.7.*
+ php: 7.0
+ - env: DB=mysql; MW=REL1_27; TYPE=coverage
+ php: 5.6
+ - env: DB=sqlite; MW=REL1_27;
+ php: 5.6
+ - env: DB=mysql; MW=master; PHPUNIT=4.8.*
+ php: hhvm
+
+install:
+ - bash ./tests/travis/install-mediawiki.sh
+ - bash ./tests/travis/install-semantic-forms-select.sh
+
+script:
+ - bash ./tests/travis/run-tests.sh
+
+after_success:
+ - bash ./tests/travis/upload-coverage-report.sh
+
+notifications:
+ email:
+ on_success: change
+ on_failure: always
+
+cache:
+ directories:
+ - $HOME/.composer/cache
diff --git a/www/wiki/extensions/SemanticFormsSelect/COPYING b/www/wiki/extensions/SemanticFormsSelect/COPYING
new file mode 100644
index 00000000..9dcf3f86
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/COPYING
@@ -0,0 +1,103 @@
+'''[https://github.com/SemanticMediaWiki/SemanticFormsSelect Semantic Forms Select (SFS)]''' is a free, open-source extension to Semantic MediaWiki that adds in-page navigation by building breadcrumb links from an attributive property filter.
+
+Copyright (C) 2014
+
+
+The license text below "====" applies to all files within this distribution, other than those that are in a directory which contains files named "LICENSE" or "COPYING", or a subdirectory thereof. For those files, the license text contained in said file overrides any license information contained in directories of smaller depth. Alternative licenses are typically used for software that is provided by external parties, and merely packaged with this extension for convenience.
+----
+----
+
+== GNU GENERAL PUBLIC LICENSE ==
+Version 2, June 1991
+
+Copyright (C) 1989, 1991 Free Software Foundation, Inc.,<br />
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Everyone is permitted to copy and distribute verbatim copies<br />
+of this license document, but changing it is not allowed.
+
+=== Preamble ===
+The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software - to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too.
+
+When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
+
+To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
+
+For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
+
+We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
+
+Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
+
+The precise terms and conditions for copying, distribution and modification follow.
+
+=== TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION ===
+
+'''0.''' This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
+
+'''1.''' You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
+
+'''2.''' You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
+
+: '''a)''' You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
+
+: '''b)''' You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
+
+: '''c)''' If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
+
+'''3.''' You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
+
+: '''a)''' Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
+
+: '''b)''' Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
+
+: '''c)''' Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
+
+If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
+
+'''4.''' You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
+
+'''5.''' You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
+
+'''6.''' Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
+
+'''7.''' If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot impose that choice.
+
+This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
+
+'''8.''' If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
+
+'''9.''' The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
+
+'''10.''' If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
+
+'''<big>NO WARRANTY</big>'''
+
+'''11.''' BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+'''12.''' IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+'''<big>END OF TERMS AND CONDITIONS</big>'''
diff --git a/www/wiki/extensions/SemanticFormsSelect/ISSUE_TEMPLATE.md b/www/wiki/extensions/SemanticFormsSelect/ISSUE_TEMPLATE.md
new file mode 100644
index 00000000..01509cee
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/ISSUE_TEMPLATE.md
@@ -0,0 +1,18 @@
+### Setup
+
+- MW version:
+- DB (MySQL etc.):
+- PHP version:
+- SMW version:
+- SFS version:
+- PF version:
+- Browsers and versions (if applicable):
+
+### Issue
+
+Detailed description of the issue and a [stack trace](https://www.semantic-mediawiki.org/wiki/Help:Identifying_bugs) if applicable:
+
+```
+```
+
+Steps to reproduce the observation (recommendation is to use the [sandbox](https://sandbox.semantic-mediawiki.org)):
diff --git a/www/wiki/extensions/SemanticFormsSelect/README.md b/www/wiki/extensions/SemanticFormsSelect/README.md
new file mode 100644
index 00000000..fc43b2ef
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/README.md
@@ -0,0 +1,101 @@
+# Semantic Forms Select
+
+[![Build Status](https://secure.travis-ci.org/SemanticMediaWiki/SemanticFormsSelect.svg?branch=master)](http://travis-ci.org/SemanticMediaWiki/SemanticFormsSelect)
+[![Code Coverage](https://scrutinizer-ci.com/g/SemanticMediaWiki/SemanticFormsSelect/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/SemanticMediaWiki/SemanticFormsSelect/?branch=master)
+[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/SemanticMediaWiki/SemanticFormsSelect/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/SemanticMediaWiki/SemanticFormsSelect/?branch=master)
+[![Latest Stable Version](https://poser.pugx.org/mediawiki/semantic-forms-select/version.png)](https://packagist.org/packages/mediawiki/semantic-forms-select)
+[![Packagist download count](https://poser.pugx.org/mediawiki/semantic-forms-select/d/total.png)](https://packagist.org/packages/mediawiki/semantic-forms-select)
+
+Semantic Forms Select (a.k.a. SFS) can generate a select form element with values retrieved from a `#ask` query or a parser function.
+
+## Requirements
+
+- PHP 5.6 or later
+- MediaWiki 1.27 or later
+- [Semantic MediaWiki][smw] 2.5 or later
+- [Page Forms][pf] 4.0.2 or later
+
+## Installation
+
+The recommended way to install Semantic Forms Select is using [Composer](http://getcomposer.org) with
+[MediaWiki's built-in support for Composer](https://www.mediawiki.org/wiki/Composer).
+
+Note that the required extensions Semantic MediaWiki and Page Forms must be installed first according to the installation
+instructions provided for them.
+
+### Step 1
+
+Change to the base directory of your MediaWiki installation. This is where the "LocalSettings.php"
+file is located. If you have not yet installed Composer do it now by running the following command
+in your shell:
+
+ wget https://getcomposer.org/composer.phar
+
+### Step 2
+
+If you do not have a "composer.local.json" file yet, create one and add the following content to it:
+
+```
+{
+ "require": {
+ "mediawiki/semantic-forms-select": "~3.0"
+ }
+}
+```
+
+If you already have a "composer.local.json" file add the following line to the end of the "require"
+section in your file:
+
+ "mediawiki/semantic-forms-select": "~3.0"
+
+Remember to add a comma to the end of the preceding line in this section.
+
+### Step 3
+
+Run the following command in your shell:
+
+ php composer.phar update --no-dev
+
+Note if you have Git installed on your system add the `--prefer-source` flag to the above command. Also
+note that it may be necessary to run this command twice. If unsure do it twice right away.
+
+### Step 4
+
+Add the following line to the end of your "LocalSettings.php" file:
+
+ wfLoadExtension( 'SemanticFormsSelect' );
+
+### Verify installation success
+
+As final step, you can verify SFS got installed by looking at the "Special:Version" page on your wiki and check that it is listed in the semantic extensions section.
+
+## Usage
+
+Please consult the [help](https://www.mediawiki.org/wiki/Extension:SemanticFormsSelect) page for more information and examples.
+
+## Contribution and support
+
+If you want to contribute work to the project please subscribe to the developers mailing list and
+have a look at the contribution guideline.
+
+* [File an issue](https://github.com/SemanticMediaWiki/SemanticFormsSelect/issues)
+* [Submit a pull request](https://github.com/SemanticMediaWiki/SemanticFormsSelect/pulls)
+* Ask a question on [the mailing list](https://www.semantic-mediawiki.org/wiki/Mailing_list)
+* Ask a question on the #semantic-mediawiki IRC channel on Freenode.
+
+Original code from https://code.google.com/p/semanticformsselect/downloads/list
+
+## Tests
+
+This extension provides unit and integration tests that are run by a [continues integration platform][travis]
+but can also be executed using `composer phpunit` from the extension base directory.
+
+## License
+
+[GNU General Public License, version 2 or later][gpl-licence].
+
+[gpl-licence]: https://www.gnu.org/copyleft/gpl.html
+[smw]: https://github.com/SemanticMediaWiki/SemanticMediaWiki
+[travis]: https://travis-ci.org/SemanticMediaWiki/SemanticFormsSelect
+[pf]: https://www.mediawiki.org/wiki/Extension:Page_Forms
+[composer]: https://getcomposer.org/
diff --git a/www/wiki/extensions/SemanticFormsSelect/RELEASE-NOTES.md b/www/wiki/extensions/SemanticFormsSelect/RELEASE-NOTES.md
new file mode 100644
index 00000000..eaa06a68
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/RELEASE-NOTES.md
@@ -0,0 +1,91 @@
+This file contains the RELEASE-NOTES of the Semantic Forms Select (a.k.a. SFS) extension.
+
+### 3.0.0
+
+Released on October 5, 2018.
+
+* Dropped support for Semantic MediaWiki 2.4 and lower
+* Dropped support for PHP 5.5 and lower
+* #53 Added support for "mapping property" / "mapping template" in value fields (by Alexander Gesinn)
+* #62 Added support for recent versions of the Page Forms extension (by Alexander Gesinn)
+* Added styles to make single values fields appear like the combobox input type of Page Forms (by Alexander Gesinn)
+* Added handling for the checkbox input type of Page Forms (by Alexander Gesinn)
+* Refactored SemanticFormsSelectInput class -> moved logic to new SelectField class (by Alexander Gesinn)
+* Added Unit Tests (by Felix Ashu)
+* Provided translation updates (by TranslateWiki.net community)
+
+### 2.1.1
+
+Released on June 27, 2017.
+
+* Fixed incorrect version numbering
+* #64 Updated version constraints for requied dependeny Page Forms
+* Provided translation updates (by TranslateWiki.net community)
+
+### 2.1.0
+
+Released on January 19, 2017.
+
+* #54 Fixed select fields no to update for an existing page (by Alexander Gesinn)
+* #56 Fixed issue when multiple `sf_select` have the same parameter in the same page (by Toni Hermoso Pulido)
+* Provided translation updates (by TranslateWiki.net community)
+
+### 2.0.0
+
+Released on December 19, 2016.
+
+* Dropped support for MediaWiki 1.26 and lower
+* Dropped support for PHP 5.4 and lower
+* Dropped support for the Semantic Forms extension
+* Added support for the Page Forms extension
+* #29 Added support for I18n (by James Hong Kong)
+* #29 Made internal code improvements (by James Hong Kong)
+* #30 Migrated to MediaWiki 1.25 extension registration method (by James Hong Kong)
+* #31 Fixed missing input not being populated when parent input only has one value (by Pierre Rudloff)
+* #34 Added escaping for spaces in template names (by Pierre Rudloff)
+* #42, #45 Migrated extension to use the Page Forms extension instead of the Semantic Forms extension (by Thomas Mulhall and Sébastien Beyou)
+* #50 Internal code changes regarding bootstrap (by James Hong Kong)
+* Provided translation updates (by TranslateWiki.net community)
+* Updated testing environment (by Thomas Mulhall and James Hong Kong)
+
+### 1.3.0
+
+Released on November 30, 2015.
+
+* Added the `SFS` PHP namespace (by James Hong Kong)
+* Added full Composer compatibility and autoloading (PSR-4) (by James Hong Kong)
+* Added stricter control over how the `scriptSelect.js` is being used (removed JS elements from PHP) and accessed from MediaWiki (by James Hong Kong)
+* Added `ResourceLoader` support (by James Hong Kong)
+* Added unit tests and general test coverage support (by James Hong Kong)
+* Fixed parser call from `Special:FormEdit/DemoAjax1` (by James Hong Kong)
+* Provided COPYING file (by James Hong Kong)
+
+### 1.2.2
+
+Released on September 18, 2015.
+
+* Fixed options filling in internal script (by Toni Hermoso Pulido)
+
+### 1.2.0
+
+Released on September 11, 2015.
+
+* Dropped support for MediaWiki 1.22 and earlier (by Toni Hermoso Pulido)
+* Dropped support for PHP 5.2 and earlier (by Toni Hermoso Pulido)
+* Extension converted to use Composer (by Toni Hermoso Pulido)
+* Converted depreciated AJAX methods to API methods (by Toni Hermoso Pulido)
+* Add support for the Semantic Forms "mapping template" parameter (by Toni Hermoso Pulido)
+* Improved README (by Toni Hermoso Pulido)
+* Several internal improvements (by Toni Hermoso Pulido)
+
+### 1.1.0
+
+Released on Febrary 23, 2013.
+
+* Various improvements (by Jason Zhang)
+
+### 1.0.0
+
+Released on January 17, 2012.
+
+* Initial release (by Jason Zhang)
diff --git a/www/wiki/extensions/SemanticFormsSelect/SemanticFormsSelect.hooks.php b/www/wiki/extensions/SemanticFormsSelect/SemanticFormsSelect.hooks.php
new file mode 100644
index 00000000..7138c0c4
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/SemanticFormsSelect.hooks.php
@@ -0,0 +1,38 @@
+<?php
+
+namespace SFS;
+
+/**
+ * @license GNU GPL v2+
+ * @since 3.0
+ * @author: Alexander Gesinn
+ */
+class Hooks {
+ /**
+ * Register Page Forms Input Type
+ *
+ * This is attached to the MediaWiki 'ParserFirstCallInit' hook.
+ *
+ * @param $parser Parser
+ * @return bool
+ */
+ public static function onSemanticFormsSelectSetup ( & $parser ) {
+
+ if ( !defined( 'PF_VERSION' ) ) {
+ die( '<b>Error:</b><a href="https://github.com/SemanticMediaWiki/SemanticFormsSelect/">Semantic Forms Select</a> requires the <a href="https://www.mediawiki.org/wiki/Extension:PageForms">Page Forms</a> extension. Please install and activate this extension first.' );
+ }
+
+ if ( isset( $GLOBALS['wgPageFormsFormPrinter'] ) ) {
+ $GLOBALS['wgPageFormsFormPrinter']->registerInputType( \SFS\SemanticFormsSelectInput::class );
+ }
+
+ return true;
+ }
+
+ public static function onRegistration() {
+
+ if ( isset( $GLOBALS['wgAPIModules'] ) ) {
+ $GLOBALS['wgAPIModules']['sformsselect'] = \SFS\ApiSemanticFormsSelect::class;
+ }
+ }
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/composer.json b/www/wiki/extensions/SemanticFormsSelect/composer.json
new file mode 100644
index 00000000..85609b32
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/composer.json
@@ -0,0 +1,64 @@
+{
+ "name": "mediawiki/semantic-forms-select",
+ "type": "mediawiki-extension",
+ "description": "Allows to generate a select field in a form whose values are retrieved from a query",
+ "keywords": [
+ "MediaWiki",
+ "SMW",
+ "Semantic MediaWiki",
+ "Page Forms"
+ ],
+ "homepage": "https://www.mediawiki.org/wiki/Extension:SemanticFormsSelect",
+ "license": "GPL-2.0-or-later",
+ "authors": [
+ {
+ "name": "Jason Zhang",
+ "role": "Creator"
+ },
+ {
+ "name": "Toni Hermoso Pulido",
+ "role": "Developer"
+ },
+ {
+ "name": "James Hong Kong",
+ "role": "Developer"
+ },
+ {
+ "name": "Thomas Mulhall",
+ "role": "Developer"
+ },
+ {
+ "name": "Alexander Gesinn",
+ "role": "Developer"
+ },
+ {
+ "name": "Felix Ashu",
+ "role": "Developer"
+ }
+ ],
+ "require": {
+ "php": ">=5.6",
+ "composer/installers": "1.*,>=1.0.1",
+ "mediawiki/semantic-media-wiki": "~2.5|~3.0",
+ "mediawiki/page-forms": ">=4.0.2"
+ },
+ "require-dev": {
+ "mediawiki/semantic-media-wiki": "@dev"
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "SFS\\": "src/"
+ }
+ },
+ "config": {
+ "process-timeout": 0
+ },
+ "scripts":{
+ "phpunit": "php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist"
+ }
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/extension.json b/www/wiki/extensions/SemanticFormsSelect/extension.json
new file mode 100644
index 00000000..bacfb313
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/extension.json
@@ -0,0 +1,63 @@
+{
+ "name": "Semantic Forms Select",
+ "version": "3.0.0",
+ "author": [
+ "Jason Zhang",
+ "James Hong Kong",
+ "Toni Hermoso Pulido",
+ "Thomas Mulhall",
+ "Alexander Gesinn",
+ "[https://github.com/SemanticMediaWiki/SemanticFormsSelect/graphs/contributors ...]"
+ ],
+ "url": "https://www.mediawiki.org/wiki/Extension:SemanticFormsSelect",
+ "descriptionmsg": "sfs-desc",
+ "license-name": "GPL-2.0-or-later",
+ "type": "semantic",
+ "requires": {
+ "MediaWiki": ">= 1.27"
+ },
+ "AutoloadClasses": {
+ "SFS\\Hooks": "SemanticFormsSelect.hooks.php",
+ "SFS\\SemanticFormsSelectInput": "src/SemanticFormsSelectInput.php",
+ "SFS\\Output": "src/Output.php",
+ "SFS\\SelectField": "src/SelectField.php",
+ "SFS\\ApiSemanticFormsSelectRequestProcessor": "src/ApiSemanticFormsSelectRequestProcessor.php",
+ "SFS\\ApiSemanticFormsSelect": "src/ApiSemanticFormsSelect.php"
+ },
+ "config": {
+ "ScriptSelectCount": 0,
+ "SF_Select_debug": false
+ },
+ "callback": "SFS\\Hooks::onRegistration",
+ "MessagesDirs": {
+ "SemanticFormsSelect": [
+ "i18n"
+ ]
+ },
+ "ResourceModules": {
+ "ext.sf_select.scriptselect": {
+ "scripts": [
+ "res/scriptSelect.js"
+ ],
+ "styles": [
+ "res/select2.css"
+ ],
+ "dependencies": [
+ "ext.pageforms.main",
+ "ext.pageforms.select2"
+ ],
+ "position": "bottom"
+ }
+ },
+ "ResourceFileModulePaths": {
+ "localBasePath": "",
+ "remoteExtPath": "SemanticFormsSelect"
+ },
+ "Hooks": {
+ "ParserFirstCallInit": [
+ "SFS\\Hooks::onSemanticFormsSelectSetup"
+ ]
+ },
+ "load_composer_autoloader":true,
+ "manifest_version": 1
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/i18n/ar.json b/www/wiki/extensions/SemanticFormsSelect/i18n/ar.json
new file mode 100644
index 00000000..df82a4c7
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/i18n/ar.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "ديفيد"
+ ]
+ },
+ "sfs-desc": "يسمح بتوليد حقل محدد في نموذج تم استرداد قيمه من استعلام"
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/i18n/ast.json b/www/wiki/extensions/SemanticFormsSelect/i18n/ast.json
new file mode 100644
index 00000000..20cae269
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/i18n/ast.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Xuacu"
+ ]
+ },
+ "sfs-desc": "Permite xenerar un campu de selección nun formulariu, nel que los valores sáquense d'una consulta"
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/i18n/be-tarask.json b/www/wiki/extensions/SemanticFormsSelect/i18n/be-tarask.json
new file mode 100644
index 00000000..69c05275
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/i18n/be-tarask.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Red Winged Duck"
+ ]
+ },
+ "sfs-desc": "Дазваляе стварыць поле выбару на форме, чые значэньні будуць узятыя з запыту"
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/i18n/be.json b/www/wiki/extensions/SemanticFormsSelect/i18n/be.json
new file mode 100644
index 00000000..507fc725
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/i18n/be.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Mechanizatar"
+ ]
+ },
+ "sfs-desc": "Дазваляе стварыць поле выбару на форме. Значэнні будуць узятыя з запыту"
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/i18n/br.json b/www/wiki/extensions/SemanticFormsSelect/i18n/br.json
new file mode 100644
index 00000000..185c8b5b
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/i18n/br.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Fulup"
+ ]
+ },
+ "sfs-desc": "Aotren a ra sevel ur roll-desachañ en ur furmskrid gant ar roadennoù distroet diwar ur reked"
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/i18n/ca.json b/www/wiki/extensions/SemanticFormsSelect/i18n/ca.json
new file mode 100644
index 00000000..809e791b
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/i18n/ca.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Toniher"
+ ]
+ },
+ "sfs-desc": "Permet generar un camp select en un formulari amb els valors retornats d'una consulta"
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/i18n/de.json b/www/wiki/extensions/SemanticFormsSelect/i18n/de.json
new file mode 100644
index 00000000..cb367f76
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/i18n/de.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Kghbln"
+ ]
+ },
+ "sfs-desc": "Ermöglicht Eingabefelder innerhalb eines Formulars, deren zur Auswahl stehenden Werte mit einer semantischen Abfrage ermittelt werden"
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/i18n/en.json b/www/wiki/extensions/SemanticFormsSelect/i18n/en.json
new file mode 100644
index 00000000..fdf3eee2
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/i18n/en.json
@@ -0,0 +1,9 @@
+{
+ "@metadata": {
+ "authors": [
+ "kghbln",
+ "mwjames"
+ ]
+ },
+ "sfs-desc": "Allows to generate a select field in a form whose values are retrieved from a query"
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/i18n/es.json b/www/wiki/extensions/SemanticFormsSelect/i18n/es.json
new file mode 100644
index 00000000..d5d66dc9
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/i18n/es.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Fitoschido"
+ ]
+ },
+ "sfs-desc": "Permite generar campos de selección en formularios, cuyos valores se recuperan de una consulta"
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/i18n/fr.json b/www/wiki/extensions/SemanticFormsSelect/i18n/fr.json
new file mode 100644
index 00000000..2c17bb5c
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/i18n/fr.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Seb35"
+ ]
+ },
+ "sfs-desc": "Permet de générer une liste déroulante dans un formulaire, liste dont les valeurs proviennent d’une requête"
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/i18n/gl.json b/www/wiki/extensions/SemanticFormsSelect/i18n/gl.json
new file mode 100644
index 00000000..f9b4a47d
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/i18n/gl.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Elisardojm"
+ ]
+ },
+ "sfs-desc": "Permite xerar un campo de selección nun formulario cuxos valores son recuperados dunha consulta"
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/i18n/ia.json b/www/wiki/extensions/SemanticFormsSelect/i18n/ia.json
new file mode 100644
index 00000000..ea044384
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/i18n/ia.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "McDutchie"
+ ]
+ },
+ "sfs-desc": "Permitte generar un campo de selection in un formulario, con valores proveniente de un consulta"
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/i18n/li.json b/www/wiki/extensions/SemanticFormsSelect/i18n/li.json
new file mode 100644
index 00000000..54fc4493
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/i18n/li.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Ooswesthoesbes"
+ ]
+ },
+ "sfs-desc": "Maak 't meugelik e silleksjeveld in e formeleer aan te make wovan de waerd waere opgehaold oet e verzeuk"
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/i18n/mk.json b/www/wiki/extensions/SemanticFormsSelect/i18n/mk.json
new file mode 100644
index 00000000..6de22e16
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/i18n/mk.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Bjankuloski06"
+ ]
+ },
+ "sfs-desc": "Овозможува создавање на изборно поле во облик чии вредности се добиваат со побарување"
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/i18n/nb.json b/www/wiki/extensions/SemanticFormsSelect/i18n/nb.json
new file mode 100644
index 00000000..31bfc791
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/i18n/nb.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Jon Harald Søby"
+ ]
+ },
+ "sfs-desc": "Gjør det mulig å generere et select-felt i et skjema hvis verdier hentes fra en spørring"
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/i18n/nl.json b/www/wiki/extensions/SemanticFormsSelect/i18n/nl.json
new file mode 100644
index 00000000..c9e486a1
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/i18n/nl.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Rcdeboer"
+ ]
+ },
+ "sfs-desc": "Maakt het mogelijk een selectieveld in een formulier te genereren waarvan de waarden worden opgehaald uit een query"
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/i18n/pl.json b/www/wiki/extensions/SemanticFormsSelect/i18n/pl.json
new file mode 100644
index 00000000..97a52903
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/i18n/pl.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Chrumps"
+ ]
+ },
+ "sfs-desc": "Umożliwia tworzenie pola wyboru w formularzu, którego wartości są pobierane z zapytania"
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/i18n/pt-br.json b/www/wiki/extensions/SemanticFormsSelect/i18n/pt-br.json
new file mode 100644
index 00000000..36ce7c8c
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/i18n/pt-br.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "!Silent"
+ ]
+ },
+ "sfs-desc": "Permite gerar um campo de seleção em um formulário cujos valores são recuperados de uma consulta"
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/i18n/pt.json b/www/wiki/extensions/SemanticFormsSelect/i18n/pt.json
new file mode 100644
index 00000000..41d938d6
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/i18n/pt.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Hamilton Abreu"
+ ]
+ },
+ "sfs-desc": "Permite gerar num formulário um campo de seleção cujos valores são obtidos com uma consulta"
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/i18n/qqq.json b/www/wiki/extensions/SemanticFormsSelect/i18n/qqq.json
new file mode 100644
index 00000000..895630e0
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/i18n/qqq.json
@@ -0,0 +1,9 @@
+{
+ "@metadata": {
+ "authors": [
+ "Kghbln",
+ "Mwjames"
+ ]
+ },
+ "sfs-desc": "{{desc|name=SemanticFormsSelect|url=https://www.mediawiki.org/wiki/Extension:SemanticFormsSelect}}"
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/i18n/roa-tara.json b/www/wiki/extensions/SemanticFormsSelect/i18n/roa-tara.json
new file mode 100644
index 00000000..6d7485de
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/i18n/roa-tara.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Joetaras"
+ ]
+ },
+ "sfs-desc": "Face ccrejà 'nu cambe scacchiate jndr'à 'nu module cu le valore ca onne state pigghiate da 'n'inderrogazione"
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/i18n/ru.json b/www/wiki/extensions/SemanticFormsSelect/i18n/ru.json
new file mode 100644
index 00000000..02a83317
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/i18n/ru.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Kareyac"
+ ]
+ },
+ "sfs-desc": "Позволяет создать выбор поля в форме, значения которых извлекаются из запроса."
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/i18n/sr-ec.json b/www/wiki/extensions/SemanticFormsSelect/i18n/sr-ec.json
new file mode 100644
index 00000000..148f6b9f
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/i18n/sr-ec.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Obsuser"
+ ]
+ },
+ "sfs-desc": "Омогућава генерисање поља за одабир у форми чије вредности се враћају из упита"
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/i18n/tr.json b/www/wiki/extensions/SemanticFormsSelect/i18n/tr.json
new file mode 100644
index 00000000..f6def0c1
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/i18n/tr.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Hedda"
+ ]
+ },
+ "sfs-desc": "Değerleri sorgudan alınan bir formda bir seçim alanı oluşturulmasına izin verir."
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/i18n/uk.json b/www/wiki/extensions/SemanticFormsSelect/i18n/uk.json
new file mode 100644
index 00000000..7a076673
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/i18n/uk.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Piramidion"
+ ]
+ },
+ "sfs-desc": "Дозволяє згенерувати вибір поля у формі, чиї значення отримуються із запиту"
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/i18n/zh-hans.json b/www/wiki/extensions/SemanticFormsSelect/i18n/zh-hans.json
new file mode 100644
index 00000000..dae37368
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/i18n/zh-hans.json
@@ -0,0 +1,8 @@
+{
+ "@metadata": {
+ "authors": [
+ "Liuxinyu970226"
+ ]
+ },
+ "sfs-desc": "允许在从查询检索值的表单中生成选择字段"
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/i18n/zh-hant.json b/www/wiki/extensions/SemanticFormsSelect/i18n/zh-hant.json
new file mode 100644
index 00000000..a1dec29e
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/i18n/zh-hant.json
@@ -0,0 +1,9 @@
+{
+ "@metadata": {
+ "authors": [
+ "Assoc",
+ "Deathkon"
+ ]
+ },
+ "sfs-desc": "允許在從査詢檢索值的表單中生成選擇欄位"
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/phpunit.xml.dist b/www/wiki/extensions/SemanticFormsSelect/phpunit.xml.dist
new file mode 100644
index 00000000..cb226758
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/phpunit.xml.dist
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<phpunit backupGlobals="false"
+ backupStaticAttributes="false"
+ bootstrap="tests/bootstrap.php"
+ cacheTokens="false"
+ colors="true"
+ convertErrorsToExceptions="true"
+ convertNoticesToExceptions="true"
+ convertWarningsToExceptions="true"
+ stopOnError="false"
+ stopOnFailure="false"
+ stopOnIncomplete="false"
+ stopOnSkipped="false"
+ verbose="true">
+ <testsuites>
+ <testsuite name="semantic-forms-select-unit">
+ <directory>tests/phpunit/Unit</directory>
+ </testsuite>
+ <testsuite name="semantic-forms-select-integration">
+ <directory>tests/phpunit/Integration</directory>
+ </testsuite>
+ </testsuites>
+ <filter>
+ <whitelist addUncoveredFilesFromWhitelist="true">
+ <directory suffix=".php">src</directory>
+ </whitelist>
+ </filter>
+</phpunit>
diff --git a/www/wiki/extensions/SemanticFormsSelect/res/scriptSelect.js b/www/wiki/extensions/SemanticFormsSelect/res/scriptSelect.js
new file mode 100644
index 00000000..d6632d21
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/res/scriptSelect.js
@@ -0,0 +1,490 @@
+/*
+ * return a jquery pattern string to find out form fields which values will be changed
+ *
+ */
+function SFSelect_getSelectFieldPat(nameObj, f) {
+ var selectpat = "";
+ if (f.selectismultiple) {
+ if (f.selecttemplate == f.valuetemplate) {
+ // each select field in a multiple
+ // template depends on its value field.
+
+ var pat = "select[name='" + f.selecttemplate + "[" + nameObj.index + "][" + f.selectfield + "]']";
+ var pat1 = "select[name='" + f.selecttemplate + "[" + nameObj.index + "][" + f.selectfield + "][]']";
+ selectpat = pat + "," + pat1;
+ } else {
+ // multiple select fields depends on one
+ // value field.
+ selectpat = "select[name^='"
+ + f.selecttemplate
+ + "'][name$='["
+ + f.selectfield
+ + "]'], select[name^='"
+ + f.selecttemplate
+ + "'][name$='["
+ + f.selectfield + "][]']";
+ }
+
+ } else {
+ selectpat = "select[name='"
+ + f.selecttemplate + "["
+ + f.selectfield
+ + "]'], select[name='"
+ + f.selecttemplate + "["
+ + f.selectfield + "][]']";
+ }
+ return selectpat;
+}
+
+/*
+ * Parse the SF field name into an objetc for easy process
+ */
+function SFSelect_parseName(name) {
+ var names = name.split('[');
+ var nameObj = {template: names[0]};
+ if (names[names.length - 1] == ']') {
+ nameObj.isList = true;
+ var property = names[names.length - 2]
+ property = property.substr(0, property.length - 1);
+ nameObj.property = property;
+ if (names.length == 4) {
+ var index = names[1];
+ index = index.substr(0, index.length - 1);
+ nameObj.index = index;
+ } else {
+ nameObj.index = null;
+ }
+ } else {
+ nameObj.isList = false;
+ var property = names[names.length - 1]
+ property = property.substr(0, property.length - 1);
+ nameObj.property = property;
+ if (names.length == 3) {
+ var index = names[1];
+ index = index.substr(0, index.length - 1);
+ nameObj.index = index;
+ } else {
+ nameObj.index = null;
+ }
+ }
+ return nameObj;
+}
+
+function SFSelect_setDependentValues(nameobj, fobj, values) {
+
+ var selectPat = SFSelect_getSelectFieldPat(nameobj, fobj);
+
+ jQuery(selectPat).each(function (index, element) {
+ //keep selected values;
+ var selectedValues = jQuery(element).val();
+
+ if ( !selectedValues && fobj.hasOwnProperty("curvalues") ) {
+ selectedValues = fobj.curvalues;
+ }
+
+ if (!selectedValues) {
+ selectedValues = [];
+ } else if (!jQuery.isArray(selectedValues)) {
+ selectedValues = [selectedValues];
+ }
+
+ element.options.length = values.length;
+
+ var newselected = [];
+
+ if (fobj.label) {
+ var namevalues = SFSelect_processNameValues(values);
+
+ for (var i = 0; i < namevalues.length; i++) {
+ element.options[i] = new Option(namevalues[i][1], namevalues[i][0]);
+ if (jQuery.inArray(namevalues[i][0], selectedValues) != -1) {
+ element.options[i].selected = true;
+ newselected.push(namevalues[i][0]);
+ }
+ }
+ } else {
+ for (var i = 0; i < values.length; i++) {
+ element.options[i] = new Option(values[i]);
+
+ if (jQuery.inArray(values[i], selectedValues) != -1) {
+ element.options[i].selected = true;
+ newselected.push(values[i]);
+ }
+ }
+ }
+
+ if (newselected.length == 0) {
+ if (fobj.selectrm && fobj.selecttemplate != fobj.valuetemplate && fobj.selectismultiple) {
+ jQuery(element).closest("div.multipleTemplateInstance").remove();
+ } else {
+ if (selectedValues.length != 0 || values.length === 1)
+ jQuery(element).trigger("change");
+ }
+ } else if (!SFSelect_arrayEqual(newselected, selectedValues)) {
+ jQuery(element).trigger("change");
+ }
+ });
+}
+
+/** Function for turning name values from 'Page (property)' results **/
+
+function SFSelect_processNameValues( values ) {
+
+ var namevalues = [];
+
+ for(var i=0; i<values.length; i++){
+
+ var openBr = 0;
+ var doneBr = 0;
+ var num = 0;
+
+ var label = values[i];
+
+ var labelArr = label.split("");
+
+ var end = labelArr.length - 1;
+ var iter = end;
+
+ var endBr = end;
+ var startBr = 0;
+
+ while ( doneBr === 0 && iter >= 0 ) {
+
+ var charLabel = labelArr[ iter ];
+
+ if ( charLabel === ")" ) {
+ openBr = openBr - 1;
+
+ if ( num === 0 ) {
+ endBr = iter;
+ num = num + 1;
+ }
+ }
+
+ if ( charLabel === "(" ) {
+ openBr = openBr + 1;
+
+ if ( num > 0 && openBr === 0 ) {
+ startBr = iter;
+ doneBr = 1;
+ }
+ }
+
+ iter = iter - 1;
+ }
+
+ labelValue = ( labelArr.slice( startBr+1, endBr ) ).join("");
+ labelKey = ( labelArr.slice( 0, startBr - 1 ) ).join("");
+
+ namevalues.push( [ labelKey, labelValue ] );
+
+ }
+
+ return namevalues;
+
+}
+
+function SFSelect_arrayEqual(a, b) {
+ if (a.length != b.length)
+ return false;
+ a = a.sort();
+ b = b.sort();
+ for (var i = 0; i < a.length; i++) {
+ if (a[i] != b[i])
+ return false;
+ }
+ return true;
+}
+
+
+//( function ( $, mw ) {
+( function ($) {
+ 'use strict';
+
+ /**
+ * valuetemplate:string,
+ * valuefield:string, value is the form field on which other select element depends on. change
+ * on this field will trigger a load event for selectfield.
+ * selecttemplate:string
+ * selectfield:string
+ * selectismultiple:boolean, Whether this template is a multiple template.
+ * selectquery or selectfunciton: the query ot function to execute
+ * selectrm:boolean remove the div if the selected value for a field is not valid any more.
+ * label: boolean, process ending content () as label in option values.
+ * sep: Separator for the list of retrieved values, default ','
+ */
+
+ // get the objects from PHP using mw.config helper
+ var SFSelect_fobjs = $.parseJSON(mw.config.get('sf_select'));
+
+ /**
+ * changeHandler
+ * @param src
+ */
+ function SFSelect_changeHandler(src) {
+
+ //console.log("change is called for " + src.name);
+
+ if (src.tagName.toLowerCase() != 'select' && src.tagName.toLowerCase() != 'input') {
+ return;
+ }
+
+ var v = [];
+
+ var selectElement = jQuery(src);
+ var select2enabled = false;
+ var name = src.name;
+
+ if (typeof selectElement.select2 === "function") {
+ // safe to use the function
+
+ var select2Data = selectElement.select2('data');
+ var value_initial = selectElement.attr('data-value-initial');
+ select2enabled = true;
+ }
+
+ // field empty?
+ if ( selectElement.val() && select2enabled ) {
+
+ // do we have a version of Page Forms that supports 'value-initial'?
+ if (typeof value_initial === 'string') {
+
+ // if select2('data') exists
+ if ((select2Data.hasOwnProperty('id') && select2Data.hasOwnProperty('text')) || (select2Data[0].hasOwnProperty('id') && select2Data[0].hasOwnProperty('text'))) {
+
+ // Combobox
+ // lookup values in wgPageFormsAutocompleteValues
+ if (selectElement.hasClass('pfComboBox')) {
+ var autocompletesettings = selectElement.attr('autocompletesettings');
+ if (autocompletesettings !== null) {
+ // In case of initial page load and label is used, select2Data.id holds a value
+ // and not an id. In this case, use 'data-value-initial' instead
+ if (typeof select2Data.id === 'string') {
+ // change triggered by initial page load
+ v.push(value_initial);
+ } else {
+ // change triggered by user
+ v.push(Object.keys(mw.config.get('wgPageFormsAutocompleteValues')[autocompletesettings])[select2Data.id - 1]);
+ }
+ }
+ }
+
+ // Tokens
+ else if (selectElement.hasClass('pfTokens')) {
+ var autocompletesettings = selectElement.attr('autocompletesettings');
+ if (autocompletesettings !== null) {
+ select2Data.forEach(function (i) {
+ v.push(i.id);
+ });
+ }
+ }
+
+ } else { // if select2('data') does not exist, use initial value
+ v = value_initial.split(';');
+ }
+
+ } else {
+
+ // Page Forms does not support 'data-value-initial' -> old behaviour without support for mapping
+ if (jQuery.isArray(selectElement.val())) {
+ v = selectElement.val();
+ } else {
+ if (selectElement.attr('type') === "checkbox") {
+ v = (selectElement.is(":checked")) ? ["true"] : ["false"];
+
+ // cut of [value] component from name
+ name = src.name.substr(0,src.name.indexOf("[value]"));
+ } else {
+ //split and trim
+ v = $.map(selectElement.val().split(";"), $.trim);
+ }
+ }
+ }
+ } else {
+
+ v = selectElement.val();
+
+ if (jQuery.isArray(v)){
+ // That's OK
+ } else if (v==null) {
+
+ v=[];
+
+ } else {
+
+ v=[v];
+
+ }
+ }
+
+ var srcName = SFSelect_parseName(name);
+
+ for (var i = 0; i < SFSelect_fobjs.length; i++) {
+
+ if ( SFSelect_fobjs[i].hasOwnProperty("staticvalue") && SFSelect_fobjs[i].staticvalue ) {
+
+ SFSelect_changeSelected( SFSelect_fobjs[i], srcName );
+
+ } else {
+
+ SFSelect_prepareQuery( SFSelect_fobjs[i], srcName, v );
+
+ }
+ }
+ }
+
+ function SFSelect_changeSelected( fobj, nameobj ) {
+
+ var selectPat=SFSelect_getSelectFieldPat(nameobj, fobj);
+
+ jQuery(selectPat).each(function(index, element){
+ //keep selected values;
+ var selectedValues=jQuery(element).val();
+
+ if ( !selectedValues && fobj.hasOwnProperty("curvalues") ) {
+ selectedValues = fobj.curvalues;
+ }
+
+ if (!selectedValues){
+ selectedValues=[];
+ } else if (!jQuery.isArray(selectedValues)){
+ selectedValues=[selectedValues];
+ }
+
+ if ( element.options && element.options.length > 0 ) {
+
+ var options = jQuery.map( element.options ,function(option) {
+ return option.value;});
+
+ for ( var c = 0; c < selectedValues.length; c++ ) {
+
+ if ( jQuery.inArray( selectedValues[c], options ) ) {
+
+ var changed = jQuery( element ).attr( "data-changed" );
+
+ if ( changed ) {
+
+ jQuery( element ).val( selectedValues[c] ).trigger('change');
+
+ }
+
+ }
+ }
+
+ }
+
+ });
+
+ }
+
+ /**
+ * prepareQuery
+ */
+ function SFSelect_prepareQuery(fobj, srcName, v) {
+ if (srcName.template == fobj.valuetemplate && srcName.property == fobj.valuefield) {
+ //good, we have a match.
+ // No values
+ if (v.length == 0 || v[0] == '') {
+ SFSelect_setDependentValues(srcName, fobj, []);
+ } else {
+ // Values
+
+ var param = {}
+ param['action'] = 'sformsselect';
+ param['format'] = 'json';
+ param['sep'] = fobj.sep;
+
+ if (fobj.selectquery) {
+ var query = fobj.selectquery.replace("@@@@", v.join('||'));
+ param['query'] = query;
+ param['approach'] = 'smw';
+
+ } else {
+ var query = fobj.selectfunction.replace("@@@@", v.join(","));
+ param['query'] = query;
+ param['approach'] = 'function';
+ }
+
+ var posting = jQuery.get(mw.config.get('wgScriptPath') + "/api.php", param);
+ posting.done(function (data) {
+ // Let's pass values
+ SFSelect_setDependentValues(srcName, fobj, data["sformsselect"].values);
+ }).fail(function (data) {
+ console.log("Error!");
+ });
+
+ // break; // Avoid loading fobj again
+ }
+ }
+ }
+
+ /**
+ * removeDuplicateFobjs
+ * SF form add a fobj for each field in a multiple template.
+ * In reality we only need a fobj to reduce the ajax call.
+ **/
+ function SFSelect_removeDuplicateFobjs(SFSelect_fobjs) {
+ var newfobjs = [];
+
+ for (var i = 0; i < SFSelect_fobjs.length; i++) {
+ var found = false;
+ var of = SFSelect_fobjs[i];
+ if (!of.selectismultiple) {
+ newfobjs.push(of);
+ continue;
+ }
+ for (var j = 0; j < newfobjs.length; j++) {
+ var nf = newfobjs[j];
+ if (of.selecttemplate == nf.selecttemplate && of.selectfield == nf.selectfield) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ newfobjs.push(of);
+ }
+ }
+
+ return newfobjs;
+ }
+
+ //simplify duplicated object.
+ SFSelect_fobjs = SFSelect_removeDuplicateFobjs(SFSelect_fobjs);
+
+ // register change handler
+ $("form#pfForm").change(function (event) {
+ SFSelect_changeHandler(event.target);
+ });
+
+ var objs = null;
+
+ // populate Select fields at load time
+ for (var i = 0; i < SFSelect_fobjs.length; i++) {
+
+ var fobj = SFSelect_fobjs[i];
+
+ //var valuepat = "input[name='" + fobj.valuetemplate + "\\["+ fobj.valuefield + "\\]']";
+
+ // support multi instance templates: select all "input" items starting with fobj.valuetemplate
+ // and containing fobj.valuefield
+ // example name attribute: name="myTemplate[0a][myField]"
+ var valuepat = 'input[name^="' + fobj.valuetemplate + '"]' + '[name*="' + fobj.valuefield + '"]';
+
+ if ($(valuepat).val()) {
+ // get Select fields, skipping 'map_fields'
+ objs = jQuery(valuepat).not('input[name*=map_field]');
+ } else {
+ //valuepat= "select[name='" + fobj.valuetemplate + "\\["+ fobj.valuefield + "\\]']";
+
+ // support multi instance templates: select all "select" items starting with fobj.valuetemplate
+ // and containing fobj.valuefield
+ // example name attribute: name="myTemplate[0a][myField]"
+ var valuepat = 'select[name^="' + fobj.valuetemplate + '"]' + '[name*="' + fobj.valuefield + '"]';
+
+ objs = jQuery(valuepat).not('select[name*=map_field]');
+ }
+ objs.trigger("change");
+ }
+
+//}( jQuery, mediaWiki ) );
+}(jQuery) );
diff --git a/www/wiki/extensions/SemanticFormsSelect/res/select2.css b/www/wiki/extensions/SemanticFormsSelect/res/select2.css
new file mode 100644
index 00000000..3b70fb56
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/res/select2.css
@@ -0,0 +1,42 @@
+/* span.select-sfs {
+ margin-bottom: 11px;
+ position: relative;
+ display: inline-block;
+ min-width: 210px;
+}
+
+span.select-sfs-single:after {
+ background-image: url(select2.png);
+ background-image: url(select2.png), linear-gradient(to top,#ccc 0%,#eee 60%);
+ background-image: url(select2.png), -webkit-linear-gradient(center bottom,#ccc 0%,#eee 60%);
+ background-image: url(select2.png), -moz-linear-gradient(center bottom,#ccc 0%,#eee 60%);
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#eeeeee',endColorstr = '#cccccc',GradientType = 0);
+ height: 100%;
+ width: 19px;
+}
+
+span.select-sfs:after{
+ content: '';
+ right: 0;
+ position: absolute;
+ pointer-events: none;
+ border-radius: 0 4px 4px 0;
+ border: 1px solid #aaa;
+}
+
+span.select-sfs select {
+ padding-top: 2px;
+ font-size: 95%;
+ cursor: pointer;
+ outline: none;
+ -webkit-appearance: none;
+ -moz-appearance: none;
+ appearance: none;
+ display: inline-block;
+ min-width: 450px !important;
+}
+
+span.select-sfs select:not([multiple]) {
+ height: 26px;
+ background-image: linear-gradient(to top,#eee 0%,#fff 50%)
+} */
diff --git a/www/wiki/extensions/SemanticFormsSelect/res/select2.png b/www/wiki/extensions/SemanticFormsSelect/res/select2.png
new file mode 100644
index 00000000..1d804ffb
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/res/select2.png
Binary files differ
diff --git a/www/wiki/extensions/SemanticFormsSelect/src/ApiSemanticFormsSelect.php b/www/wiki/extensions/SemanticFormsSelect/src/ApiSemanticFormsSelect.php
new file mode 100644
index 00000000..86dabb5e
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/src/ApiSemanticFormsSelect.php
@@ -0,0 +1,94 @@
+<?php
+
+/**
+ * API modules to communicate with the back-end
+ *
+ * @license GNU GPL v2+
+ * @since 1.2
+ *
+ * @author Jason Zhang
+ * @author Toni Hermoso Pulido
+ */
+
+namespace SFS;
+
+use ApiBase;
+use Parser;
+use ParserOptions;
+use ParserOutput;
+use Title;
+
+class ApiSemanticFormsSelect extends ApiBase {
+
+ /**
+ * @see ApiBase::execute
+ */
+ public function execute() {
+
+ $parser = new Parser( $GLOBALS['wgParserConf'] );
+ $parser->setTitle( Title::newFromText( 'NO TITLE' ) );
+ $parser->mOptions = new ParserOptions();
+ $parser->mOutput = new ParserOutput();
+
+ $apiRequestProcessor = new \SFS\ApiSemanticFormsSelectRequestProcessor( $parser );
+ $apiRequestProcessor->setDebugFlag( $GLOBALS['wgSF_Select_debug'] );
+
+ $resultValues = $apiRequestProcessor->getJsonDecodedResultValuesForRequestParameters(
+ $this->extractRequestParams()
+ );
+
+ $result = $this->getResult();
+ $result->setIndexedTagName( $resultValues->values, 'value' );
+ $result->addValue( $this->getModuleName(), 'values', $resultValues->values );
+ $result->addValue( $this->getModuleName(), 'count', $resultValues->count );
+
+ return true;
+ }
+
+ /**
+ * @see ApiBase::getAllowedParams
+ */
+ public function getAllowedParams() {
+ return [
+ 'approach' => [
+ ApiBase::PARAM_TYPE => 'string',
+ ApiBase::PARAM_REQUIRED => true
+ ],
+ 'query' => [
+ ApiBase::PARAM_TYPE => 'string',
+ ApiBase::PARAM_REQUIRED => true
+ ],
+ 'sep' => [
+ ApiBase::PARAM_TYPE => 'string',
+ ApiBase::PARAM_REQUIRED => false
+ ]
+ ];
+ }
+
+ /**
+ * @see ApiBase::getDescription
+ */
+ public function getDescription() {
+ return [
+ 'API for providing SemanticFormsSelect values'
+ ];
+ }
+
+ /**
+ * @see ApiBase::getParamDescription
+ */
+ public function getParamDescription() {
+ return [
+ 'approach' => 'The actual approach: function or smw',
+ 'query' => 'The query of the former'
+ ];
+ }
+
+ /**
+ * @see ApiBase::getVersion
+ */
+ public function getVersion() {
+ return __CLASS__ . ': 1.1';
+ }
+
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/src/ApiSemanticFormsSelectRequestProcessor.php b/www/wiki/extensions/SemanticFormsSelect/src/ApiSemanticFormsSelectRequestProcessor.php
new file mode 100644
index 00000000..18355536
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/src/ApiSemanticFormsSelectRequestProcessor.php
@@ -0,0 +1,149 @@
+<?php
+
+/**
+ * @license GNU GPL v2+
+ * @since 1.3
+ *
+ * @author Jason Zhang
+ * @author Toni Hermoso Pulido
+ * @author mwjames
+ */
+
+namespace SFS;
+
+use Parser;
+use SMWQueryProcessor as QueryProcessor;
+use InvalidArgumentException;
+use MWDebug;
+
+class ApiSemanticFormsSelectRequestProcessor {
+
+ /**
+ * @var Parser
+ */
+ private $parser;
+
+ /**
+ * @var boolean
+ */
+ private $debugFlag = false;
+
+ /**
+ * @since 1.3
+ *
+ * @param Parser $parser
+ */
+ public function __construct( Parser $parser ) {
+ $this->parser = $parser;
+ }
+
+ /**
+ * @since 1.3
+ *
+ * @param boolean $debugFlag
+ */
+ public function setDebugFlag( $debugFlag ) {
+ $this->debugFlag = $debugFlag;
+ }
+
+ /**
+ * @since 1.3
+ *
+ * @param array $parameters
+ *
+ * @return string
+ */
+ public function getJsonDecodedResultValuesForRequestParameters( array $parameters ) {
+
+ if ( !isset( $parameters['query'] ) || !isset( $parameters['sep'] ) ) {
+ throw new InvalidArgumentException( 'Missing an query parameter' );
+ }
+
+ $this->parser->firstCallInit();
+ $json = [];
+
+ if ( isset( $parameters['approach'] ) && $parameters['approach'] == 'smw' ) {
+ $json = $this->doProcessQueryFor( $parameters['query'], $parameters['sep'] );
+ } else {
+ $json = $this->doProcessFunctionFor( $parameters['query'], $parameters['sep'] );
+ }
+
+ // I have no idea why we first encode and and then decode here??
+
+ return json_decode( $json );
+ }
+
+ private function doProcessQueryFor( $querystr, $sep = "," ) {
+
+ $querystr = str_replace(
+ [ "&lt;", "&gt;", "sep=;" ],
+ [ "<", ">", "sep={$sep};" ],
+ $querystr
+ );
+
+ $rawparams = explode( ";", $querystr );
+ $f = str_replace( ";", "|", $rawparams[0] );
+
+ $rawparams[0] = $this->parser->replaceVariables( $f );
+
+ if ( $this->debugFlag ) {
+ error_log( implode( "|", $rawparams ) );
+ }
+
+
+ list( $query, $params ) = QueryProcessor::getQueryAndParamsFromFunctionParams( $rawparams, SMW_OUTPUT_WIKI, QueryProcessor::INLINE_QUERY, false );
+
+ $result = QueryProcessor::getResultFromQuery( $query, $params, SMW_OUTPUT_WIKI, QueryProcessor::INLINE_QUERY );
+
+
+ $values = $this->getFormattedValuesFrom( $sep, $result );
+
+ return json_encode( [
+ "values" => $values,
+ "count" => count( $values )
+ ] );
+ }
+
+ private function doProcessFunctionFor( $query, $sep = "," ) {
+
+ $query = str_replace(
+ [ "&lt;", "&gt;", "sep=;" ],
+ [ "<", ">", "sep={$sep};" ],
+ $query
+ );
+
+ $f = str_replace( ";", "|", $query );
+
+ if ( $this->debugFlag ) {
+ error_log( $f );
+ }
+
+ $values = $this->getFormattedValuesFrom(
+ $sep,
+ $this->parser->replaceVariables( $f )
+ );
+
+ return json_encode( [
+ "values" => $values,
+ "count" => count( $values )
+ ] );
+ }
+
+ private function getFormattedValuesFrom( $sep, $values ) {
+
+ if ( strpos( $values, $sep ) === false ) {
+ return [ $values ];
+ }
+
+ $values = explode( $sep, $values );
+ $values = array_map( "trim", $values );
+ $values = array_unique( $values );
+
+ // TODO: sorting here will destroy any sort defined in the query, e.g. in case sorting for labels (instead of mainlable)
+ //sort( $values );
+ array_unshift( $values, "" );
+
+ return $values;
+ }
+
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/src/Output.php b/www/wiki/extensions/SemanticFormsSelect/src/Output.php
new file mode 100644
index 00000000..578a0ab5
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/src/Output.php
@@ -0,0 +1,47 @@
+<?php
+
+/**
+ * @license GNU GPL v2+
+ * @since 1.3
+ *
+ * @author mwjames
+ * @author Alexander Gesinn
+ */
+
+namespace SFS;
+
+//use MWDebug;
+
+class Output {
+
+ /**
+ * @var array
+ */
+ private static $headItems = [];
+
+ /**
+ * Add an array of SF_Select field parameters as defined in Page Form's field tag.
+ *
+ * This will later be added to $wgOut so that JS can access it via mw.config.get
+ *
+ * @param array $data
+ */
+ public static function addToHeadItem( Array $data = [] ) {
+ return self::$headItems[] = $data;
+ }
+
+ /**
+ * Commit all SF_Select field parameters to Output
+ *
+ */
+ public static function commitToParserOutput() {
+ global $wgOut; # is there a better way to get $output/$parser without using a global? (testability!)
+
+ // to be used in JS like:
+ // var SFSelect_fobjs = $.parseJSON( mw.config.get( 'sf_select' ) );
+ $wgOut->addJsConfigVars('sf_select', json_encode( self::$headItems ));
+
+ //self::$resourceModules = array();
+ //self::$headItems = array();
+ }
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/src/SelectField.php b/www/wiki/extensions/SemanticFormsSelect/src/SelectField.php
new file mode 100644
index 00000000..87adea0a
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/src/SelectField.php
@@ -0,0 +1,210 @@
+<?php
+
+/**
+ * Represents a Select Field.
+ * @license GNU GPL v2+
+ * @since 3.0.0
+ * @author: Alexander Gesinn
+ */
+
+namespace SFS;
+
+use SMWQueryProcessor as QueryProcessor;
+use Parser;
+use MWDebug;
+
+class SelectField {
+
+ private $mParser = null;
+
+ //private $mSelectField = array();
+ private $mValues = null;
+ private $mHasStaticValues = false;
+
+ private $mData = []; # array with all parameters
+ private $mQuery = "";
+ private $mFunction = "";
+ private $mSelectIsMultiple = false;
+ private $mSelectTemplate = "";
+ private $mSelectField = "";
+ private $mValueTemplate = "";
+ private $mValueField = "";
+ private $mSelectRemove = false;
+ private $mLabel = false;
+ private $mDelimiter = ",";
+
+ public function __construct( & $parser ) {
+ $this->mParser = $parser;
+ }
+
+ /**
+ * Convenience function to process all parameters at once
+ */
+ public function processParameters( $input_name = "", $other_args ) {
+ if ( array_key_exists( "query", $other_args ) ) {
+ $this->setQuery( $other_args );
+ } elseif ( array_key_exists( "function", $other_args ) ) {
+ $this->setFunction( $other_args );
+ }
+ }
+
+ /**
+ * getData
+ *
+ * @return array Array with all parameters
+ */
+ public function getData() {
+ return $this->mData;
+ }
+
+ public function setQuery( $other_args ) {
+ $querystr = $other_args["query"];
+ $querystr = str_replace( [ "~", "(", ")" ], [ "=", "[", "]" ], $querystr );
+
+ //$this->mSelectField["query"] = $query;
+ $this->mQuery = $querystr;
+ $this->mData['selectquery'] = $querystr;
+
+ // unparametrized query
+ if ( strpos( $querystr, '@@@@' ) === false ) {
+ $rawparams = explode( ";", $querystr );
+
+ // there is no need to run the parser, $query has been parsed already
+ //$params[0] = $wgParser->replaceVariables( $params[0] );
+
+ list( $query, $params ) = QueryProcessor::getQueryAndParamsFromFunctionParams( $rawparams, SMW_OUTPUT_WIKI, QueryProcessor::INLINE_QUERY, false );
+
+ $result = QueryProcessor::getResultFromQuery( $query, $params, SMW_OUTPUT_WIKI, QueryProcessor::INLINE_QUERY );
+
+ $this->mValues = $this->getFormattedValuesFrom( $this->mDelimiter, $result );
+
+ $this->setHasStaticValues( true );
+ }
+ }
+
+ public function setFunction( $other_args ) {
+ #global $wgParser;
+
+ $function = $other_args["function"];
+ $function = '{{#' . $function . '}}';
+ $function = str_replace( [ "~", "(", ")" ], [ "=", "[", "]" ], $function );
+
+ //$this->mSelectField["function"] = $function;
+ $this->mFunction = $function;
+ $this->mData['selectfunction'] = $function;
+
+ // unparametrized function
+ if ( strpos( $function, '@@@@' ) === false ) {
+ $f = str_replace( ";", "|", $function );
+
+ $this->setValues( $this->mParser->replaceVariables( $f ) );
+
+ $this->setHasStaticValues( true );
+ }
+ }
+
+ public function setSelectIsMultiple( Array $other_args ) {
+ $this->mSelectIsMultiple = array_key_exists( "part_of_multiple", $other_args );
+ $this->mData["selectismultiple"] = $this->mSelectIsMultiple;
+ }
+
+ public function setSelectTemplate( $input_name = "" ) {
+ $index = strpos( $input_name, "[" );
+ $this->mSelectTemplate = substr( $input_name, 0, $index );
+ $this->mData['selecttemplate'] = $this->mSelectTemplate;
+ }
+
+ public function setSelectField( $input_name = "" ) {
+ $index = strrpos( $input_name, "[" );
+ $this->mSelectField = substr( $input_name, $index + 1, strlen( $input_name ) - $index - 2 );
+ $this->mData['selectfield'] = $this->mSelectField;
+ }
+
+ public function setValueTemplate( Array $other_args ) {
+ $this->mValueTemplate =
+ array_key_exists( "sametemplate", $other_args ) ? $this->mSelectTemplate : $other_args["template"];
+ $this->mData["valuetemplate"] = $this->mValueTemplate;
+ }
+
+ public function setValueField( Array $other_args ) {
+ $this->mValueField = $other_args["field"];
+ $this->mData["valuefield"] = $this->mValueField;
+
+ }
+
+ public function setSelectRemove( Array $other_args ) {
+ $this->mSelectRemove = array_key_exists( 'rmdiv', $other_args );
+ $this->mData['selectrm'] = $this->mSelectRemove;
+ }
+
+ public function setLabel( Array $other_args ) {
+ $this->mLabel = array_key_exists( 'label', $other_args );
+ $this->mData['label'] = $this->mLabel;
+ }
+
+ /**
+ * setDelimiter
+ * @param array $other_args
+ */
+ public function setDelimiter( Array $other_args ) {
+
+ $this->mDelimiter = $GLOBALS['wgPageFormsListSeparator'];
+
+ if ( array_key_exists( 'sep', $other_args ) ) {
+ $this->mDelimiter = $other_args['sep'];
+ } else {
+ // Adding Backcompatibility
+ if ( array_key_exists( 'delimiter', $other_args ) ) {
+ $this->mDelimiter = $other_args['delimiter'];
+ }
+ }
+
+ $this->mData['sep'] = $this->mDelimiter;
+ }
+
+ public function getDelimiter() {
+ return $this->mDelimiter;
+ }
+
+ public function getValues() {
+ return $this->mValues;
+ }
+
+ /**
+ * setValues
+ * @param string $values (comma separated, fully parsed list of values)
+ */
+ private function setValues( $values ) {
+ $values = explode( $this->mDelimiter, $values );
+ $values = array_map( "trim", $values );
+ $values = array_unique( $values );
+ $this->mValues = $values;
+ }
+
+ public function hasStaticValues() {
+ return $this->mHasStaticValues;
+ }
+
+ private function setHasStaticValues( $StaticValues ) {
+ $this->mHasStaticValues = $StaticValues;
+ }
+
+ /** Copied from ApiSemanticFormsSelectRequestProcessor */
+
+ private function getFormattedValuesFrom( $sep, $values ) {
+
+ if ( strpos( $values, $sep ) === false ) {
+ return [ $values ];
+ }
+
+ $values = explode( $sep, $values );
+ $values = array_map( "trim", $values );
+ $values = array_unique( $values );
+
+ // TODO: sorting here will destroy any sort defined in the query, e.g. in case sorting for labels (instead of mainlable)
+ //sort( $values );
+ // array_unshift( $values, "" ); Unshift no needed here
+
+ return $values;
+ }
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/src/SemanticFormsSelectInput.php b/www/wiki/extensions/SemanticFormsSelect/src/SemanticFormsSelectInput.php
new file mode 100644
index 00000000..3417f6d0
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/src/SemanticFormsSelectInput.php
@@ -0,0 +1,307 @@
+<?php
+
+/**
+ * @license GNU GPL v2+
+ * @since 1.3
+ *
+ * @author Jason Zhang
+ * @author Toni Hermoso Pulido
+ * @author Alexander Gesinn
+ */
+
+namespace SFS;
+
+use SMWQueryProcessor as QueryProcessor;
+use Parser;
+use PFFormInput;
+use MWDebug;
+
+class SemanticFormsSelectInput extends PFFormInput {
+
+ /**
+ * Internal data container
+ *
+ * @var array
+ */
+ private static $data = [];
+
+ private $mSelectField;
+
+ public function __construct( $inputNumber, $curValue, $inputName, $disabled, $otherArgs ) {
+ parent::__construct( $inputNumber, $curValue, $inputName, $disabled, $otherArgs );
+
+ // SelectField is a simple value object - we accept creating it in the constructor
+ $this->mSelectField = new SelectField( $GLOBALS['wgParser'] );
+ }
+
+ public static function getName() {
+ return 'SF_Select';
+ }
+
+ public static function getParameters() {
+ $params = parent::getParameters();
+ return $params;
+ }
+
+ public function getResourceModuleNames() {
+ /**
+ * Loading modules this way currently fails with:
+ * "mw.loader.state({"ext.sf_select.scriptselect":"loading"});"
+ */
+
+ return [
+ 'ext.sf_select.scriptselect'
+ ];
+ }
+
+ /**
+ * Returns the HTML code to be included in the output page for this input.
+ * This is currently just a wrapper for getHTML().
+ */
+ public function getHtmlText() {
+ return self::getHTML( $this->mCurrentValue, $this->mInputName, $this->mIsMandatory, $this->mIsDisabled,
+ $this->mOtherArgs );
+ }
+
+ /**
+ * Returns the HTML code to be included in the output page for this input.
+ * @deprecated use getHtmlText() instead
+ *
+ * @param string $cur_value A single value or a list of values with separator
+ * @param string $input_name Name of the input including the template, e.g. Building[Part Of Site]
+ * @param $is_mandatory
+ * @param $is_disabled
+ * @param string[] $other_args Array of other field parameters
+ * @return string
+ */
+ public function getHTML( $cur_value = "", $input_name = "", $is_mandatory, $is_disabled, Array $other_args ) {
+ global $sfgFieldNum, $wgUser;
+
+ // shortcut to the SelectField object
+ $selectField = $this->mSelectField;
+
+ // get 'delimiter' before 'query' or 'function'
+ $selectField->setDelimiter( $other_args );
+
+ if ( array_key_exists( "query", $other_args ) ) {
+ $selectField->setQuery( $other_args );
+ } elseif ( array_key_exists( "function", $other_args ) ) {
+ $selectField->setFunction( $other_args );
+ }
+
+ if ( array_key_exists( "label", $other_args ) ) {
+ $selectField->setLabel( $other_args );
+ }
+
+ // parameters are only required if values needs to be retrieved dynamically
+ if ( !$selectField->hasStaticValues() ) {
+ $selectField->setSelectIsMultiple( $other_args );
+ $selectField->setSelectTemplate( $input_name );
+ $selectField->setSelectField( $input_name );
+ $selectField->setValueTemplate( $other_args );
+ $selectField->setValueField( $other_args );
+ $selectField->setSelectRemove( $other_args );
+
+ $item = Output::addToHeadItem( $selectField->getData() );
+ }
+
+ Output::commitToParserOutput();
+
+ // prepare the html input tag
+
+ $extraatt = "";
+ $is_list = false;
+
+ if ( array_key_exists( 'is_list', $other_args ) && $other_args['is_list'] == true ) {
+ $is_list = true;
+ }
+
+ if ( $is_list ) {
+ $extraatt = ' multiple="multiple" ';
+ }
+
+ if ( array_key_exists( "size", $other_args ) ) {
+ $extraatt .= " size=\"{$other_args['size']}\"";
+ }
+
+ $classes = [];
+ if ( $is_mandatory ) {
+ $classes[] = "mandatoryField";
+ }
+ if ( array_key_exists( "class", $other_args ) ) {
+ $classes[] = $other_args['class'];
+ }
+ if ( $classes ) {
+ $cstr = implode( " ", $classes );
+ $extraatt .= " class=\"$cstr\"";
+ }
+
+ $inname = $input_name;
+ if ( $is_list ) {
+ $inname .= '[]';
+ }
+
+ // TODO Use Html::
+
+ $spanextra = $is_mandatory ? 'mandatoryFieldSpan' : '';
+ $is_single_select = (!$is_list) ? 'select-sfs-single' : '' ;
+ $ret = "<span class=\"inputSpan select-sfs $is_single_select $spanextra\"><select name='$inname' id='input_$sfgFieldNum' $extraatt>";
+
+ $curvalues = null;
+ if ( $cur_value ) {
+ if ( $cur_value === 'current user' ) {
+ $cur_value = $wgUser->getName();
+ }
+ if ( is_array( $cur_value ) ) {
+ $curvalues = $cur_value;
+ } else {
+ // delimiter for $cur_value is always ',' - PF seems to ignore $wgPageFormsListSeparator
+ $curvalues = array_map( "trim", explode( $selectField->getDelimiter(), $cur_value ) );
+ }
+
+ } else {
+ $curvalues = [];
+ }
+
+
+ $labelArray = [];
+ if ( array_key_exists( "label", $other_args ) && $curvalues ) {
+ // $labelArray = $this->getLabels( $curvalues );
+ }
+
+ // TODO handle empty value case.
+ $ret .= "<option></option>";
+
+ if ( $selectField->hasStaticValues() ) {
+
+ $values = $selectField->getValues();
+
+ if ( array_key_exists( "label", $other_args ) && $values ) {
+ $labelArray = $this->getLabels( $values );
+ }
+
+ if ( is_array( $values ) ) {
+
+ foreach ( $values as $val ) {
+
+ $selected = "";
+
+ if ( array_key_exists( $val, $labelArray ) ) {
+
+ if ( in_array( $labelArray[ $val ][0], $curvalues ) ) {
+ $selected = " selected='selected'";
+ }
+
+ $ret.="<option".$selected." value='".$labelArray[ $val ][0]."'>".$labelArray[ $val ][1]."</option>";
+
+ } else {
+
+ if ( in_array( $val, $curvalues ) ) {
+ $selected = " selected='selected'";
+ }
+
+ $ret .= "<option".$selected.">$val</option>";
+ }
+ }
+ }
+ } else {
+
+ foreach ( $curvalues as $cur ) {
+ $selected = "";
+
+ if ( array_key_exists( $cur, $labelArray ) ) {
+
+ if ( in_array( $labelArray[ $cur ][0], $curvalues ) ) {
+ $selected = " selected='selected'";
+ }
+
+ $ret.="<option".$selected." value='".$labelArray[ $cur ][0]."'>".$labelArray[ $cur ][1]."</option>";
+
+ } else {
+ if ( in_array( $cur, $curvalues ) ) {
+ $selected = " selected='selected'";
+ }
+ $ret.="<option".$selected.">$cur</option>";
+ }
+ }
+
+ }
+
+ $ret .= "</select></span>";
+ $ret .= "<span id=\"info_$sfgFieldNum\" class=\"errorMessage\"></span>";
+
+ if ( $other_args["is_list"] ) {
+ $hiddenname = $input_name . '[is_list]';
+ $ret .= "<input type='hidden' name='$hiddenname' value='1' />";
+ }
+
+ return $ret;
+ }
+
+
+ private function getLabels( $labels ) {
+
+ $labelArray = [ ];
+
+ if ( is_array( $labels ) ) {
+ foreach ( $labels as $label ) {
+
+ $labelKey = $label;
+ $labelValue = $label;
+
+ // Tricky thing if ( ) already in name
+ if ( strpos( $label, ")" ) && strpos( $label, "(" ) ) {
+
+ // Check Break
+ $openBr = 0;
+ $doneBr = 0;
+ $num = 0;
+
+ $labelArr = str_split ( $label );
+
+ $end = count( $labelArr ) - 1;
+ $iter = $end;
+
+ $endBr = $end;
+ $startBr = 0;
+
+ while ( $doneBr == 0 && $iter >= 0 ) {
+
+ $char = $labelArr[ $iter ];
+
+ if ( $char == ")" ) {
+ $openBr = $openBr - 1;
+
+ if ( $num == 0 ) {
+ $endBr = $iter;
+ $num = $num + 1;
+ }
+ }
+
+ if ( $char == "(" ) {
+ $openBr = $openBr + 1;
+
+ if ( $num > 0 && $openBr == 0 ) {
+ $startBr = $iter;
+ $doneBr = 1;
+ }
+ }
+
+ $iter = $iter - 1;
+
+ }
+
+ $labelValue = implode( "", array_slice( $labelArr, $startBr+1, $endBr-$startBr-1 ) );
+ $labelKey = implode( "", array_slice( $labelArr, 0, $startBr-1 ) );
+
+ }
+
+ $labelArray[ $label ] = [ $labelKey, $labelValue ] ;
+ }
+
+ }
+
+ return $labelArray;
+
+ }
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/tests/bootstrap.php b/www/wiki/extensions/SemanticFormsSelect/tests/bootstrap.php
new file mode 100644
index 00000000..83339993
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/tests/bootstrap.php
@@ -0,0 +1,29 @@
+<?php
+
+if ( PHP_SAPI !== 'cli' ) {
+ die( 'Not an entry point' );
+}
+
+error_reporting( E_ALL | E_STRICT );
+date_default_timezone_set( 'UTC' );
+ini_set( 'display_errors', 1 );
+
+global $IP;
+
+//if ( !is_readable( $autoloaderClassPath = __DIR__ . '/../../SemanticMediaWiki/tests/autoloader.php' ) ) {
+if ( !is_readable( $autoloaderClassPath = $IP . '/extensions/SemanticMediaWiki/tests/autoloader.php' ) ) {
+ die( "\nThe Semantic MediaWiki test autoloader is not available\n" );
+}
+
+// if ( !class_exists( 'SemanticFormsSelect' ) || ( $version = SemanticFormsSelect::getVersion() ) === null ) {
+if ( ExtensionRegistry::getInstance()->isLoaded( 'SemanticFormsSelect' ) ) {
+ die( "\nSemantic Forms Select is not available, please check your Composer or LocalSettings.\n" );
+}
+
+//print sprintf( "\n%-20s%s\n", "Semantic Forms Select: ", ExtensionRegistry::getInstance()->isLoaded( 'SemanticFormsSelect' ) );
+//print sprintf( "%-20s%s\n", "Page Forms: ", SemanticFormsSelect::getVersion( 'PageForms' ) );
+
+$autoloader = require $autoloaderClassPath;
+//$autoloader->addPsr4( 'SFS\\Tests\\', __DIR__ . '/phpunit/Unit' );
+//$autoloader->addPsr4( 'SFS\\Tests\\Integration\\', __DIR__ . '/phpunit/Integration' );
+unset( $autoloader );
diff --git a/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/ApiSemanticFormsSelectRequestProcessorTest.php b/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/ApiSemanticFormsSelectRequestProcessorTest.php
new file mode 100644
index 00000000..7c2b292b
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/ApiSemanticFormsSelectRequestProcessorTest.php
@@ -0,0 +1,134 @@
+<?php
+
+namespace SFS\Tests;
+
+use SFS\ApiSemanticFormsSelectRequestProcessor;
+use ApiMain;
+use RequestContext;
+use WebRequest;
+use FauxRequest;
+
+/**
+ * @covers \SFS\ApiSemanticFormsSelectRequestProcessor
+ * @group semantic-forms-select
+ *
+ * @license GNU GPL v2+
+ * @since 3.0.0
+ *
+ * @author FelixAba
+ */
+class ApiSemanticFormsSelectRequestProcessorTest
+ extends \PHPUnit_Framework_TestCase {
+
+ private $ApiSFSRP;
+
+ protected function setUp() {
+ parent::setUp();
+ $parser = $this->getMockBuilder( '\Parser' )
+ ->disableOriginalConstructor()->getMock();
+ $this->ApiSFSRP = new ApiSemanticFormsSelectRequestProcessor( $parser );
+ }
+
+ protected function tearDown() {
+ unset( $this->ApiSFSRP );
+ parent::tearDown();
+ }
+
+ public function testCanConstruct() {
+ $this->assertInstanceOf(
+ '\SFS\ApiSemanticFormsSelectRequestProcessor', $this->ApiSFSRP
+ );
+ }
+
+ public function testMissingParametersThrowsException() {
+
+ $parameters = [];
+
+ $this->setExpectedException( 'InvalidArgumentException' );
+ $this->ApiSFSRP->getJsonDecodedResultValuesForRequestParameters(
+ $parameters
+ );
+ }
+
+ public function testJsonResultValuesFromRequestParameters() {
+
+ $parameters = [ 'query' => 'foo', 'sep' => ',' ];
+
+ $this->assertInternalType(
+ 'object',
+ $this->ApiSFSRP->getJsonDecodedResultValuesForRequestParameters(
+ $parameters
+ )
+ );
+ }
+
+ public function testJsonResultValuesFromRequestParameters_doProcessQueryFor(
+ ) {
+
+ $parameters = [ 'approach' => 'smw', 'query' => 'foo, baa, gaah',
+ 'sep' => ',' ];
+
+ $this->assertInternalType(
+ 'object',
+ $this->ApiSFSRP->getJsonDecodedResultValuesForRequestParameters(
+ $parameters
+ )
+ );
+ }
+
+ public function testSetDebugFlag() {
+ $this->ApiSFSRP->setDebugFlag( true );
+ $parameters = [ 'query' => 'foo , function', 'sep' => ',' ];
+
+ $this->assertInternalType(
+ 'object',
+ $this->ApiSFSRP->getJsonDecodedResultValuesForRequestParameters(
+ $parameters
+ )
+ );
+ }
+
+ public function testSetDebugFlag_doProcessQueryFor() {
+ $this->ApiSFSRP->setDebugFlag( true );
+ $parameters = [ 'approach' => 'smw', 'query' => 'my Query,query2',
+ 'sep' => ',' ];
+
+ $this->assertInternalType(
+ 'object',
+ $this->ApiSFSRP->getJsonDecodedResultValuesForRequestParameters(
+ $parameters
+ )
+ );
+ }
+
+ public function testGetFormattedValuesFrom() {
+ $sep = ",";
+ $values = "my Query,query2";
+ $result = [ "", "my Query", "query2" ];
+ $formattedValues = $this->invokeMethod(
+ $this->ApiSFSRP, 'getFormattedValuesFrom', [ $sep, $values ]
+ );
+ $this->assertEquals( $result, $formattedValues );
+ }
+
+ /**
+ * Call protected/private method of a class.
+ *
+ * @param object &$object Instantiated object that we will run method on.
+ * @param string $methodName Method name to call
+ * @param array $parameters Array of parameters to pass into method.
+ *
+ * @return mixed Method return.
+ */
+ public function invokeMethod( &$object, $methodName,
+ array $parameters = []
+ ) {
+ $reflection = new \ReflectionClass( get_class( $object ) );
+ $method = $reflection->getMethod( $methodName );
+ $method->setAccessible( true );
+
+ return $method->invokeArgs( $object, $parameters );
+ }
+
+
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/ApiSemanticFormsSelectTest.php b/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/ApiSemanticFormsSelectTest.php
new file mode 100644
index 00000000..30ad86de
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/ApiSemanticFormsSelectTest.php
@@ -0,0 +1,95 @@
+<?php
+
+namespace SFS\Tests;
+
+use SFS\ApiSemanticFormsSelect;
+use ApiMain;
+use RequestContext;
+use WebRequest;
+use FauxRequest;
+
+/**
+ * @covers \SFS\ApiSemanticFormsSelect
+ * @group semantic-forms-select
+ *
+ * @license GNU GPL v2+
+ * @since 1.3
+ *
+ * @author mwjames
+ */
+class ApiSemanticFormsSelectTest extends \PHPUnit_Framework_TestCase {
+
+ private $ApiSFS;
+ private $ApiMain;
+
+ protected function setUp() {
+ parent::setUp();
+ $parameters = [ 'action' => 'sformsselect', 'approach' => 'smw',
+ 'query' => 'abc', 'sep' => ',' ];
+
+ $this->ApiMain = new ApiMain(
+ $this->newRequestContext( $parameters ), true
+ );
+ $this->ApiSFS = new ApiSemanticFormsSelect(
+ $this->ApiMain, 'sformsselect'
+ );
+ }
+
+ protected function tearDown() {
+ unset( $this->ApiSFS );
+ unset( $this->ApiMain );
+ parent::tearDown();
+ }
+
+
+ public function testCanConstruct() {
+
+ $apiMain = new ApiMain( $this->newRequestContext( [] ), true );
+
+ $instance = new ApiSemanticFormsSelect(
+ $apiMain, 'sformsselect'
+ );
+
+ $this->assertInstanceOf(
+ '\SFS\ApiSemanticFormsSelect', $this->ApiSFS
+ );
+ }
+
+ public function testExecute() {
+
+ $this->assertTrue(
+ $this->ApiSFS->execute()
+ );
+ }
+
+ public function testGetDescription() {
+ $tdata = [ 'API for providing SemanticFormsSelect values' ];
+ $this->assertEquals( $this->ApiSFS->getDescription(), $tdata );
+ }
+
+ public function testGetParamDescription() {
+ $tdata = [ 'approach' => 'The actual approach: function or smw',
+ 'query' => 'The query of the former' ];
+ $this->assertEquals( $this->ApiSFS->getParamDescription(), $tdata );
+ }
+
+ public function testGetVersion() {
+ $tdata = 'SFS\ApiSemanticFormsSelect: 1.1';
+ $this->assertEquals( $this->ApiSFS->getVersion(), $tdata );
+ }
+
+
+ private function newRequestContext( $request = [] ) {
+
+ $context = new RequestContext();
+
+ if ( $request instanceof WebRequest ) {
+ $context->setRequest( $request );
+ } else {
+ $context->setRequest( new FauxRequest( $request, true ) );
+ }
+
+ return $context;
+ }
+
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/OutputTest.php b/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/OutputTest.php
new file mode 100644
index 00000000..7f124267
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/OutputTest.php
@@ -0,0 +1,50 @@
+<?php
+
+namespace SFS\Tests;
+
+use SFS\Output;
+
+/**
+ * @covers \SFS\Output
+ * @group semantic-forms-select
+ *
+ * @license GNU GPL v2+
+ * @since 1.3
+ *
+ * @author mwjames
+ */
+class OutputTest extends \PHPUnit_Framework_TestCase {
+ private $data;
+
+ protected function setUp() {
+ parent::setUp();
+ $this->data = [];
+ $this->data['Foo'] = 'Bar';
+ $this->data['Spam'] = 'Eggs';
+ }
+
+ protected function tearDown() {
+ unset( $this->data );
+ parent::tearDown();
+ }
+
+ public function testCanConstruct() {
+ $this->assertInstanceOf( '\SFS\Output', new Output() );
+ }
+
+ public function testAddToHeadItem() {
+ $ret = Output::addToHeadItem( $this->data );
+
+ $this->assertArrayHasKey( 'Foo', $ret );
+ $this->assertArrayHasKey( 'Spam', $ret );
+ }
+
+ public function testCommitToParserOutput() {
+ global $wgOut;
+ $expected_result = '[' . json_encode( $this->data ) . ']';
+ Output::commitToParserOutput();
+ $this->assertEquals(
+ $expected_result, $wgOut->getJsConfigVars()['sf_select']
+ );
+ }
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/SelectFieldTest.php b/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/SelectFieldTest.php
new file mode 100644
index 00000000..e69faca3
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/SelectFieldTest.php
@@ -0,0 +1,270 @@
+<?php
+
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+namespace SFS\Tests;
+
+use SFS\SelectField;
+
+use Parser;
+use ParserOptions;
+use ParserOutput;
+use Title;
+
+/**
+ * @covers \SFS\SelectField
+ * @group semantic-forms-select
+ * @author FelixAba
+ */
+class SelectFieldTest extends \PHPUnit_Framework_TestCase {
+ private $SelectField;
+ private $parser;
+ // Defined variables
+ private $other_args_query_parametrized = [ 'query' => '((Category:Building Complex))((Part Of Site::@@@@));?Display Title;format~list;sort~Display Title;sep~,;link~none;headers~hide;limit~500' ];
+ private $expected_result_parametrized_setQuery = "[[Category:Building Complex]][[Part Of Site::@@@@]];?Display Title;format=list;sort=Display Title;sep=,;link=none;headers=hide;limit=500";
+ private $other_args_query_unparametrized = [ 'query' => '((Category:Building Complex));?Display Title;format~list;sort~Display Title;sep~,;link~none;headers~hide;limit~500' ];
+ private $other_args_function_parametrized = [ 'function' => '((Category:Building Complex))((Part Of Site::@@@@));?Display Title;format~list;sort~Display Title;sep~,;link~none;headers~hide;limit~500' ];
+ private $expected_result_parametrized_seFunction = '{{#[[Category:Building Complex]][[Part Of Site::@@@@]];?Display Title;format=list;sort=Display Title;sep=,;link=none;headers=hide;limit=500}}';
+ private $other_args_function_unparametrized = [ 'function' => 'ask:((Category:Building Complex));?Display Title;format~list;sort~Display Title;sep~@@;link~none;headers~hide;limit~500' ];
+ private $expected_result_unparametrized_seFunction = "Building Complex:86543eab-4112-4616-be50-17dcdc24c346 (OFD.AEXH)@@Building Complex:5b9e26f8-6c57-48ff-a6b8-42a4e50fe472 (OFD.AEXH)@@Building Complex:93b076aa-cbe9-4371-8b61-c17c26f1872f (OFD.AMEXH)@@Building Complex:59577450-1582-4d6e-9621-3ac0531a728e (OFD.EEXH)@@Building Complex:1a9bed0b-67de-4e71-8528-f2b6a8907814 (RContiAve.Sport Complex)@@Building Complex:6a2242ea-7536-4a6d-85d2-f2ba4398ef44 (TB.BC)@@Building Complex:2db51fb1-10b6-4d4c-a152-f512914781ff (TB.BD)";
+
+ public function testCanConstruct() {
+
+ $this->assertInstanceOf( '\SFS\SelectField', $this->SelectField );
+ }
+
+ public function testProcessParameters_Query() {
+
+ $this->SelectField->processParameters(
+ "", $this->other_args_query_parametrized
+ );
+ $this->assertTrue(
+ array_key_exists( "query", $this->other_args_query_parametrized )
+ );
+ }
+
+ public function testProcessParameters_Function() {
+
+ $this->SelectField->processParameters(
+ "", $this->other_args_function_parametrized
+ );
+ $this->assertArrayHasKey(
+ "function", $this->other_args_function_parametrized
+ );
+ }
+
+ public function testParametrized_setQuery() {
+
+ $this->SelectField->setQuery( $this->other_args_query_parametrized );
+
+ $this->assertEquals(
+ $this->expected_result_parametrized_setQuery,
+ $this->SelectField->getData()['selectquery']
+ );
+ /*
+ * Optional Test.
+ */
+ preg_match_all(
+ "/[~(\(\()(\)\))]+/", $this->SelectField->getData()['selectquery'],
+ $was_remove
+ );
+
+ preg_match_all(
+ "/[=(\[\[)(\]\])]+/", $this->SelectField->getData()['selectquery'],
+ $was_replaced
+ );
+
+ $this->assertTrue( count( $was_remove[0] ) == 0 );
+ $this->assertTrue( count( $was_replaced[0] ) > 0 );
+ }
+
+ public function testUnparametrized_setQuery() {
+
+ $this->SelectField->setQuery( $this->other_args_query_unparametrized );
+
+ $this->assertTrue( $this->SelectField->getValues() !== null );
+ $this->assertTrue( $this->SelectField->hasStaticValues() );
+ }
+
+ public function testParametrized_setFunction() {
+
+ $this->SelectField->setFunction(
+ $this->other_args_function_parametrized
+ );
+ $this->assertTrue(
+ strcmp(
+ $this->expected_result_parametrized_seFunction,
+ $this->SelectField->getData()['selectfunction']
+ ) == 0
+ );
+ }
+
+ public function testUnparametrized_setFunction() {
+
+ $this->SelectField->setFunction(
+ $this->other_args_function_unparametrized
+ );
+
+ $this->assertTrue( $this->SelectField->hasStaticValues() );
+ }
+
+ public function testSetSelectIsMultiple_keyExistTrue() {
+ $other_args = [ "part_of_multiple" => "bla bla bla" ];
+ $this->SelectField->setSelectIsMultiple( $other_args );
+ $this->assertTrue( $this->SelectField->getData()["selectismultiple"] );
+ }
+
+ public function testSetSelectIsMultiple_keyExistFalse() {
+
+ $other_args = [ "Not_part_of_multiple" => "blas blas blas" ];
+ $this->SelectField->setSelectIsMultiple( $other_args );
+ $this->assertFalse( $this->SelectField->getData()["selectismultiple"] );
+ }
+
+ public function testSetSelectTemplate_correctData() {
+ $input_name = "{{#[[Category:Building Complex]][[Part Of Site::@@@@]]";
+ $result = "{{#";
+ $this->SelectField->setSelectTemplate( $input_name );
+
+ $this->assertEquals(
+ $this->SelectField->getData()['selecttemplate'], $result
+ );
+ }
+
+ public function testSetSelectTemplate_wrongData() {
+ $input_name = "Category:Building Complex";
+ $result = "";
+ $this->SelectField->setSelectTemplate( $input_name );
+
+ $this->assertEquals(
+ $this->SelectField->getData()['selecttemplate'], $result
+ );
+ }
+
+ public function testSetSelectField_correctData() {
+ $input_name = "{{#[[Category:Building Complex]][[Part Of Site::@@@@]]";
+ $result = "Part Of Site::@@@@]";
+
+ $this->SelectField->setSelectField( $input_name );
+
+ $this->assertEquals(
+ $this->SelectField->getData()['selectfield'], $result
+ );
+ }
+
+ public function testSetSelectField_wrongData() {
+ $input_name = "Category:Building Complex";
+ $result = "";
+ $this->SelectField->setSelectField( $input_name );
+
+ $this->assertNotEquals(
+ $this->SelectField->getData()['selectfield'], $result
+ );
+ }
+
+ public function testSetValueTemplate_containsMselectTemplate() {
+ $input_name = "{{#[[Category:Building Complex]][[Part Of Site::@@@@]]";
+ $other_args = [ "sametemplate" => "test values" ];
+ $result = "{{#";
+ $this->SelectField->setSelectTemplate( $input_name );
+ $this->SelectField->setValueTemplate( $other_args );
+
+ $this->assertEquals(
+ $this->SelectField->getData()["valuetemplate"], $result
+ );
+ }
+
+ public function testSetValueTemplate_containsOtherArgsTemplate() {
+
+ $other_args = [ "template" => "test values" ];
+
+ $this->SelectField->setValueTemplate( $other_args );
+
+ $this->assertEquals(
+ $this->SelectField->getData()["valuetemplate"],
+ $other_args["template"]
+ );
+ }
+
+ public function testSetValueField() {
+ $other_args = [ "field" => "test values Field" ];
+
+ $this->SelectField->setValueField( $other_args );
+
+ $this->assertEquals(
+ $this->SelectField->getData()["valuefield"], $other_args["field"]
+ );
+ }
+
+ public function testSetSelectRemove_keyExistTrue() {
+ $other_args = [ 'rmdiv' => "Test data" ];
+ $this->SelectField->setSelectRemove( $other_args );
+ $this->assertTrue( $this->SelectField->getData()["selectrm"] );
+ }
+
+ public function testSetSelectRemove_keyExistFalse() {
+
+ $other_args = [ "no_rmdiv" => "test data" ];
+ $this->SelectField->setSelectRemove( $other_args );
+ $this->assertFalse( $this->SelectField->getData()["selectrm"] );
+ }
+
+ public function testSetLabel_keyExistTrue() {
+ $other_args = [ 'label' => "Test data" ];
+ $this->SelectField->setLabel( $other_args );
+ $this->assertTrue( $this->SelectField->getData()["label"] );
+ }
+
+ public function testSetLabel_keyExistFalse() {
+
+ $other_args = [ "no_label" => "test data" ];
+ $this->SelectField->setLabel( $other_args );
+ $this->assertArrayHasKey( "label", $this->SelectField->getData() );
+ $this->assertFalse( $this->SelectField->getData()["label"] );
+ }
+
+ public function testSetDelimiter_keyExistTrue() {
+ $other_args = [ "delimiter" => ":" ];
+ $this->SelectField->setDelimiter( $other_args );
+ $this->assertEquals(
+ $this->SelectField->getDelimiter(), $other_args["delimiter"]
+ );
+ $this->assertEquals(
+ $this->SelectField->getData()["sep"], $other_args["delimiter"]
+ );
+ }
+
+ public function testSetWgPageFormsListSeparator_keyExistTrue() {
+
+ $g_args = [ "Global_delimiter" => ";" ];
+ $this->SelectField->setDelimiter( $g_args );
+ $this->assertEquals(
+ $this->SelectField->getDelimiter(), $g_args["Global_delimiter"]
+ );
+ $this->assertEquals(
+ $this->SelectField->getData()["sep"], $g_args["Global_delimiter"]
+ );
+ }
+
+ protected function setUp() {
+ parent::setUp();
+ $this->parser = $GLOBALS['wgParser'];
+ $this->parser->setTitle( Title::newFromText( 'NO TITLE' ) );
+ $this->parser->mOptions = new ParserOptions();
+ $this->parser->mOutput = new ParserOutput(
+ ); // Stored result thats passed back to Parser Object
+ $this->parser->clearState();
+ $this->SelectField = new SelectField( $this->parser );
+ }
+
+ protected function tearDown() {
+ unset( $this->SelectField );
+ parent::tearDown();
+ }
+
+
+}
diff --git a/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/SemanticFormsSelectInputTest.php b/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/SemanticFormsSelectInputTest.php
new file mode 100644
index 00000000..dac06300
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/tests/phpunit/Unit/SemanticFormsSelectInputTest.php
@@ -0,0 +1,84 @@
+<?php
+
+namespace SFS\Tests;
+
+use SFS\SemanticFormsSelectInput;
+
+/**
+ * @covers \SFS\SemanticFormsSelectInput
+ * @group semantic-forms-select
+ *
+ * @license GNU GPL v2+
+ * @since 3.0.0
+ *
+ * @author FelixAba
+ */
+class SemanticFormsSelectInputTest extends \PHPUnit_Framework_TestCase {
+
+ private $SFSInput;
+
+
+ protected function setUp() {
+ parent::setUp();
+ $value = '';
+ $inputName = '';
+ $isMandatory = false;
+ $isDisabled = false;
+
+ $otherArgs = [ 'template' => 'Foo', 'field' => '',
+ 'function' => 'Bar', 'is_list' => true ];
+
+ $parserOutput = $this->getMockBuilder( '\ParserOutput' )
+ ->disableOriginalConstructor()->getMock();
+
+ $parser = $this->getMockBuilder( '\Parser' )
+ ->disableOriginalConstructor()->getMock();
+
+ $parser->expects( $this->any() )->method( 'getOutput' )->will(
+ $this->returnValue( $parserOutput )
+ );
+ $this->SFSInput = new SemanticFormsSelectInput(
+ $value, $inputName, $isMandatory, $isDisabled, $otherArgs
+ );
+ }
+
+ protected function tearDown() {
+ unset( $this->SelectField );
+ parent::tearDown();
+ }
+
+ public function testCanConstruct() {
+
+ $this->assertInstanceOf(
+ '\SFS\SemanticFormsSelectInput', $this->SFSInput
+ );
+ }
+
+ public function testGetHTMLText() {
+
+ $this->assertInternalType(
+ 'string', $this->SFSInput->getHtmlText()
+ );
+ }
+
+ public function testGetName() {
+
+ $this->assertEquals(
+ 'SF_Select', $this->SFSInput->getName()
+ );
+ }
+
+ public function testGetParameters() {
+
+ $this->assertInternalType( 'array', $this->SFSInput->getParameters() );
+ }
+
+
+ public function testGetResourceModuleNames() {
+ $rsmn = [ 'ext.sf_select.scriptselect' ];
+
+ $this->assertEquals( $rsmn, $this->SFSInput->getResourceModuleNames() );
+ }
+
+}
+
diff --git a/www/wiki/extensions/SemanticFormsSelect/tests/travis/install-mediawiki.sh b/www/wiki/extensions/SemanticFormsSelect/tests/travis/install-mediawiki.sh
new file mode 100644
index 00000000..0fe25fb1
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/tests/travis/install-mediawiki.sh
@@ -0,0 +1,43 @@
+#!/bin/bash
+set -ex
+
+cd ..
+
+## Use sha (master@5cc1f1d) to download a particular commit to avoid breakages
+## introduced by MediaWiki core
+if [[ "$MW" == *@* ]]
+then
+ arrMw=(${MW//@/ })
+ MW=${arrMw[0]}
+ SOURCE=${arrMw[1]}
+else
+ MW=$MW
+ SOURCE=$MW
+fi
+
+wget https://github.com/wikimedia/mediawiki/archive/$SOURCE.tar.gz -O $MW.tar.gz
+
+tar -zxf $MW.tar.gz
+mv mediawiki-* mw
+
+cd mw
+
+## MW 1.25+ requires Psr\Logger
+if [ -f composer.json ]
+then
+ composer self-update
+ composer install --prefer-source
+fi
+
+if [ "$DB" == "postgres" ]
+then
+ # See #458
+ sudo /etc/init.d/postgresql stop
+ sudo /etc/init.d/postgresql start
+
+ psql -c 'create database its_a_mw;' -U postgres
+ php maintenance/install.php --dbtype $DB --dbuser postgres --dbname its_a_mw --pass nyan TravisWiki admin --scriptpath /TravisWiki
+else
+ mysql -e 'create database its_a_mw;'
+ php maintenance/install.php --dbtype $DB --dbuser root --dbname its_a_mw --dbpath $(pwd) --pass nyan TravisWiki admin --scriptpath /TravisWiki
+fi
diff --git a/www/wiki/extensions/SemanticFormsSelect/tests/travis/install-semantic-forms-select.sh b/www/wiki/extensions/SemanticFormsSelect/tests/travis/install-semantic-forms-select.sh
new file mode 100644
index 00000000..8ebd83b3
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/tests/travis/install-semantic-forms-select.sh
@@ -0,0 +1,73 @@
+#!/bin/bash
+set -ex
+
+BASE_PATH=$(pwd)
+MW_INSTALL_PATH=$BASE_PATH/../mw
+
+# Run Composer installation from the MW root directory
+function installToMediaWikiRoot {
+ echo -e "Running MW root composer install build on $TRAVIS_BRANCH \n"
+
+ cd $MW_INSTALL_PATH
+
+ if [ "$PHPUNIT" != "" ]
+ then
+ composer require 'phpunit/phpunit='$PHPUNIT --prefer-source --update-with-dependencies
+ else
+ composer require 'phpunit/phpunit=3.7.*' --prefer-source --update-with-dependencies
+ fi
+
+ if [ "$SFS" != "" ]
+ then
+ composer require 'mediawiki/semantic-forms-select='$SMT --prefer-source --update-with-dependencies
+ else
+ composer init --stability dev
+ composer require "mediawiki/semantic-forms-select:dev-master" --prefer-source --dev --update-with-dependencies
+
+ cd extensions
+ cd SemanticFormsSelect
+
+ # Pull request number, "false" if it's not a pull request
+ # After the install via composer an additional get fetch is carried out to
+ # update th repository to make sure that the latests code changes are
+ # deployed for testing
+ if [ "$TRAVIS_PULL_REQUEST" != "false" ]
+ then
+ git fetch origin +refs/pull/"$TRAVIS_PULL_REQUEST"/merge:
+ git checkout -qf FETCH_HEAD
+ else
+ git fetch origin "$TRAVIS_BRANCH"
+ git checkout -qf FETCH_HEAD
+ fi
+
+ cd ../..
+ fi
+
+ # Rebuild the class map for added classes during git fetch
+ composer dump-autoload
+}
+
+function updateConfiguration {
+
+ cd $MW_INSTALL_PATH
+
+ # Site language
+ if [ "$SITELANG" != "" ]
+ then
+ echo '$wgLanguageCode = "'$SITELANG'";' >> LocalSettings.php
+ fi
+
+ echo 'wfLoadExtension( "PageForms" );' >> LocalSettings.php
+ echo 'wfLoadExtension( "SemanticFormsSelect" );' >> LocalSettings.php
+
+ echo 'error_reporting(E_ALL| E_STRICT);' >> LocalSettings.php
+ echo 'ini_set("display_errors", 1);' >> LocalSettings.php
+ echo '$wgShowExceptionDetails = true;' >> LocalSettings.php
+ echo '$wgDevelopmentWarnings = true;' >> LocalSettings.php
+ echo "putenv( 'MW_INSTALL_PATH=$(pwd)' );" >> LocalSettings.php
+
+ php maintenance/update.php --quick
+}
+
+installToMediaWikiRoot
+updateConfiguration
diff --git a/www/wiki/extensions/SemanticFormsSelect/tests/travis/run-tests.sh b/www/wiki/extensions/SemanticFormsSelect/tests/travis/run-tests.sh
new file mode 100644
index 00000000..66104ddd
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/tests/travis/run-tests.sh
@@ -0,0 +1,14 @@
+#! /bin/bash
+set -ex
+
+BASE_PATH=$(pwd)
+MW_INSTALL_PATH=$BASE_PATH/../mw
+
+cd $MW_INSTALL_PATH/extensions/SemanticFormsSelect
+
+if [ "$TYPE" == "coverage" ]
+then
+ composer phpunit -- --coverage-clover $BASE_PATH/build/coverage.clover
+else
+ composer phpunit
+fi
diff --git a/www/wiki/extensions/SemanticFormsSelect/tests/travis/upload-coverage-report.sh b/www/wiki/extensions/SemanticFormsSelect/tests/travis/upload-coverage-report.sh
new file mode 100644
index 00000000..aff95cf7
--- /dev/null
+++ b/www/wiki/extensions/SemanticFormsSelect/tests/travis/upload-coverage-report.sh
@@ -0,0 +1,10 @@
+#! /bin/bash
+set -ex
+
+BASE_PATH=$(pwd)
+
+if [ "$TYPE" == "coverage" ]
+then
+ wget https://scrutinizer-ci.com/ocular.phar
+ php ocular.phar code-coverage:upload --format=php-clover $BASE_PATH/build/coverage.clover
+fi \ No newline at end of file