├── .gitattributes ├── .github ├── FUNDING.yml ├── dependabot.yml └── workflows │ ├── ci.yml │ └── installMediaWiki.sh ├── .gitignore ├── COPYING ├── Makefile ├── README.md ├── composer.json ├── extension.json ├── i18n ├── Network.i18n.alias.php ├── _MagicWords.php ├── ce.json ├── de.json ├── en.json ├── fa.json ├── fr.json ├── he.json ├── ia.json ├── ja.json ├── ko.json ├── krc.json ├── lt.json ├── mk.json ├── nb.json ├── nl.json ├── pl.json ├── pt-br.json ├── pt.json ├── qqq.json ├── roa-tara.json ├── ru.json ├── sl.json ├── sv.json ├── tr.json ├── uk.json ├── zh-hans.json └── zh-hant.json ├── phpcs.xml ├── phpstan.neon ├── phpunit.xml.dist ├── psalm.xml ├── resources ├── js │ ├── ApiConnectionsBuilder.js │ ├── ApiPageConnectionRepo.js │ ├── Network.js │ ├── NetworkData.js │ ├── PageExclusionManager.js │ ├── SpecialForm.js │ └── index.js ├── lib │ └── vis-network.js └── network.css ├── src ├── EntryPoints │ ├── NetworkFunction.php │ └── SpecialNetwork.php ├── Extension.php └── NetworkFunction │ ├── AbstractNetworkPresenter.php │ ├── NetworkConfig.php │ ├── NetworkPresenter.php │ ├── NetworkUseCase.php │ ├── ParserFunctionNetworkPresenter.php │ ├── RequestModel.php │ ├── ResponseModel.php │ └── SpecialNetworkPresenter.php └── tests ├── bootstrap.php ├── js ├── MultiPageConnectionsTest.js ├── PageBlacklistTest.js ├── SinglePageConnectionsTest.js └── stub │ ├── Cats.js │ ├── MultiPage.js │ └── index.js └── php ├── NetworkFunction ├── NetworkUseCaseTest.php └── SpyNetworkPresenter.php └── NetworkFunctionIntegrationTest.php /.gitattributes: -------------------------------------------------------------------------------- 1 | .github/network.png export-ignore 2 | .github/youtube.png export-ignore 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: JeroenDeDauw # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 2 | 3 | version: 2 4 | updates: 5 | - package-ecosystem: "composer" 6 | directory: "/" # Location of package manifests 7 | schedule: 8 | interval: "daily" 9 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | # Controls when the action will run. Triggers the workflow on push or pull request 4 | # events but only for the master branch 5 | on: 6 | push: 7 | branches: [ master ] 8 | pull_request: 9 | branches: [ "*" ] 10 | 11 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 12 | jobs: 13 | test: 14 | name: "PHPUnit: MW ${{ matrix.mw }}, PHP ${{ matrix.php }}" 15 | continue-on-error: ${{ matrix.experimental }} 16 | 17 | strategy: 18 | matrix: 19 | include: 20 | - mw: 'REL1_39' 21 | php: 7.4 22 | experimental: false 23 | - mw: 'REL1_40' 24 | php: 8.0 25 | experimental: false 26 | - mw: 'REL1_41' 27 | php: 8.1 28 | experimental: false 29 | - mw: 'REL1_42' 30 | php: 8.2 31 | experimental: false 32 | - mw: 'REL1_43' 33 | php: 8.3 34 | experimental: false 35 | - mw: 'master' 36 | php: 8.4 37 | experimental: true 38 | 39 | runs-on: ubuntu-latest 40 | 41 | defaults: 42 | run: 43 | working-directory: mediawiki 44 | 45 | # Steps represent a sequence of tasks that will be executed as part of the job 46 | steps: 47 | - name: Setup PHP 48 | uses: shivammathur/setup-php@v2 49 | with: 50 | php-version: ${{ matrix.php }} 51 | extensions: mbstring, intl 52 | tools: composer 53 | 54 | - name: Cache MediaWiki 55 | id: cache-mediawiki 56 | uses: actions/cache@v4 57 | with: 58 | path: | 59 | mediawiki 60 | !mediawiki/extensions/ 61 | !mediawiki/vendor/ 62 | key: mw_${{ matrix.mw }}-php${{ matrix.php }}-v21 63 | 64 | - name: Cache Composer cache 65 | uses: actions/cache@v4 66 | with: 67 | path: ~/.composer/cache 68 | key: composer-php${{ matrix.php }} 69 | 70 | - uses: actions/checkout@v4 71 | with: 72 | path: EarlyCopy 73 | 74 | - name: Install MediaWiki 75 | if: steps.cache-mediawiki.outputs.cache-hit != 'true' 76 | working-directory: ~ 77 | run: bash EarlyCopy/.github/workflows/installMediaWiki.sh ${{ matrix.mw }} Network 78 | 79 | - uses: actions/checkout@v4 80 | with: 81 | path: mediawiki/extensions/Network 82 | 83 | - name: Composer update 84 | run: composer update 85 | 86 | - name: Run PHPUnit 87 | run: php tests/phpunit/phpunit.php -c extensions/Network/phpunit.xml.dist 88 | 89 | static-analysis: 90 | name: "Static Analysis: MW ${{ matrix.mw }}, PHP ${{ matrix.php }}" 91 | 92 | strategy: 93 | matrix: 94 | include: 95 | - mw: 'REL1_43' 96 | php: '8.3' 97 | 98 | runs-on: ubuntu-latest 99 | 100 | defaults: 101 | run: 102 | working-directory: mediawiki/extensions/Network 103 | 104 | steps: 105 | - name: Setup PHP 106 | uses: shivammathur/setup-php@v2 107 | with: 108 | php-version: ${{ matrix.php }} 109 | extensions: mbstring 110 | tools: composer, cs2pr 111 | 112 | - name: Cache MediaWiki 113 | id: cache-mediawiki 114 | uses: actions/cache@v4 115 | with: 116 | path: | 117 | mediawiki 118 | !mediawiki/extensions/ 119 | !mediawiki/vendor/ 120 | key: mediawiki-cache 121 | 122 | - name: Cache Composer cache 123 | uses: actions/cache@v4 124 | with: 125 | path: ~/.composer/cache 126 | key: composer_static_analysis 127 | 128 | - uses: actions/checkout@v4 129 | with: 130 | path: EarlyCopy 131 | 132 | - name: Install MediaWiki 133 | if: steps.cache-mediawiki.outputs.cache-hit != 'true' 134 | working-directory: ~ 135 | run: bash EarlyCopy/.github/workflows/installMediaWiki.sh ${{ matrix.mw }} Network 136 | 137 | - uses: actions/checkout@v4 138 | with: 139 | path: mediawiki/extensions/Network 140 | 141 | - name: Composer install 142 | run: composer install --no-progress --no-suggest --no-interaction --prefer-dist --optimize-autoloader 143 | 144 | - name: PHPStan 145 | run: php vendor/bin/phpstan analyse --error-format=checkstyle --no-progress | cs2pr 146 | 147 | - name: Psalm 148 | run: php vendor/bin/psalm 149 | 150 | code-style: 151 | name: "Code style: MW ${{ matrix.mw }}, PHP ${{ matrix.php }}" 152 | 153 | strategy: 154 | matrix: 155 | include: 156 | - mw: 'REL1_43' 157 | php: '8.3' 158 | 159 | runs-on: ubuntu-latest 160 | 161 | defaults: 162 | run: 163 | working-directory: mediawiki/extensions/Network 164 | 165 | steps: 166 | - name: Setup PHP 167 | uses: shivammathur/setup-php@v2 168 | with: 169 | php-version: ${{ matrix.php }} 170 | extensions: mbstring, intl, php-ast 171 | tools: composer 172 | 173 | - name: Cache MediaWiki 174 | id: cache-mediawiki 175 | uses: actions/cache@v4 176 | with: 177 | path: | 178 | mediawiki 179 | !mediawiki/extensions/ 180 | !mediawiki/vendor/ 181 | key: mw_static_analysis 182 | 183 | - name: Cache Composer cache 184 | uses: actions/cache@v4 185 | with: 186 | path: ~/.composer/cache 187 | key: composer_static_analysis 188 | 189 | - uses: actions/checkout@v4 190 | with: 191 | path: EarlyCopy 192 | 193 | - name: Install MediaWiki 194 | if: steps.cache-mediawiki.outputs.cache-hit != 'true' 195 | working-directory: ~ 196 | run: bash EarlyCopy/.github/workflows/installMediaWiki.sh ${{ matrix.mw }} Network 197 | 198 | - uses: actions/checkout@v4 199 | with: 200 | path: mediawiki/extensions/Network 201 | 202 | - name: Composer allow-plugins 203 | run: composer config --no-plugins allow-plugins.composer/installers true 204 | 205 | - name: Composer install 206 | run: composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader 207 | 208 | - run: vendor/bin/phpcs -p -s -------------------------------------------------------------------------------- /.github/workflows/installMediaWiki.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | set -ex 4 | 5 | MW_BRANCH=$1 6 | EXTENSION_NAME=$2 7 | 8 | wget "https://github.com/wikimedia/mediawiki/archive/refs/heads/$MW_BRANCH.tar.gz" -nv 9 | 10 | tar -zxf $MW_BRANCH.tar.gz 11 | mv mediawiki-$MW_BRANCH mediawiki 12 | 13 | cd mediawiki 14 | 15 | composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader 16 | 17 | php maintenance/install.php \ 18 | --dbtype sqlite \ 19 | --dbuser root \ 20 | --dbname mw \ 21 | --dbpath "$(pwd)" \ 22 | --scriptpath="" \ 23 | --pass AdminPassword WikiName AdminUser 24 | 25 | echo 'error_reporting(E_ALL| E_STRICT);' >> LocalSettings.php 26 | echo 'ini_set("display_errors", 1);' >> LocalSettings.php 27 | echo '$wgShowExceptionDetails = true;' >> LocalSettings.php 28 | echo '$wgShowDBErrorBacktrace = true;' >> LocalSettings.php 29 | echo '$wgDevelopmentWarnings = true;' >> LocalSettings.php 30 | 31 | echo 'wfLoadExtension( "'$EXTENSION_NAME'" );' >> LocalSettings.php 32 | 33 | cat <> composer.local.json 34 | { 35 | "require": {}, 36 | "extra": { 37 | "merge-plugin": { 38 | "merge-dev": true, 39 | "include": [ 40 | "extensions/$EXTENSION_NAME/composer.json" 41 | ] 42 | } 43 | } 44 | } 45 | EOT -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | vendor/ 2 | composer.lock 3 | .phpunit.result.cache 4 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | The license text below "----" applies to all files within this distribution, other 2 | than those that are in a directory which contains files named "LICENSE" or 3 | "COPYING", or a subdirectory thereof. For those files, the license text contained in 4 | said file overrides any license information contained in directories of smaller depth. 5 | Alternative licenses are typically used for software that is provided by external 6 | parties, and merely packaged with this software for convenience. 7 | ---- 8 | 9 | GNU GENERAL PUBLIC LICENSE 10 | Version 2, June 1991 11 | 12 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 13 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 14 | Everyone is permitted to copy and distribute verbatim copies 15 | of this license document, but changing it is not allowed. 16 | 17 | Preamble 18 | 19 | The licenses for most software are designed to take away your 20 | freedom to share and change it. By contrast, the GNU General Public 21 | License is intended to guarantee your freedom to share and change free 22 | software--to make sure the software is free for all its users. This 23 | General Public License applies to most of the Free Software 24 | Foundation's software and to any other program whose authors commit to 25 | using it. (Some other Free Software Foundation software is covered by 26 | the GNU Lesser General Public License instead.) You can apply it to 27 | your programs, too. 28 | 29 | When we speak of free software, we are referring to freedom, not 30 | price. Our General Public Licenses are designed to make sure that you 31 | have the freedom to distribute copies of free software (and charge for 32 | this service if you wish), that you receive source code or can get it 33 | if you want it, that you can change the software or use pieces of it 34 | in new free programs; and that you know you can do these things. 35 | 36 | To protect your rights, we need to make restrictions that forbid 37 | anyone to deny you these rights or to ask you to surrender the rights. 38 | These restrictions translate to certain responsibilities for you if you 39 | distribute copies of the software, or if you modify it. 40 | 41 | For example, if you distribute copies of such a program, whether 42 | gratis or for a fee, you must give the recipients all the rights that 43 | you have. You must make sure that they, too, receive or can get the 44 | source code. And you must show them these terms so they know their 45 | rights. 46 | 47 | We protect your rights with two steps: (1) copyright the software, and 48 | (2) offer you this license which gives you legal permission to copy, 49 | distribute and/or modify the software. 50 | 51 | Also, for each author's protection and ours, we want to make certain 52 | that everyone understands that there is no warranty for this free 53 | software. If the software is modified by someone else and passed on, we 54 | want its recipients to know that what they have is not the original, so 55 | that any problems introduced by others will not reflect on the original 56 | authors' reputations. 57 | 58 | Finally, any free program is threatened constantly by software 59 | patents. We wish to avoid the danger that redistributors of a free 60 | program will individually obtain patent licenses, in effect making the 61 | program proprietary. To prevent this, we have made it clear that any 62 | patent must be licensed for everyone's free use or not licensed at all. 63 | 64 | The precise terms and conditions for copying, distribution and 65 | modification follow. 66 | 67 | GNU GENERAL PUBLIC LICENSE 68 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 69 | 70 | 0. This License applies to any program or other work which contains 71 | a notice placed by the copyright holder saying it may be distributed 72 | under the terms of this General Public License. The "Program", below, 73 | refers to any such program or work, and a "work based on the Program" 74 | means either the Program or any derivative work under copyright law: 75 | that is to say, a work containing the Program or a portion of it, 76 | either verbatim or with modifications and/or translated into another 77 | language. (Hereinafter, translation is included without limitation in 78 | the term "modification".) Each licensee is addressed as "you". 79 | 80 | Activities other than copying, distribution and modification are not 81 | covered by this License; they are outside its scope. The act of 82 | running the Program is not restricted, and the output from the Program 83 | is covered only if its contents constitute a work based on the 84 | Program (independent of having been made by running the Program). 85 | Whether that is true depends on what the Program does. 86 | 87 | 1. You may copy and distribute verbatim copies of the Program's 88 | source code as you receive it, in any medium, provided that you 89 | conspicuously and appropriately publish on each copy an appropriate 90 | copyright notice and disclaimer of warranty; keep intact all the 91 | notices that refer to this License and to the absence of any warranty; 92 | and give any other recipients of the Program a copy of this License 93 | along with the Program. 94 | 95 | You may charge a fee for the physical act of transferring a copy, and 96 | you may at your option offer warranty protection in exchange for a fee. 97 | 98 | 2. You may modify your copy or copies of the Program or any portion 99 | of it, thus forming a work based on the Program, and copy and 100 | distribute such modifications or work under the terms of Section 1 101 | above, provided that you also meet all of these conditions: 102 | 103 | a) You must cause the modified files to carry prominent notices 104 | stating that you changed the files and the date of any change. 105 | 106 | b) You must cause any work that you distribute or publish, that in 107 | whole or in part contains or is derived from the Program or any 108 | part thereof, to be licensed as a whole at no charge to all third 109 | parties under the terms of this License. 110 | 111 | c) If the modified program normally reads commands interactively 112 | when run, you must cause it, when started running for such 113 | interactive use in the most ordinary way, to print or display an 114 | announcement including an appropriate copyright notice and a 115 | notice that there is no warranty (or else, saying that you provide 116 | a warranty) and that users may redistribute the program under 117 | these conditions, and telling the user how to view a copy of this 118 | License. (Exception: if the Program itself is interactive but 119 | does not normally print such an announcement, your work based on 120 | the Program is not required to print an announcement.) 121 | 122 | These requirements apply to the modified work as a whole. If 123 | identifiable sections of that work are not derived from the Program, 124 | and can be reasonably considered independent and separate works in 125 | themselves, then this License, and its terms, do not apply to those 126 | sections when you distribute them as separate works. But when you 127 | distribute the same sections as part of a whole which is a work based 128 | on the Program, the distribution of the whole must be on the terms of 129 | this License, whose permissions for other licensees extend to the 130 | entire whole, and thus to each and every part regardless of who wrote it. 131 | 132 | Thus, it is not the intent of this section to claim rights or contest 133 | your rights to work written entirely by you; rather, the intent is to 134 | exercise the right to control the distribution of derivative or 135 | collective works based on the Program. 136 | 137 | In addition, mere aggregation of another work not based on the Program 138 | with the Program (or with a work based on the Program) on a volume of 139 | a storage or distribution medium does not bring the other work under 140 | the scope of this License. 141 | 142 | 3. You may copy and distribute the Program (or a work based on it, 143 | under Section 2) in object code or executable form under the terms of 144 | Sections 1 and 2 above provided that you also do one of the following: 145 | 146 | a) Accompany it with the complete corresponding machine-readable 147 | source code, which must be distributed under the terms of Sections 148 | 1 and 2 above on a medium customarily used for software interchange; or, 149 | 150 | b) Accompany it with a written offer, valid for at least three 151 | years, to give any third party, for a charge no more than your 152 | cost of physically performing source distribution, a complete 153 | machine-readable copy of the corresponding source code, to be 154 | distributed under the terms of Sections 1 and 2 above on a medium 155 | customarily used for software interchange; or, 156 | 157 | c) Accompany it with the information you received as to the offer 158 | to distribute corresponding source code. (This alternative is 159 | allowed only for noncommercial distribution and only if you 160 | received the program in object code or executable form with such 161 | an offer, in accord with Subsection b above.) 162 | 163 | The source code for a work means the preferred form of the work for 164 | making modifications to it. For an executable work, complete source 165 | code means all the source code for all modules it contains, plus any 166 | associated interface definition files, plus the scripts used to 167 | control compilation and installation of the executable. However, as a 168 | special exception, the source code distributed need not include 169 | anything that is normally distributed (in either source or binary 170 | form) with the major components (compiler, kernel, and so on) of the 171 | operating system on which the executable runs, unless that component 172 | itself accompanies the executable. 173 | 174 | If distribution of executable or object code is made by offering 175 | access to copy from a designated place, then offering equivalent 176 | access to copy the source code from the same place counts as 177 | distribution of the source code, even though third parties are not 178 | compelled to copy the source along with the object code. 179 | 180 | 4. You may not copy, modify, sublicense, or distribute the Program 181 | except as expressly provided under this License. Any attempt 182 | otherwise to copy, modify, sublicense or distribute the Program is 183 | void, and will automatically terminate your rights under this License. 184 | However, parties who have received copies, or rights, from you under 185 | this License will not have their licenses terminated so long as such 186 | parties remain in full compliance. 187 | 188 | 5. You are not required to accept this License, since you have not 189 | signed it. However, nothing else grants you permission to modify or 190 | distribute the Program or its derivative works. These actions are 191 | prohibited by law if you do not accept this License. Therefore, by 192 | modifying or distributing the Program (or any work based on the 193 | Program), you indicate your acceptance of this License to do so, and 194 | all its terms and conditions for copying, distributing or modifying 195 | the Program or works based on it. 196 | 197 | 6. Each time you redistribute the Program (or any work based on the 198 | Program), the recipient automatically receives a license from the 199 | original licensor to copy, distribute or modify the Program subject to 200 | these terms and conditions. You may not impose any further 201 | restrictions on the recipients' exercise of the rights granted herein. 202 | You are not responsible for enforcing compliance by third parties to 203 | this License. 204 | 205 | 7. If, as a consequence of a court judgment or allegation of patent 206 | infringement or for any other reason (not limited to patent issues), 207 | conditions are imposed on you (whether by court order, agreement or 208 | otherwise) that contradict the conditions of this License, they do not 209 | excuse you from the conditions of this License. If you cannot 210 | distribute so as to satisfy simultaneously your obligations under this 211 | License and any other pertinent obligations, then as a consequence you 212 | may not distribute the Program at all. For example, if a patent 213 | license would not permit royalty-free redistribution of the Program by 214 | all those who receive copies directly or indirectly through you, then 215 | the only way you could satisfy both it and this License would be to 216 | refrain entirely from distribution of the Program. 217 | 218 | If any portion of this section is held invalid or unenforceable under 219 | any particular circumstance, the balance of the section is intended to 220 | apply and the section as a whole is intended to apply in other 221 | circumstances. 222 | 223 | It is not the purpose of this section to induce you to infringe any 224 | patents or other property right claims or to contest validity of any 225 | such claims; this section has the sole purpose of protecting the 226 | integrity of the free software distribution system, which is 227 | implemented by public license practices. Many people have made 228 | generous contributions to the wide range of software distributed 229 | through that system in reliance on consistent application of that 230 | system; it is up to the author/donor to decide if he or she is willing 231 | to distribute software through any other system and a licensee cannot 232 | impose that choice. 233 | 234 | This section is intended to make thoroughly clear what is believed to 235 | be a consequence of the rest of this License. 236 | 237 | 8. If the distribution and/or use of the Program is restricted in 238 | certain countries either by patents or by copyrighted interfaces, the 239 | original copyright holder who places the Program under this License 240 | may add an explicit geographical distribution limitation excluding 241 | those countries, so that distribution is permitted only in or among 242 | countries not thus excluded. In such case, this License incorporates 243 | the limitation as if written in the body of this License. 244 | 245 | 9. The Free Software Foundation may publish revised and/or new versions 246 | of the General Public License from time to time. Such new versions will 247 | be similar in spirit to the present version, but may differ in detail to 248 | address new problems or concerns. 249 | 250 | Each version is given a distinguishing version number. If the Program 251 | specifies a version number of this License which applies to it and "any 252 | later version", you have the option of following the terms and conditions 253 | either of that version or of any later version published by the Free 254 | Software Foundation. If the Program does not specify a version number of 255 | this License, you may choose any version ever published by the Free Software 256 | Foundation. 257 | 258 | 10. If you wish to incorporate parts of the Program into other free 259 | programs whose distribution conditions are different, write to the author 260 | to ask for permission. For software which is copyrighted by the Free 261 | Software Foundation, write to the Free Software Foundation; we sometimes 262 | make exceptions for this. Our decision will be guided by the two goals 263 | of preserving the free status of all derivatives of our free software and 264 | of promoting the sharing and reuse of software generally. 265 | 266 | NO WARRANTY 267 | 268 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 269 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 270 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 271 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 272 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 273 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 274 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 275 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 276 | REPAIR OR CORRECTION. 277 | 278 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 279 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 280 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 281 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 282 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 283 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 284 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 285 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 286 | POSSIBILITY OF SUCH DAMAGES. 287 | 288 | END OF TERMS AND CONDITIONS 289 | 290 | How to Apply These Terms to Your New Programs 291 | 292 | If you develop a new program, and you want it to be of the greatest 293 | possible use to the public, the best way to achieve this is to make it 294 | free software which everyone can redistribute and change under these terms. 295 | 296 | To do so, attach the following notices to the program. It is safest 297 | to attach them to the start of each source file to most effectively 298 | convey the exclusion of warranty; and each file should have at least 299 | the "copyright" line and a pointer to where the full notice is found. 300 | 301 | 302 | Copyright (C) 303 | 304 | This program is free software; you can redistribute it and/or modify 305 | it under the terms of the GNU General Public License as published by 306 | the Free Software Foundation; either version 2 of the License, or 307 | (at your option) any later version. 308 | 309 | This program is distributed in the hope that it will be useful, 310 | but WITHOUT ANY WARRANTY; without even the implied warranty of 311 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 312 | GNU General Public License for more details. 313 | 314 | You should have received a copy of the GNU General Public License along 315 | with this program; if not, write to the Free Software Foundation, Inc., 316 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 317 | 318 | Also add information on how to contact you by electronic and paper mail. 319 | 320 | If the program is interactive, make it output a short notice like this 321 | when it starts in an interactive mode: 322 | 323 | Gnomovision version 69, Copyright (C) year name of author 324 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 325 | This is free software, and you are welcome to redistribute it 326 | under certain conditions; type `show c' for details. 327 | 328 | The hypothetical commands `show w' and `show c' should show the appropriate 329 | parts of the General Public License. Of course, the commands you use may 330 | be called something other than `show w' and `show c'; they could even be 331 | mouse-clicks or menu items--whatever suits your program. 332 | 333 | You should also get your employer (if you work as a programmer) or your 334 | school, if any, to sign a "copyright disclaimer" for the program, if 335 | necessary. Here is a sample; alter the names: 336 | 337 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 338 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 339 | 340 | , 1 April 1989 341 | Ty Coon, President of Vice 342 | 343 | This General Public License does not permit incorporating your program into 344 | proprietary programs. If your program is a subroutine library, you may 345 | consider it more useful to permit linking proprietary applications with the 346 | library. If this is what you want to do, use the GNU Lesser General 347 | Public License instead of this License. 348 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: ci cs test phpunit phpcs psalm phpstan 2 | 3 | ci: test cs 4 | cs: phpcs phpstan psalm 5 | test: phpunit 6 | 7 | phpunit: 8 | php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist 9 | 10 | phpcs: 11 | cd ../.. && vendor/bin/phpcs -p -s --standard=$(shell pwd)/phpcs.xml 12 | 13 | psalm: 14 | ../../vendor/bin/psalm --config=psalm.xml 15 | 16 | phpstan: 17 | ../../vendor/bin/phpstan analyse --configuration=phpstan.neon --memory-limit=2G 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Network 2 | 3 | [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/ProfessionalWiki/Network/ci.yml?branch=master)](https://github.com/ProfessionalWiki/Network/actions?query=workflow%3ACI) 4 | [![Latest Stable Version](https://poser.pugx.org/professional-wiki/network/v/stable)](https://packagist.org/packages/professional-wiki/network) 5 | [![Download count](https://poser.pugx.org/professional-wiki/network/downloads)](https://packagist.org/packages/professional-wiki/network) 6 | [![License](https://poser.pugx.org/professional-wiki/network/license)](LICENSE) 7 | 8 | The **Network** extension allows visualizing connections between wiki pages via an interactive network graph. 9 | 10 | It was created by [Professional Wiki](https://professional.wiki/) and funded by 11 | [KDZ - Centre for Public Administration Research](https://www.kdz.eu/). 12 | 13 | 14 | 15 | 16 | - [Platform requirements](#platform-requirements) 17 | - [Installation](#installation) 18 | - [Usage](#usage) 19 | * [Parameters](#parameters) 20 | * [Layout CSS](#layout-css) 21 | * [Examples](#examples) 22 | + [Options parameter](#options-parameter) 23 | + [Using templates](#using-templates) 24 | - [PHP Configuration](#php-configuration) 25 | - [Limitations](#limitations) 26 | - [Contribution and support](#contribution-and-support) 27 | - [Development](#development) 28 | - [License](#license) 29 | - [Release notes](#release-notes) 30 | 31 | ## Platform requirements 32 | 33 | * PHP 7.4 or later (tested up to PHP 8.4) 34 | * MediaWiki 1.39.x or later (tested up to 1.43.x) 35 | 36 | See the [release notes](#release-notes) for more information on the different versions of Network. 37 | 38 | ## Installation 39 | 40 | The recommended way to install Network is using [Composer](https://getcomposer.org) with 41 | [MediaWiki's built-in support for Composer](https://professional.wiki/en/articles/installing-mediawiki-extensions-with-composer). 42 | 43 | On the commandline, go to your wikis root directory. Then run these two commands: 44 | 45 | ```shell script 46 | COMPOSER=composer.local.json composer require --no-update professional-wiki/network:~2.0 47 | composer update professional-wiki/network --no-dev -o 48 | ``` 49 | 50 | Then enable the extension by adding the following to the bottom of your wikis `LocalSettings.php` file: 51 | 52 | ```php 53 | wfLoadExtension( 'Network' ); 54 | ``` 55 | 56 | You can verify the extension was enabled successfully by opening your wikis Special:Version page in your browser. 57 | 58 | Finally, please consider [sponsoring the project]. 59 | 60 | ## Usage 61 | 62 | Minimal example 63 | 64 | ``` 65 | {{#network:}} 66 | ``` 67 | 68 | Example with parameters 69 | 70 | ``` 71 | {{#network:Page1 | Page2 | Page3 72 | | class = col-lg-3 mt-0 73 | | exclude = Main Page ; Sitemap 74 | }} 75 | ``` 76 | 77 | ### Parameters 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 121 | 122 | 123 | 124 | 125 | 126 | 131 | 132 | 133 | 134 | 135 | 136 | 141 | 142 |
DefaultExample valueDescription
(page or pages)The current pageMyPageThe name of the page to show connections for. Can be specified multiple times. The parameter name is optional. Templates are supported
classcol-lg-3 mt-0Extra css class(es) to add to the network graph
excludeSitemap ; Main PagePages to exclude from the network graph, separated by semicolon
excludedNamespaces2, 4, 8, 12Namespaces to exclude from the network graph by namespace number, separated by comma
options{ "nodes": { "shape": "box" } } 115 | vis.js options in JSON. 116 | Option names and text values both need to be surrounded with double quotes. 117 | Single quotes will not work. Tailing commas also do not work. Two curly brackets closes the parser function, 118 | so if you are putting the JSON directly in the parser function rather than using a template, put a tailing space 119 | or new line after each closing bracket. 120 |
enableDisplayTitletruefalse 127 | Should the display title rather than 128 | the page title be displayed as a node's label? 129 | Overrides the value of the $wgPageNetworkEnableDisplayTitle configuration variable. 130 |
labelMaxLength2030 137 | The text length of a node's label. If the node label must be truncated, an ellipsis (…) will appended. 138 | A value of 0 indicates that the text length is not limited. 139 | Overrides the value of the $wgPageNetworkLabelMaxLength configuration variable. 140 |
143 | 144 | There is also an includable special page, Special:Network, that can be used to construct graphs interactively. The 145 | special page presents a form that can be filled in with the same parameters listed above and submitted to render a 146 | graph. The special page can also be included in other pages for the same results as the parser function with the 147 | following modifications: the pages must be provided in a single `pages` parameter, and all values for the `pages` and 148 | `exclude` parameters must be separated by newlines. For example, 149 | 150 | ``` 151 | {{Special:Network 152 | |pages=Page1 153 | Page2 154 | Page3 155 | | class = col-lg-3 mt-0 156 | | exclude = Main Page 157 | Sitemap 158 | }} 159 | ``` 160 | 161 | ### Layout CSS 162 | 163 | The network graphs are located in a div with class `network-visualization`. The default css for this class is 164 | 165 | ```css 166 | .network-visualization { 167 | width: 100%; 168 | height: 600px; 169 | } 170 | ``` 171 | 172 | You can add extra CSS in [MediaWiki:Common.css]. You can also add extra classes to the div via the `class` parameter. 173 | 174 | ### Node Icons 175 | 176 | By default, nodes are represented by [OOUI icons](https://doc.wikimedia.org/oojs-ui/master/demos/?page=icons&theme=wikimediaui). This is specified in the node 177 | or group options as (excerpted from the full options): 178 | 179 | ```json 180 | "nodes": { 181 | "shape": "image" 182 | }, 183 | "groups": { 184 | "bluelink": { 185 | "image": "resources/lib/ooui/themes/wikimediaui/images/icons/article-rtl-progressive.svg" 186 | }, 187 | "redlink": { 188 | "image": "resources/lib/ooui/themes/wikimediaui/images/icons/articleNotFound-ltr.svg" 189 | }, 190 | "externallink": { 191 | "image": "resources/lib/ooui/themes/wikimediaui/images/icons/linkExternal-ltr-progressive.svg" 192 | } 193 | } 194 | ``` 195 | 196 | If version 5.1 or later of the [Title Icon](https://mediawiki.org/wiki/Extension:Title_Icon) extension is installed and 197 | a page rendered in the graph has at least one title icon defined, one of those title icons will be used for that node's 198 | icon. If there are multiple title icons defined for the page, one will be selected in the order in which they were 199 | parsed on the page. 200 | 201 | ### Examples 202 | 203 | #### Options parameter 204 | 205 | Array of [vis.js options](https://visjs.github.io/vis-network/docs/network/#options) 206 | 207 | ``` 208 | {{#network:Page1 | Page2 | Page3 209 | | options= 210 | { 211 | "autoResize": true, 212 | "nodes": { 213 | "color": "lightblue", 214 | "shape": "box", 215 | "borderWidth": 3, 216 | "font": { "color": "red", "size": 17 } 217 | } 218 | } 219 | }} 220 | ``` 221 | 222 | Wrong: `"font.color": "red"`, right: `"font": { "color": "red" }`, also right: `"font": "14 px arial red"` 223 | 224 | #### Using templates 225 | 226 | ``` 227 | {{#network: {{NetworkPages}} 228 | | class = col-lg-3 mt-0 229 | | options= {{NetworkOptions}} 230 | }} 231 | ``` 232 | 233 | Where `NetworkPages` contains `Page1 | Page2 | Page3` and `NetworkOptions` contains `{ "nodes": { "shape": "box" } } ` 234 | 235 | ## PHP Configuration 236 | 237 | The default value of all parameters can be changed by placing configuration in "LocalSettings.php". 238 | These configuration settings are available: 239 | 240 | * `$wgPageNetworkOptions` – options passed directly to the graph visualization library 241 | * `$wgPageNetworkExcludeTalkPages` - indicates if talk pages should be excluded 242 | * `$wgPageNetworkExcludedNamespaces` - IDs of namespaces to exclude 243 | * `$wgPageNetworkEnableDisplayTitle` - indicates if display title should be used for node labels by default 244 | * `$wgPageNetworkLabelMaxLength` - default maximum length for node labels 245 | 246 | Default values of these configuration settings can be found in "extension.json". Do not change "extension.json". 247 | 248 | **$wgPageNetworkOptions** 249 | 250 | Array of [vis.js options](https://visjs.github.io/vis-network/docs/network/#options). Can be (partially) overridden per network via the `options` parameter 251 | 252 | Example: 253 | 254 | ```php 255 | $wgPageNetworkOptions = [ 256 | 'clickToUse' => true, 257 | 'nodes' => [ 258 | 'borderWidth' => 1, 259 | 'borderWidthSelected' => 2, 260 | 'shape' => 'box', 261 | ], 262 | ]; 263 | ``` 264 | 265 | Predefined style groups exist to represent links to existing pages (group "bluelink"), links to missing pages 266 | (group "redlink"), and links to external web pages (group "externallink"). Styling of those groups can be 267 | overridden site-wide using `$wgPageNetworkOptions` or per graph using the options parameter described above. 268 | 269 | Note: to change the width or height, use CSS, not the network options. 270 | 271 | **$wgPageNetworkExcludeTalkPages** 272 | 273 | Possible values: `true`, `false` 274 | 275 | Default value: `true` (talk pages get excluded) 276 | 277 | **$wgPageNetworkExcludedNamespaces** 278 | 279 | List of IDs of namespaces of which all pages should be excluded. 280 | 281 | Default value: `[ 2, 4, 8, 12 ]` (excluding `User`, `Project`, `MediaWiki` and `Help`) 282 | 283 | Examples: 284 | 285 | Exclude the User and Project namespaces: 286 | `$wgPageNetworkExcludedNamespaces = [ NS_USER, NS_PROJECT ];` 287 | 288 | Keep the default exclusions and also exclude the Talk namespace: 289 | `$wgPageNetworkExcludedNamespaces[] = NS_TALK;` 290 | 291 | See also: https://www.mediawiki.org/wiki/Manual:Namespace#Built-in_namespaces 292 | 293 | **$wgPageNetworkEnableDisplayTitle** 294 | 295 | By default, should the display title rather than the page title be displayed as a node's label? 296 | This can be overridden on a per-graph basis using the `enableDisplayTitle` parameter to #network. 297 | 298 | Possible values: `true`, `false` 299 | 300 | Default value: `true` (use display title for node labels) 301 | 302 | **$wgPageNetworkLabelMaxLength** 303 | 304 | The default text length of a node's label. If the node label must be truncated, an ellipsis (…) will appended. 305 | A value of 0 indicates that the text length is not limited. 306 | This can be overridden on a per-graph basis using the `labelMaxLength` parameter to #network. 307 | 308 | Possible values: 0 or a positive integer value 309 | 310 | Default value: 20 311 | 312 | **$wgRegisterInternalExternals** 313 | By default, MediaWiki does not consider links using external link syntax that point to pages in the wiki to be 314 | internal links. To make them show up as internal links on the network graph, you need to set 315 | `$wgRegisterInternalExternals` to `true` in "LocalSettings.php". If pages already exist in your wiki when that 316 | setting is changed, you will need to run the `refreshLinks.php` MediaWiki maintenance script for the change to 317 | be recognized. 318 | 319 | ## Performance / caching 320 | 321 | This extension bypasses the MediaWiki page cache. This means that your network graphs will always be up to date, 322 | without needing to purge the page cache. 323 | 324 | ## Limitations 325 | 326 | * Styling or grouping per category or namespace is not supported 327 | 328 | Pull requests to remove those limitations are welcome. 329 | 330 | You can also contact [Professional.Wiki](https://professional.wiki/) 331 | for [Professional MediaWiki development](https://professional.wiki/en/mediawiki-development) services. 332 | 333 | ## Contribution and support 334 | 335 | If you want to contribute work to the project please subscribe to the developers mailing list and 336 | have a look at the contribution guideline. 337 | 338 | * [File an issue](https://github.com/ProfessionalWiki/Network/issues) 339 | * [Submit a pull request](https://github.com/ProfessionalWiki/Network/pulls) 340 | * Ask a question on [the mailing list](https://www.semantic-mediawiki.org/wiki/Mailing_list) 341 | 342 | [Professional MediaWiki support](https://professional.wiki/en/support) is available via 343 | [Professional.Wiki](https://professional.wiki/). 344 | 345 | ## Development 346 | 347 | Tests, style checks and static analysis can be run via Make. You can execute these commands on the command line 348 | in the `extensions/Network` directory: 349 | 350 | * `make ci` - run everything 351 | * `make cs` - run style checks 352 | * `make test` - run the tests 353 | 354 | For more details see the `Makefile`. 355 | 356 | The JavaScript tests can only be run by going to the [`Special:JavaScriptTest` page][JS tests]. 357 | 358 | ## License 359 | 360 | [GNU General Public License v2.0 or later (GPL-2.0-or-later)](/COPYING). 361 | 362 | ## Professional Support and Development 363 | 364 | [Professional.Wiki] provides commercial [MediaWiki development], [managed wiki hosting] and [MediaWiki support]. 365 | 366 | ## Release notes 367 | 368 | ### Version 3.0.0 369 | 370 | Release date TDB 371 | 372 | * Raised minimum MediaWiki version from 1.31 to 1.39 373 | 374 | ### Version 2.0.1 375 | 376 | Released on December 9th, 2023. 377 | 378 | * Fixed handling of redirects (thanks @thomas-topway-it) 379 | 380 | ### Version 2.0.0 381 | 382 | Released on July 11th, 2021. 383 | 384 | * Added optional support for using display title for nodes' labels. (thanks @cicalese) 385 | * Added configurable maximum length for node labels. (thanks @cicalese) 386 | * Added tooltips to nodes. (thanks @cicalese) 387 | * Made styling of nodes representing links to existing pages and links to 388 | missing pages configurable by adding vis.js groups named "bluelink" and 389 | "redlink". (thanks @cicalese) 390 | * Added support for OOUI icons. (thanks @cicalese) 391 | * Added support for external links. (thanks @cicalese) 392 | 393 | ### Version 1.4.0 394 | 395 | Released on January 9, 2021. 396 | 397 | * Upgraded viz-network from 8.3.2 to 8.5.5 398 | 399 | ### Version 1.3.0 400 | 401 | Released on September 8, 2020. 402 | 403 | * Added WAI compliance by adding an aria-label attribute to the network canvas 404 | 405 | ### Version 1.2.1 406 | 407 | Released on September 7, 2020. 408 | 409 | * Added compatibility with MediaWiki 1.31 410 | 411 | ### Version 1.2.0 412 | 413 | Released on September 7, 2020. 414 | 415 | * Upgraded viz-network from 7.6 to 8.3 416 | 417 | ### Version 1.1.1 418 | 419 | Released on September 7, 2020. 420 | 421 | * Made code more robust against invalid titles 422 | 423 | ### Version 1.1.0 424 | 425 | Released on August 30, 2020. 426 | 427 | * Added `$wgPageNetworkExcludeTalkPages` option 428 | * Added `$wgPageNetworkExcludedNamespaces` option 429 | * Improved node repulsion physics 430 | 431 | ### Version 1.0.0 432 | 433 | Released on August 11, 2020. 434 | 435 | Initial release 436 | 437 | [MediaWiki:Common.css]: https://www.mediawiki.org/wiki/Manual:Interface/Stylesheets 438 | [JS tests]: https://www.mediawiki.org/wiki/Manual:JavaScript_unit_testing 439 | [sponsoring the project]: https://github.com/sponsors/JeroenDeDauw 440 | [Professional.Wiki]: https://professional.wiki 441 | [MediaWiki development]: https://professional.wiki/en/mediawiki-development 442 | [managed wiki hosting]: https://professional.wiki/en/hosting 443 | [MediaWiki support]: https://professional.wiki/en/support 444 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "professional-wiki/network", 3 | "type": "mediawiki-extension", 4 | "description": "MediaWiki extension for adding interactive network visualizations to your wiki pages", 5 | "keywords": [ 6 | "MediaWiki", 7 | "Network", 8 | "Visualization", 9 | "Chart", 10 | "visjs", 11 | "interactive", 12 | "dynamic", 13 | "graph", 14 | "force-directed graph", 15 | "pages", 16 | "links", 17 | "outgoing links", 18 | "incoming links", 19 | "what links here" 20 | ], 21 | "homepage": "https://professional.wiki/en/extension/network", 22 | "license": "GPL-2.0-or-later", 23 | "authors": [ 24 | { 25 | "name": "Professional Wiki", 26 | "email": "info@professional.wiki", 27 | "homepage": "https://professional.wiki", 28 | "role": "Creator" 29 | }, 30 | { 31 | "name": "Jeroen De Dauw", 32 | "email": "jeroendedauw@gmail.com", 33 | "homepage": "https://www.entropywins.wtf", 34 | "role": "Creator and lead developer" 35 | } 36 | ], 37 | "support": { 38 | "issues": "https://github.com/ProfessionalWiki/Network/issues", 39 | "source": "https://github.com/ProfessionalWiki/Network" 40 | }, 41 | "require": { 42 | "php": ">=7.4", 43 | "composer/installers": "^2|^1.0.1" 44 | }, 45 | "require-dev": { 46 | "vimeo/psalm": "^5.17.0", 47 | "phpstan/phpstan": "^2.0.2", 48 | "mediawiki/mediawiki-codesniffer": "45.0.0" 49 | }, 50 | "config": { 51 | "allow-plugins": { 52 | "composer/installers": true, 53 | "dealerdirect/phpcodesniffer-composer-installer": true 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /extension.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Network", 3 | 4 | "version": "3.0.0", 5 | 6 | "author": [ 7 | "[https://www.entropywins.wtf/mediawiki Jeroen De Dauw]", 8 | "[https://professional.wiki/ Professional Wiki]" 9 | ], 10 | 11 | "url": "https://professional.wiki/en/extension/network", 12 | 13 | "descriptionmsg": "network-desc", 14 | 15 | "license-name": "GPL-2.0-or-later", 16 | 17 | "type": "parserhook", 18 | 19 | "requires": { 20 | "MediaWiki": ">= 1.39.0" 21 | }, 22 | 23 | "config": { 24 | "PageNetworkOptions": { 25 | "value": { 26 | "layout": { 27 | "randomSeed": 42 28 | }, 29 | "physics": { 30 | "barnesHut": { 31 | "gravitationalConstant": -5000, 32 | "damping": 0.242 33 | } 34 | }, 35 | "nodes": { 36 | "color": { 37 | "background": "white", 38 | "highlight": { 39 | "background": "white" 40 | } 41 | }, 42 | "borderWidth": 0, 43 | "shape": "image", 44 | "size": 10, 45 | "shapeProperties": { 46 | "useBorderWithImage": true 47 | } 48 | }, 49 | "groups": { 50 | "bluelink": { 51 | "image": "resources/lib/ooui/themes/wikimediaui/images/icons/article-rtl-progressive.svg" 52 | }, 53 | "redlink": { 54 | "image": "resources/lib/ooui/themes/wikimediaui/images/icons/articleNotFound-ltr.svg", 55 | "color": { 56 | "border": "#ba0000", 57 | "highlight": { 58 | "border": "#ba0000" 59 | } 60 | }, 61 | "font": { 62 | "color": "#ba0000" 63 | } 64 | }, 65 | "externallink": { 66 | "image": "resources/lib/ooui/themes/wikimediaui/images/icons/linkExternal-ltr-progressive.svg", 67 | "color": { 68 | "border": "grey", 69 | "highlight": { 70 | "border": "grey" 71 | } 72 | }, 73 | "font": { 74 | "color": "grey" 75 | } 76 | } 77 | } 78 | }, 79 | "merge_strategy": "array_replace_recursive" 80 | }, 81 | "PageNetworkExcludeTalkPages": { 82 | "value": true 83 | }, 84 | "PageNetworkExcludedNamespaces": { 85 | "value": [ 2, 4, 8, 12 ] 86 | }, 87 | "PageNetworkEnableDisplayTitle": { 88 | "value": true 89 | }, 90 | "PageNetworkLabelMaxLength": { 91 | "value": 20 92 | } 93 | }, 94 | 95 | "MessagesDirs": { 96 | "Network": [ 97 | "i18n" 98 | ] 99 | }, 100 | 101 | "ExtensionMessagesFiles": { 102 | "NetworkParserFunction": "i18n/_MagicWords.php", 103 | "NetworkAlias": "i18n/Network.i18n.alias.php" 104 | }, 105 | 106 | "AutoloadNamespaces": { 107 | "MediaWiki\\Extension\\Network\\": "src", 108 | "MediaWiki\\Extension\\Network\\Tests\\": "tests/php" 109 | }, 110 | 111 | "Hooks": { 112 | "ParserFirstCallInit": "MediaWiki\\Extension\\Network\\EntryPoints\\NetworkFunction::onParserFirstCallInit" 113 | }, 114 | 115 | "SpecialPages": { 116 | "Network": "MediaWiki\\Extension\\Network\\EntryPoints\\SpecialNetwork" 117 | }, 118 | 119 | "ResourceFileModulePaths": { 120 | "localBasePath": "/", 121 | "remoteExtPath": "Network" 122 | }, 123 | 124 | "ResourceModules": { 125 | "ext.network": { 126 | "dependencies": [ 127 | "mediawiki.api", 128 | "mediawiki.Title", 129 | "mediawiki.jqueryMsg" 130 | ], 131 | "scripts": [ 132 | "resources/lib/vis-network.js", 133 | 134 | "resources/js/PageExclusionManager.js", 135 | "resources/js/NetworkData.js", 136 | "resources/js/ApiConnectionsBuilder.js", 137 | "resources/js/ApiPageConnectionRepo.js", 138 | "resources/js/Network.js", 139 | "resources/js/index.js" 140 | ], 141 | "styles": [ 142 | "resources/network.css" 143 | ], 144 | "messages": [ 145 | "network-aria" 146 | ], 147 | "targets": [ "desktop", "mobile" ] 148 | }, 149 | "ext.network.special": { 150 | "dependencies": [ 151 | "mediawiki.Title", 152 | "oojs-ui-core", 153 | "oojs-ui-widgets" 154 | ], 155 | "scripts": [ 156 | "resources/js/SpecialForm.js" 157 | ], 158 | "messages": [ 159 | "htmlform-submit", 160 | "pagenetwork-pages-field-label", 161 | "pagenetwork-pages-field-help", 162 | "pagenetwork-exclude-field-label", 163 | "pagenetwork-exclude-field-help", 164 | "pagenetwork-excludedNamespaces-field-label", 165 | "pagenetwork-excludedNamespaces-field-help", 166 | "pagenetwork-class-field-label", 167 | "pagenetwork-class-field-help", 168 | "pagenetwork-options-field-label", 169 | "pagenetwork-options-field-help", 170 | "pagenetwork-enableDisplayTitle-field-label", 171 | "pagenetwork-enableDisplayTitle-field-help", 172 | "pagenetwork-labelMaxLength-field-label", 173 | "pagenetwork-labelMaxLength-field-help", 174 | "pagenetwork-basic-tab-label", 175 | "pagenetwork-advanced-tab-label" 176 | ], 177 | "targets": [ "desktop", "mobile" ] 178 | } 179 | }, 180 | 181 | "QUnitTestModule": { 182 | "localBasePath": "tests/js", 183 | "remoteExtPath": "Network/tests/js", 184 | "scripts": [ 185 | "stub/index.js", 186 | "stub/Cats.js", 187 | "stub/MultiPage.js", 188 | 189 | "MultiPageConnectionsTest.js", 190 | "PageBlacklistTest.js", 191 | "SinglePageConnectionsTest.js" 192 | ], 193 | "dependencies": [ 194 | "ext.network" 195 | ] 196 | }, 197 | 198 | "manifest_version": 2 199 | } 200 | -------------------------------------------------------------------------------- /i18n/Network.i18n.alias.php: -------------------------------------------------------------------------------- 1 | [ 'Network' ], 7 | ]; 8 | -------------------------------------------------------------------------------- /i18n/_MagicWords.php: -------------------------------------------------------------------------------- 1 | [ 0, 'network' ], 8 | ]; 9 | 10 | /** German (Deutsch) */ 11 | $magicWords['de'] = [ 12 | 'network' => [ 0, 'netzwerk' ], 13 | ]; 14 | -------------------------------------------------------------------------------- /i18n/ce.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Умар" 5 | ] 6 | }, 7 | "network": "Сеть", 8 | "pagenetwork-pages-field-label": "АгӀонаш", 9 | "pagenetwork-class-field-label": "CSS классаш", 10 | "pagenetwork-enableDisplayTitle-field-label": "Гойтуш йолу цӀе дӀахӀоттайе", 11 | "pagenetwork-basic-tab-label": "Коьрта нисдаран гӀирс", 12 | "pagenetwork-advanced-tab-label": "Шорбина нисдаран гӀирс" 13 | } 14 | -------------------------------------------------------------------------------- /i18n/de.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Brettchenweber", 5 | "DraconicDark", 6 | "Gichi", 7 | "Justman10000", 8 | "Kghbln", 9 | "Krabina", 10 | "Lorem Ipsum", 11 | "Umlaut", 12 | "Zabe" 13 | ] 14 | }, 15 | "network": "Netzwerk", 16 | "network-desc": "Ermöglicht die Visualisierung von Netzwerkbeziehungen zwischen Seiten", 17 | "network-aria": "Die Netzwerkvisualisierung zeigt eingehende und ausgehende Links der {{PLURAL:$1|Seite|Seiten}} $2", 18 | "pagenetwork-pages-field-label": "Seiten", 19 | "pagenetwork-pages-field-help": "Der Name der Seite oder Seiten, für die Verbindungen angezeigt werden sollen, eine pro Zeile. Standardmäßig wird die Hauptseite angezeigt.", 20 | "pagenetwork-exclude-field-label": "Seiten ausschließen", 21 | "pagenetwork-exclude-field-help": "Seiten, die aus dem Netzwerkdiagramm ausgeschlossen werden sollen, eine pro Zeile.", 22 | "pagenetwork-excludedNamespaces-field-label": "Namensräume ausschließen", 23 | "pagenetwork-excludedNamespaces-field-help": "Namensräume, die aus dem Netzwerkdiagramm ausgeschlossen werden sollen.", 24 | "pagenetwork-class-field-label": "CSS-Klassen", 25 | "pagenetwork-class-field-help": "Extra css-Klasse(n), die dem Netzwerkdiagramm hinzugefügt werden sollen, getrennt durch Leerzeichen.", 26 | "pagenetwork-options-field-label": "Diagrammoptionen", 27 | "pagenetwork-options-field-help": "JSON-Struktur mit vis.js-Diagrammoptionen.", 28 | "pagenetwork-enableDisplayTitle-field-label": "Aktiviere Titel anzeigen", 29 | "pagenetwork-enableDisplayTitle-field-help": "Soll der Seitentitel oder der Anzeigetitel als Beschriftung eines Knotens angezeigt werden?", 30 | "pagenetwork-labelMaxLength-field-label": "Maximale Etikettenlänge", 31 | "pagenetwork-labelMaxLength-field-help": "Die maximale Textlänge der Knotenbeschriftung oder 0, wenn sie unbegrenzt ist. Wenn die Knotenbezeichnung abgeschnitten werden muss, wird eine Ellipse (…) angehängt.", 32 | "pagenetwork-basic-tab-label": "Basisoptionen", 33 | "pagenetwork-advanced-tab-label": "Erweiterte Optionen" 34 | } 35 | -------------------------------------------------------------------------------- /i18n/en.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Jeroen De Dauw", 5 | "Karsten Hoffmeyer" 6 | ] 7 | }, 8 | "network": "Network", 9 | "network-name": "Network", 10 | "network-desc": "Allows adding interactive network visualizations in your wiki pages", 11 | "network-aria": "Network visualization showing the outgoing and incoming links for {{PLURAL:$1|page|pages}} $2", 12 | "pagenetwork-pages-field-label": "Pages", 13 | "pagenetwork-pages-field-help": "The name of the page or pages to show connections for, one per line. Defaults to main page.", 14 | "pagenetwork-exclude-field-label": "Exclude Pages", 15 | "pagenetwork-exclude-field-help": "Pages to exclude from the network graph, one per line.", 16 | "pagenetwork-excludedNamespaces-field-label": "Exclude Namespaces", 17 | "pagenetwork-excludedNamespaces-field-help": "Namespaces to exclude from the network graph.", 18 | "pagenetwork-class-field-label": "CSS Classes", 19 | "pagenetwork-class-field-help": "Extra css class(es) to add to the network graph, separated by spaces.", 20 | "pagenetwork-options-field-label": "Graph Options", 21 | "pagenetwork-options-field-help": "JSON structure with vis.js graph options.", 22 | "pagenetwork-enableDisplayTitle-field-label": "Enable Display Title", 23 | "pagenetwork-enableDisplayTitle-field-help": "Should the page title or the display title be displayed as a node's label?", 24 | "pagenetwork-labelMaxLength-field-label": "Maximum Label Length", 25 | "pagenetwork-labelMaxLength-field-help": "The maximum text length of a node's label or 0 if unlimited. If the node label must be truncated, an ellipsis (…) will appended.", 26 | "pagenetwork-basic-tab-label": "Basic Options", 27 | "pagenetwork-advanced-tab-label": "Advanced Options" 28 | } 29 | -------------------------------------------------------------------------------- /i18n/fa.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Jeeputer" 5 | ] 6 | }, 7 | "network": "شبکه", 8 | "pagenetwork-pages-field-label": "صفحه‌ها", 9 | "pagenetwork-class-field-label": "کلاس‌های سی‌اس‌اس", 10 | "pagenetwork-options-field-label": "گزینه‌های نمودار", 11 | "pagenetwork-enableDisplayTitle-field-label": "فعال‌سازی عنوان نمایشی", 12 | "pagenetwork-labelMaxLength-field-label": "بیشتری طول برچسب" 13 | } 14 | -------------------------------------------------------------------------------- /i18n/fr.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Ajeje Brazorf", 5 | "Gomoko", 6 | "JenyxGym", 7 | "Verdy p" 8 | ] 9 | }, 10 | "network": "Réseau", 11 | "network-desc": "Permet l’ajout de visualisations de réseau interactives dans vos pages wiki", 12 | "network-aria": "Affichage du réseau montrant les liens sortant et entrant pour {{PLURAL:$1|la page|les pages}} $2", 13 | "pagenetwork-pages-field-label": "Pages", 14 | "pagenetwork-pages-field-help": "Le nom de la ou des pages pour lesquelles afficher les connexions, une par ligne.\nPar défaut, la page principale.", 15 | "pagenetwork-exclude-field-label": "Exclure des pages", 16 | "pagenetwork-exclude-field-help": "Pages à exclure du graphe du réseau, une par ligne.", 17 | "pagenetwork-excludedNamespaces-field-label": "Exclure des espaces de noms", 18 | "pagenetwork-excludedNamespaces-field-help": "Espaces de nom à exclure du graphe du réseau.", 19 | "pagenetwork-class-field-label": "Classes CSS", 20 | "pagenetwork-class-field-help": "Classes CSS supplémentaires à ajouter au graphe du réseau, séparées par des espaces.", 21 | "pagenetwork-options-field-label": "Options du graphique", 22 | "pagenetwork-options-field-help": "Structure JSON avec les options de graphe vis.js.", 23 | "pagenetwork-enableDisplayTitle-field-label": "Activer le titre d’affichage", 24 | "pagenetwork-enableDisplayTitle-field-help": "La page doit-elle afficher son titre ou le titre d’affichage comme libellé du nœud ?", 25 | "pagenetwork-labelMaxLength-field-label": "Longueur maximale du libellé", 26 | "pagenetwork-labelMaxLength-field-help": "La longueur maximale du texte du libellé d’un nœud, ou 0 si illimité. Si le libellé du nœud doit être tronqué, un caractère (…) sera ajouté.", 27 | "pagenetwork-basic-tab-label": "Options de base", 28 | "pagenetwork-advanced-tab-label": "Options avancées" 29 | } 30 | -------------------------------------------------------------------------------- /i18n/he.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Amire80", 5 | "Avma" 6 | ] 7 | }, 8 | "network": "רשת", 9 | "network-desc": "מאפשרת הוספת הדמיות רשת הידויות בדפי הוויקי שלך", 10 | "network-aria": "הדמיית רשת המציגה את הקישורים היוצאים והנכנסים עבור {{PLURAL:$1|הדף|הדפים}} $2", 11 | "pagenetwork-pages-field-label": "דפים", 12 | "pagenetwork-pages-field-help": "שם הדף או הדפים שעבורם יש להציג חיבורים, אחד בכל שורה. ברירת מחדל היא העמוד הראשי.", 13 | "pagenetwork-exclude-field-label": "ללא הדפים האלה", 14 | "pagenetwork-exclude-field-help": "דפים להחרגה מגרף הרשת, אחד בכל שורה.", 15 | "pagenetwork-excludedNamespaces-field-label": "לא לכלול את מרחבי השם", 16 | "pagenetwork-excludedNamespaces-field-help": "מרחבי שם להחרגה מתרשים הרשת.", 17 | "pagenetwork-class-field-label": "מחלקות CSS", 18 | "pagenetwork-class-field-help": "מחלקות css נוספות להוספה לגרף הרשת, מופרדות ברווחים.", 19 | "pagenetwork-options-field-label": "אפשרויות תרשים", 20 | "pagenetwork-options-field-help": "מבנה JSON עם אפשרויות גרף vis.js.", 21 | "pagenetwork-enableDisplayTitle-field-label": "הפעלת כותרת התצוגה", 22 | "pagenetwork-enableDisplayTitle-field-help": "האם יש להציג את כותרת הדף או את כותרת התצוגה כתווית של צומת?", 23 | "pagenetwork-labelMaxLength-field-label": "אורך תווית מרבי", 24 | "pagenetwork-labelMaxLength-field-help": "אורך הטקסט המרבי של תווית של צומת או 0 אם בלתי מוגבל. אם יש לחתוך את תווית הצומת, יתווספו שלוש נקודות (...).", 25 | "pagenetwork-basic-tab-label": "אפשרויות בסיסיות", 26 | "pagenetwork-advanced-tab-label": "אפשרויות מתקדמות" 27 | } 28 | -------------------------------------------------------------------------------- /i18n/ia.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "McDutchie" 5 | ] 6 | }, 7 | "network": "Rete", 8 | "network-desc": "Permitte adder visualisationes de rete interactive in tu paginas wiki", 9 | "network-aria": "Visualisation de rete que monstra le ligamines sortiente e entrante pro le pagina{{PLURAL:$1||s}} $2", 10 | "pagenetwork-pages-field-label": "Paginas", 11 | "pagenetwork-pages-field-help": "Le nomine(s) del pagina(s) pro le qual(es) monstrar connexiones, un per linea. Le valor predefinite es le pagina principal.", 12 | "pagenetwork-exclude-field-label": "Excluder paginas", 13 | "pagenetwork-exclude-field-help": "Paginas a excluder del graphico de rete, un per linea.", 14 | "pagenetwork-excludedNamespaces-field-label": "Excluder spatios de nomines", 15 | "pagenetwork-excludedNamespaces-field-help": "Spatios de nomines a excluder del graphico de rete.", 16 | "pagenetwork-class-field-label": "Classes CSS", 17 | "pagenetwork-class-field-help": "Class(es) CSS supplementari a adder al graphico de rete, separate per spatios.", 18 | "pagenetwork-options-field-label": "Optiones de graphico", 19 | "pagenetwork-options-field-help": "Structura JSON con optiones de graphico vis.js.", 20 | "pagenetwork-enableDisplayTitle-field-label": "Activar le titulo a monstrar", 21 | "pagenetwork-enableDisplayTitle-field-help": "Debe le titulo del pagina o le titulo a monstrar esser monstrate como le etiquetta de un nodo?", 22 | "pagenetwork-labelMaxLength-field-label": "Longitude maxime del etiquetta", 23 | "pagenetwork-labelMaxLength-field-help": "Le longitude maxime del texto del etiquetta de un nodo, o 0 si illimitate. Si le etiquetta de un nodo debe esser truncate, un ellipse (…) essera adjungite.", 24 | "pagenetwork-basic-tab-label": "Optiones de base", 25 | "pagenetwork-advanced-tab-label": "Optiones avantiate" 26 | } 27 | -------------------------------------------------------------------------------- /i18n/ja.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Hideki Yoshida", 5 | "Omotecho", 6 | "Yukkuri Shambis", 7 | "もなー(偽物)" 8 | ] 9 | }, 10 | "network": "ネットワーク", 11 | "pagenetwork-pages-field-label": "ページ", 12 | "pagenetwork-exclude-field-label": "ページを除外", 13 | "pagenetwork-exclude-field-help": "ネットワーク グラフから除外するページ(1ページ/行)", 14 | "pagenetwork-excludedNamespaces-field-label": "名前空間を除外", 15 | "pagenetwork-excludedNamespaces-field-help": "ネットワーク グラフから除外する名前空間", 16 | "pagenetwork-class-field-label": "CSSクラス", 17 | "pagenetwork-class-field-help": "ネットワーク グラフに対する追加のCSSクラス (スペースで区切ります)", 18 | "pagenetwork-options-field-label": "グラフのオプション", 19 | "pagenetwork-options-field-help": "vis.jsグラフ オプションが記載されたJSON構造。", 20 | "pagenetwork-enableDisplayTitle-field-label": "表示タイトルを有効にする", 21 | "pagenetwork-labelMaxLength-field-label": "最大ラベル長", 22 | "pagenetwork-labelMaxLength-field-help": "ノードのラベルの上限テキスト長もしくは無制限の場合は0。ノードのラベルの省略を切り捨てるには省略記号(...)を追加。", 23 | "pagenetwork-basic-tab-label": "基本設定", 24 | "pagenetwork-advanced-tab-label": "詳細設定" 25 | } 26 | -------------------------------------------------------------------------------- /i18n/ko.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Suleiman the Magnificent Television", 5 | "Ykhwong" 6 | ] 7 | }, 8 | "network": "네트워크", 9 | "network-desc": "위키 페이지에 상호작용 네트워크 시각화의 추가를 허용합니다", 10 | "pagenetwork-pages-field-label": "문서", 11 | "pagenetwork-exclude-field-label": "문서 제외", 12 | "pagenetwork-excludedNamespaces-field-label": "이름공간 제외", 13 | "pagenetwork-excludedNamespaces-field-help": "네트워크 그래프에서 제외할 이름공간입니다.", 14 | "pagenetwork-class-field-label": "CSS 클래스", 15 | "pagenetwork-options-field-label": "그래프 옵션", 16 | "pagenetwork-options-field-help": "vis.js 그래프 옵션이 포함된 JSON 구조입니다.", 17 | "pagenetwork-enableDisplayTitle-field-label": "표시 제목 활성화", 18 | "pagenetwork-enableDisplayTitle-field-help": "문서 제목이나 표시 제목은 노드의 레이블로 표시되어야 합니까?", 19 | "pagenetwork-labelMaxLength-field-label": "최대 레이블 길이", 20 | "pagenetwork-basic-tab-label": "기본 옵션", 21 | "pagenetwork-advanced-tab-label": "고급 옵션" 22 | } 23 | -------------------------------------------------------------------------------- /i18n/krc.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Къарачайлы" 5 | ] 6 | }, 7 | "network": "Нетаулау", 8 | "network-desc": "Викибетилеригизге интерактив нетаулау визуализация къошаргъа амал береди", 9 | "network-aria": "{{PLURAL:$1|Бет}} $2 ючюн кетген эмда келген джибериулени кёргюзген нетаулау визуализация", 10 | "pagenetwork-pages-field-label": "Бетле", 11 | "pagenetwork-pages-field-help": "Хар тизгиннге бир байлам болуб кёргюзюллюк бетни неда бетлени аты. Тынгылау бла баш бетди.", 12 | "pagenetwork-exclude-field-label": "Бетлени Тышында Тут", 13 | "pagenetwork-exclude-field-help": "Нетаулау графикден чыгъарыргъа керек бетле, хар тизгиннге бир бет.", 14 | "pagenetwork-excludedNamespaces-field-label": "Ат Аламланы Тышында Тут", 15 | "pagenetwork-excludedNamespaces-field-help": "Нетаулау графикледен тышында тутуллукъ ат аламла.", 16 | "pagenetwork-class-field-label": "CSS Классла", 17 | "pagenetwork-class-field-help": "Нетаулау графикге къошуллукъ, бошлукълагъа айрылгъан экстра css класс(ла).", 18 | "pagenetwork-options-field-label": "График Опцияла", 19 | "pagenetwork-options-field-help": "vis.js графика опцияла бла JSON структура.", 20 | "pagenetwork-enableDisplayTitle-field-label": "Кёрнюм Башлыкъны Джандыр", 21 | "pagenetwork-enableDisplayTitle-field-help": "Бет башлыкъ неда кёрюнюм башлыкъ тюйюмчекни этикети болуб кёргюзюлюрге боллукъмуду?", 22 | "pagenetwork-labelMaxLength-field-label": "Максимум Этикет Узунлукъ", 23 | "pagenetwork-labelMaxLength-field-help": "Бу тюйюмчекни этикетини максимум текст узунлугъу неда чексиз эсе 0. Тюйюмчек этикетни кесилиую керек эсе, нохта (...) салыныр.", 24 | "pagenetwork-basic-tab-label": "Тамал Сайлаула", 25 | "pagenetwork-advanced-tab-label": "Кенгленнген Сайлаула" 26 | } 27 | -------------------------------------------------------------------------------- /i18n/lt.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Nokeoo" 5 | ] 6 | }, 7 | "network": "Tinklas", 8 | "network-desc": "Leidžia pridėti interaktyvių tinklo vizualizacijų jūsų viki puslapiuose", 9 | "network-aria": "Tinklo vizualizacija, rodanti išeinančias ir čia vedančias nuorodas {{PLURAL:$1|puslapiui|puslapiams}} $2", 10 | "pagenetwork-pages-field-label": "Puslapiai", 11 | "pagenetwork-pages-field-help": "Puslapio ar puslapių, kuriuose rodomi ryšiai, pavadinimas, po vieną eilutėje. Numatytasis – pagrindinis puslapis.", 12 | "pagenetwork-exclude-field-label": "Neįtraukti puslapių", 13 | "pagenetwork-exclude-field-help": "Puslapiai, kurių netraukti į tinklo grafiką, po vieną eilutėje.", 14 | "pagenetwork-excludedNamespaces-field-label": "Neįtraukti vardų sričių", 15 | "pagenetwork-excludedNamespaces-field-help": "Neįtrauktinos į tinklo grafiką vardų sritys.", 16 | "pagenetwork-class-field-label": "CSS klasės", 17 | "pagenetwork-class-field-help": "Papildoma (-os) css klasė (-s), kurią (-as) reikia pridėti prie tinklo grafiko, atskirtos tarpais.", 18 | "pagenetwork-options-field-label": "Grafiko parinktys", 19 | "pagenetwork-options-field-help": "JSON struktūra su vis.js grafiko parinktimis.", 20 | "pagenetwork-enableDisplayTitle-field-label": "Įgalinti Rodyti pavadinimą", 21 | "pagenetwork-enableDisplayTitle-field-help": "Ar taško etiketė turėtų būti puslapio pavadinimas ar puslapio rodomas pavadinimas?", 22 | "pagenetwork-labelMaxLength-field-label": "Maksimalus etiketės ilgis", 23 | "pagenetwork-labelMaxLength-field-help": "Maksimalus taško etiketės teksto ilgis arba 0, jei neribotas. Jei taško etiketė turi būti sutrumpinta, bus pridėta elipsė (…).", 24 | "pagenetwork-basic-tab-label": "Pagrindinės parinktys", 25 | "pagenetwork-advanced-tab-label": "Išplėstinės parinktys" 26 | } 27 | -------------------------------------------------------------------------------- /i18n/mk.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Bjankuloski06" 5 | ] 6 | }, 7 | "network": "Мрежа", 8 | "network-desc": "Овозможува додавање на интерактивни нагледни прикази на мрежата во вашите викистраници", 9 | "network-aria": "Мрежен нагледен приказ на појдовните и дојдовните врски за {{PLURAL:$1|страницата|страниците}} $2", 10 | "pagenetwork-pages-field-label": "Страници", 11 | "pagenetwork-pages-field-help": "За која страница или страници да се прикажат поврзаности, по една во секој ред.\nПо основно ја дава главната страница.", 12 | "pagenetwork-exclude-field-label": "Изземи страници", 13 | "pagenetwork-exclude-field-help": "Кои страници да се изземат од графиконот на мрежата, по една во секој ред.", 14 | "pagenetwork-excludedNamespaces-field-label": "Изземи именски простори", 15 | "pagenetwork-excludedNamespaces-field-help": "Кои именски простори да се изземат од мрежниот графикон.", 16 | "pagenetwork-class-field-label": "CSS-класи", 17 | "pagenetwork-class-field-help": "Дополнителни CSS-класи за додавање во графиконот на мрежата, одделени со празни места.", 18 | "pagenetwork-options-field-label": "Нагодувања за графиконот", 19 | "pagenetwork-options-field-help": "JSON-структура со графиконски можности на vis.js.", 20 | "pagenetwork-enableDisplayTitle-field-label": "Овозможи наслов за приказ", 21 | "pagenetwork-enableDisplayTitle-field-help": "Дали да се прикажува насловот на страницата или друг наслов за приказ како натпис на јазолот?", 22 | "pagenetwork-labelMaxLength-field-label": "Допуштена должина на натписот", 23 | "pagenetwork-labelMaxLength-field-help": "Најголемата допуштена должина на текстот во натписот на јазолот или 0 за неограничено. Ако натписот мора да биде скратен, на крајот ќе се појават три точки (…).", 24 | "pagenetwork-basic-tab-label": "Основни можности", 25 | "pagenetwork-advanced-tab-label": "Напредни можности" 26 | } 27 | -------------------------------------------------------------------------------- /i18n/nb.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Jon Harald Søby" 5 | ] 6 | }, 7 | "network-desc": "Gjør det mulig å legge til interaktive nettverksvisualiseringer på wikisider", 8 | "network-aria": "Nettverksvisualisering som viser lenker til og fra {{PLURAL:$1|siden|sidene}} $2" 9 | } 10 | -------------------------------------------------------------------------------- /i18n/nl.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "McDutchie", 5 | "Romaine" 6 | ] 7 | }, 8 | "network": "Netwerk", 9 | "network-desc": "Maakt het mogelijk om interactieve netwerkvisualisaties aan uw wikipagina’s toe te voegen", 10 | "network-aria": "Netwerkvisualisatie met de uitgaande en inkomende koppelingen voor de pagina{{PLURAL:$1||’s}} $2", 11 | "pagenetwork-pages-field-label": "Pagina's", 12 | "pagenetwork-pages-field-help": "De naam van de pagina of pagina’s waarvoor verbindingen moeten worden weergegeven, één per regel. Standaard ingesteld op de hoofdpagina.", 13 | "pagenetwork-exclude-field-label": "Pagina’s uitsluiten", 14 | "pagenetwork-exclude-field-help": "Pagina’s die moeten worden uitgesloten van de netwerkgrafiek, één per regel.", 15 | "pagenetwork-excludedNamespaces-field-label": "Naamruimten uitsluiten", 16 | "pagenetwork-excludedNamespaces-field-help": "Naamruimten die moeten worden uitgesloten van de netwerkgrafiek.", 17 | "pagenetwork-class-field-label": "CSS-klassen", 18 | "pagenetwork-class-field-help": "Extra CSS-klasse(n) om toe te voegen aan de netwerkgrafiek, gescheiden door spaties.", 19 | "pagenetwork-options-field-label": "Grafiekopties", 20 | "pagenetwork-options-field-help": "JSON-structuur met vis.js-grafiekopties.", 21 | "pagenetwork-enableDisplayTitle-field-label": "Weergavetitel inschakelen", 22 | "pagenetwork-enableDisplayTitle-field-help": "Moet de paginatitel of de weergavetitel worden weergegeven als het label van een knooppunt?", 23 | "pagenetwork-labelMaxLength-field-label": "Maximale labellengte", 24 | "pagenetwork-labelMaxLength-field-help": "De maximale tekstlengte van het label van een knooppunt, of 0 indien onbeperkt. Als het knooppunt-label moet worden afgekapt, wordt er een weglatingsteken (…) toegevoegd.", 25 | "pagenetwork-basic-tab-label": "Basisopties", 26 | "pagenetwork-advanced-tab-label": "Geavanceerde opties" 27 | } 28 | -------------------------------------------------------------------------------- /i18n/pl.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Rail", 5 | "WaldiSt" 6 | ] 7 | }, 8 | "network-desc": "Umożliwia dodawanie interaktywnych wizualizacji sieci do stron na wiki", 9 | "network-aria": "Wizualizacja sieci pokazująca wychodzące i przychodzące połączenia dla {{PLURAL:$1|strony|stron}} $2", 10 | "pagenetwork-pages-field-label": "Strony" 11 | } 12 | -------------------------------------------------------------------------------- /i18n/pt-br.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Eduardo Addad de Oliveira", 5 | "Eduardoaddad" 6 | ] 7 | }, 8 | "network": "Rede", 9 | "network-desc": "Permitir adicionar visualizações de rede interativas nas suas páginas da wiki", 10 | "network-aria": "Visualização de rede mostrando os links de saída e entrada para {{PLURAL:$1|página|páginas}} $2", 11 | "pagenetwork-pages-field-label": "Páginas", 12 | "pagenetwork-pages-field-help": "O nome da página ou páginas para mostrar as conexões, uma por linha. Padrões para a página principal.", 13 | "pagenetwork-exclude-field-help": "Páginas a serem excluídas do gráfico da rede, uma por linha.", 14 | "pagenetwork-class-field-label": "Classes CSS", 15 | "pagenetwork-options-field-label": "Opções de gráfico", 16 | "pagenetwork-enableDisplayTitle-field-label": "Ativar título de exibição", 17 | "pagenetwork-enableDisplayTitle-field-help": "O título da página ou o título de exibição deve ser exibido como um rótulo de nó?", 18 | "pagenetwork-labelMaxLength-field-label": "Comprimento máximo do rótulo.", 19 | "pagenetwork-basic-tab-label": "Opções básicas", 20 | "pagenetwork-advanced-tab-label": "Opções avançadas" 21 | } 22 | -------------------------------------------------------------------------------- /i18n/pt.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Hamilton Abreu" 5 | ] 6 | }, 7 | "network": "Rede", 8 | "network-desc": "Permite adicionar vistas de rede interativas nas páginas da sua wiki", 9 | "network-aria": "Vista de rede que mostra as hiperligações de entrada e saída {{PLURAL:$1|da página|das páginas}} $2", 10 | "pagenetwork-pages-field-label": "Páginas", 11 | "pagenetwork-pages-field-help": "O nome da página, ou páginas, cujas ligações serão mostradas, uma por linha. Por omissão, a página principal.", 12 | "pagenetwork-exclude-field-label": "Páginas a excluir", 13 | "pagenetwork-exclude-field-help": "Páginas a serem excluídas do gráfico de rede, uma por linha.", 14 | "pagenetwork-excludedNamespaces-field-label": "Espaços nominais a excluir", 15 | "pagenetwork-excludedNamespaces-field-help": "Espaços nominais a serem excluídos do gráfico de rede.", 16 | "pagenetwork-class-field-label": "Classes CSS", 17 | "pagenetwork-class-field-help": "Classes CSS extra a adicionar ao gráfico de rede, separadas por espaços.", 18 | "pagenetwork-options-field-label": "Opções do gráfico", 19 | "pagenetwork-options-field-help": "Estrutura JSON com opções de gráfico vis.js.", 20 | "pagenetwork-enableDisplayTitle-field-label": "Ativar a apresentação do título", 21 | "pagenetwork-enableDisplayTitle-field-help": "Deve ser apresentado como rótulo de um nó o título da página ou o título de apresentação?", 22 | "pagenetwork-labelMaxLength-field-label": "Comprimento máximo do rótulo", 23 | "pagenetwork-labelMaxLength-field-help": "O comprimento máximo do texto do rótulo de um nó ou 0, se ilimitado. Se o rótulo do nó tiver de ser truncado, serão acrescentadas reticências.", 24 | "pagenetwork-basic-tab-label": "Opções de base", 25 | "pagenetwork-advanced-tab-label": "Opções avançadas" 26 | } 27 | -------------------------------------------------------------------------------- /i18n/qqq.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Amire80", 5 | "Cantons-de-l'Est", 6 | "Jeroen De Dauw", 7 | "Karsten Hoffmeyer", 8 | "Kghbln", 9 | "Verdy p" 10 | ] 11 | }, 12 | "network": "This is a noun.", 13 | "network-desc": "{{Desc|name=Network|url=https://github.com/ProfessionalWiki/Network}}", 14 | "network-aria": "Informatory message.\n\nParameters:\n* $1 - Holds the number of pages listed with parameter $2\n* $2 - Holds the name of a page or the names of pages", 15 | "pagenetwork-pages-field-label": "Field label\n\n{{Identical|Pages}}", 16 | "pagenetwork-pages-field-help": "Field help", 17 | "pagenetwork-exclude-field-label": "Field label\n{{Related|Pagenetwork-exclude}}", 18 | "pagenetwork-exclude-field-help": "Field help", 19 | "pagenetwork-excludedNamespaces-field-label": "Field label\n{{Related|Pagenetwork-exclude}}", 20 | "pagenetwork-excludedNamespaces-field-help": "Field help", 21 | "pagenetwork-class-field-label": "Field label\\n{{Identical|CSS Classes}}", 22 | "pagenetwork-class-field-help": "Field help", 23 | "pagenetwork-options-field-label": "Field label\\n{{Identical|Graph Options}}", 24 | "pagenetwork-options-field-help": "Field help", 25 | "pagenetwork-enableDisplayTitle-field-label": "Field label\\n{{Identical|Enable Display Title}}", 26 | "pagenetwork-enableDisplayTitle-field-help": "Field help", 27 | "pagenetwork-labelMaxLength-field-label": "Field label\\n{{Identical|Maximum Label Length}}", 28 | "pagenetwork-labelMaxLength-field-help": "Field help", 29 | "pagenetwork-basic-tab-label": "Tab label\\n{{Identical|Basic Options}}", 30 | "pagenetwork-advanced-tab-label": "Tab label\n{{Identical|Advanced options}}" 31 | } 32 | -------------------------------------------------------------------------------- /i18n/roa-tara.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Joetaras" 5 | ] 6 | }, 7 | "network-desc": "Permette l'aggiunde de 'ndrucaminde de rezze inderattive jndr'à le pàggene uicchi toje", 8 | "network-aria": "'U 'ndrucamende d'a rezze face 'ndrucà le collegaminde ca trasene e iessene {{PLURAL:$1|pa pàgene|pe le pàggene}} $2" 9 | } 10 | -------------------------------------------------------------------------------- /i18n/ru.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Kareyac", 5 | "Okras" 6 | ] 7 | }, 8 | "network": "Сеть", 9 | "pagenetwork-pages-field-label": "Страницы", 10 | "pagenetwork-class-field-label": "Классы CSS", 11 | "pagenetwork-enableDisplayTitle-field-label": "Включить отображаемый заголовок", 12 | "pagenetwork-basic-tab-label": "Основные настройки", 13 | "pagenetwork-advanced-tab-label": "Расширенные настройки" 14 | } 15 | -------------------------------------------------------------------------------- /i18n/sl.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Eleassar" 5 | ] 6 | }, 7 | "network": "Omrežje", 8 | "network-desc": "Omogoča dodajanje interaktivnih vizualizacij omrežja v vaše viki strani", 9 | "network-aria": "Vizualizacija omrežja, ki prikazuje odhodne in dohodne povezave za {{PLURAL:$1|stran|strani}} $2", 10 | "pagenetwork-pages-field-label": "Strani", 11 | "pagenetwork-pages-field-help": "Ime strani za prikaz povezav, po ena na vrstico. Privzeto glavna stran.", 12 | "pagenetwork-exclude-field-label": "Izključi strani", 13 | "pagenetwork-exclude-field-help": "Strani za izključitev iz grafa omrežja, po ena na vrstico.", 14 | "pagenetwork-excludedNamespaces-field-label": "Izključi imenske prostore", 15 | "pagenetwork-excludedNamespaces-field-help": "Imenski prostori, ki naj bodo izključeni iz grafa omrežja.", 16 | "pagenetwork-class-field-label": "Razredi CSS", 17 | "pagenetwork-class-field-help": "Dodatni razred(i) css, ki ga(jih) želite dodati v graf omrežja, ločeni s presledki.", 18 | "pagenetwork-options-field-label": "Možnosti grafikona", 19 | "pagenetwork-options-field-help": "Struktura JSON z možnostmi grafa vis.js.", 20 | "pagenetwork-enableDisplayTitle-field-label": "Omogoči prikaz naslova", 21 | "pagenetwork-enableDisplayTitle-field-help": "Ali naj bo naslov strani ali prikazni naslov prikazan kot oznaka vozlišča?", 22 | "pagenetwork-labelMaxLength-field-label": "Največja dolžina oznake", 23 | "pagenetwork-labelMaxLength-field-help": "Največja dolžina besedila oznake vozlišča ali 0, če je neomejeno. Če mora biti oznaka vozlišča okrnjena, bo dodano tripičje (…).", 24 | "pagenetwork-basic-tab-label": "Osnovne možnosti", 25 | "pagenetwork-advanced-tab-label": "Napredne možnosti" 26 | } 27 | -------------------------------------------------------------------------------- /i18n/sv.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Sabelöga" 5 | ] 6 | }, 7 | "network-desc": "Gör det möjligt att lägga till interaktiva nätverksvisualiseringar på dina wikisidor", 8 | "network-aria": "Nätverksvisualiseringar visar ut- och ingående länkar för {{PLURAL:$1|sidan|sidorna}} $2" 9 | } 10 | -------------------------------------------------------------------------------- /i18n/tr.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "BaRaN6161 TURK", 5 | "Joseph", 6 | "Mim.saitkilic", 7 | "MuratTheTurkish" 8 | ] 9 | }, 10 | "network": "Ağ", 11 | "network-desc": "Viki sayfalarınıza etkileşimli ağ görselleştirmeleri eklemenize izin verir", 12 | "network-aria": "{{PLURAL:$1|Sayfa}} $2 için giden ve gelen bağlantıları gösteren ağ görselleştirme", 13 | "pagenetwork-pages-field-label": "Sayfalar", 14 | "pagenetwork-pages-field-help": "Her satıra bir tane olmak üzere, bağlantıların gösterileceği sayfanın veya sayfaların adı. Varsayılan ana sayfadır.", 15 | "pagenetwork-exclude-field-label": "Sayfaları Hariç Tut", 16 | "pagenetwork-exclude-field-help": "Her satırda bir tane olacak şekilde ağ grafiğinden hariç tutulacak sayfalar.", 17 | "pagenetwork-excludedNamespaces-field-label": "Ad Alanlarını Hariç Tut", 18 | "pagenetwork-excludedNamespaces-field-help": "Ağ grafiğinden hariç tutulacak ad alanları.", 19 | "pagenetwork-class-field-label": "CSS Sınıfları", 20 | "pagenetwork-class-field-help": "Ağ grafiğine eklenecek, boşluklarla ayrılmış ekstra css sınıfları.", 21 | "pagenetwork-options-field-label": "Grafik Seçenekleri", 22 | "pagenetwork-options-field-help": "vis.js grafik seçenekleriyle JSON yapısı.", 23 | "pagenetwork-enableDisplayTitle-field-label": "Görüntü Başlığını Etkinleştir", 24 | "pagenetwork-enableDisplayTitle-field-help": "Sayfa başlığı mı yoksa görünen başlık bir düğümün etiketi olarak mı görüntülenmeli?", 25 | "pagenetwork-labelMaxLength-field-label": "Maksimum Etiket Uzunluğu", 26 | "pagenetwork-labelMaxLength-field-help": "Bir düğümün etiketinin maksimum metin uzunluğu veya sınırsızsa 0. Düğüm etiketinin kesilmesi gerekiyorsa, bir üç nokta (…) eklenir.", 27 | "pagenetwork-basic-tab-label": "Temel Seçenekler", 28 | "pagenetwork-advanced-tab-label": "Gelişmiş Seçenekler" 29 | } 30 | -------------------------------------------------------------------------------- /i18n/uk.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "DDPAT", 5 | "Ice bulldog" 6 | ] 7 | }, 8 | "network": "Мережа", 9 | "network-desc": "Дозволяє додавати інтерактивні візуалізації мережі на ваші вікі-сторінки", 10 | "network-aria": "Візуалізація мережі, що показує вихідні та вхідні посилання на {{PLURAL:$1|сторінку|сторінок}} $2", 11 | "pagenetwork-pages-field-label": "Сторінок", 12 | "pagenetwork-pages-field-help": "Назва сторінки або сторінок, до яких відображатимуться з'єднання, по одному на рядок. За замовчуванням для головної сторінки.", 13 | "pagenetwork-exclude-field-label": "Виключити сторінки", 14 | "pagenetwork-exclude-field-help": "Сторінки для виключення з мережевого графіка - по одній на рядок.", 15 | "pagenetwork-excludedNamespaces-field-label": "Виключити простори назв", 16 | "pagenetwork-excludedNamespaces-field-help": "Простори назв для виключення з мережевого діаграми.", 17 | "pagenetwork-class-field-label": "Класи CSS", 18 | "pagenetwork-class-field-help": "Додаткові класи(и) css для додавання до мережевого графа, розділені пробілами.", 19 | "pagenetwork-options-field-label": "Параметри графіків", 20 | "pagenetwork-options-field-help": "Структура JSON з параметрами графіку vis.js", 21 | "pagenetwork-enableDisplayTitle-field-label": "Увімкнути назву дисплея", 22 | "pagenetwork-enableDisplayTitle-field-help": "Чи має заголовок сторінки або заголовок відображення відображатися як мітка вузла?", 23 | "pagenetwork-labelMaxLength-field-label": "Максимальна довжина етикетки", 24 | "pagenetwork-labelMaxLength-field-help": "Максимальна довжина тексту мітки вузла або 0, якщо необмежена. Якщо мітку вузла потрібно урізати, буде додано крапку (…).", 25 | "pagenetwork-basic-tab-label": "Основні параметри", 26 | "pagenetwork-advanced-tab-label": "Розширені параметри" 27 | } 28 | -------------------------------------------------------------------------------- /i18n/zh-hans.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "GuoPC", 5 | "Lakejason0", 6 | "Xiplus", 7 | "Zhang8569", 8 | "落花有意12138" 9 | ] 10 | }, 11 | "network": "网络", 12 | "network-desc": "允许在您的wiki页面中添加交互式网状图可视化", 13 | "network-aria": "网状图可视化,显示{{PLURAL:$1|页面}}$2的传出和传入链接", 14 | "pagenetwork-pages-field-label": "页面", 15 | "pagenetwork-pages-field-help": "该页面的名字或者展示该链接的页面,每行一个。\n默认为主页面。", 16 | "pagenetwork-exclude-field-label": "排除的页面", 17 | "pagenetwork-exclude-field-help": "从网络图标排除的页面,每行一个。", 18 | "pagenetwork-excludedNamespaces-field-label": "排除命名空间", 19 | "pagenetwork-excludedNamespaces-field-help": "要从网络图表中排除的命名空间。", 20 | "pagenetwork-class-field-label": "CSS课程", 21 | "pagenetwork-class-field-help": "添加额外的css课程到网络图标,由空格分隔。", 22 | "pagenetwork-options-field-label": "图表选项", 23 | "pagenetwork-options-field-help": "JSON 结构和 vis.js显示选项。", 24 | "pagenetwork-enableDisplayTitle-field-label": "启用显示标题", 25 | "pagenetwork-enableDisplayTitle-field-help": "页面标题或显示标题是否应该被当作节点标签来显示?", 26 | "pagenetwork-labelMaxLength-field-label": "最长标签长度", 27 | "pagenetwork-labelMaxLength-field-help": "该节点标签的最高文字长度或在无限制情况下为0. 如果节点标签必须被缩短,一个省略号(…)将会被附加,", 28 | "pagenetwork-basic-tab-label": "基本选项", 29 | "pagenetwork-advanced-tab-label": "高级选项" 30 | } 31 | -------------------------------------------------------------------------------- /i18n/zh-hant.json: -------------------------------------------------------------------------------- 1 | { 2 | "@metadata": { 3 | "authors": [ 4 | "Kly" 5 | ] 6 | }, 7 | "network": "網路", 8 | "network-desc": "允許添加視覺化互動網路在您的 wiki 頁面", 9 | "network-aria": "網路視覺化顯示出{{PLURAL:$1|頁面}}$2的傳出與傳入連結", 10 | "pagenetwork-pages-field-label": "頁面", 11 | "pagenetwork-pages-field-help": "頁面的名稱或是顯示所連結的頁面,一行一個。預設為主頁面。", 12 | "pagenetwork-exclude-field-label": "排除的頁面", 13 | "pagenetwork-exclude-field-help": "從網路圖形排除的頁面,每行一個。", 14 | "pagenetwork-excludedNamespaces-field-label": "排除的命名空間", 15 | "pagenetwork-excludedNamespaces-field-help": "從網路圖形中排除的命名空間。", 16 | "pagenetwork-class-field-label": "CSS 類別", 17 | "pagenetwork-class-field-help": "添加額外的 css 類別到網路圖形,以空格分隔。", 18 | "pagenetwork-options-field-label": "圖形選項", 19 | "pagenetwork-options-field-help": "帶有 vis.js 圖形選項的 JSON 結構。", 20 | "pagenetwork-enableDisplayTitle-field-label": "啟用顯示標題", 21 | "pagenetwork-enableDisplayTitle-field-help": "頁面標題或是顯示標題是否應以節點標籤來顯示?", 22 | "pagenetwork-labelMaxLength-field-label": "標籤最大長度", 23 | "pagenetwork-labelMaxLength-field-help": "節點標籤的最大文字長度,若為 0 代表無限制。如果節點標籤必須被截短,將會附加一個省略號(…)。", 24 | "pagenetwork-basic-tab-label": "基本選項", 25 | "pagenetwork-advanced-tab-label": "進階選項" 26 | } 27 | -------------------------------------------------------------------------------- /phpcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | src/ 4 | tests/php/ 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /phpstan.neon: -------------------------------------------------------------------------------- 1 | parameters: 2 | level: 1 3 | paths: 4 | - src 5 | - tests 6 | scanDirectories: 7 | - ../../includes 8 | - ../../vendor 9 | bootstrapFiles: 10 | - ../../includes/AutoLoader.php 11 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 13 | 14 | 15 | tests/php 16 | 17 | 18 | 19 | 20 | src 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /psalm.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /resources/js/ApiConnectionsBuilder.js: -------------------------------------------------------------------------------- 1 | /** 2 | * MediaWiki API specific, visjs agnostic 3 | */ 4 | module.ApiConnectionsBuilder = ( function () { 5 | "use strict" 6 | 7 | let ApiConnectionsBuilder = function() { 8 | }; 9 | 10 | ApiConnectionsBuilder.prototype.connectionsFromApiResponses = function(apiResponse) { 11 | // console.log(JSON.stringify(apiResponse, null, 4)); 12 | 13 | let centralPages = this._centralPagesFromApiResponse(apiResponse); 14 | 15 | return { 16 | pages: this._buildPageList(centralPages), 17 | links: this._buildLinksList(centralPages) 18 | }; 19 | } 20 | 21 | ApiConnectionsBuilder.prototype._centralPagesFromApiResponse = function(apiResponse) { 22 | return Object.values(apiResponse.query.pages) 23 | .map(function(page) { 24 | return { 25 | outgoingLinks: page.links || [], 26 | incomingLinks: page.linkshere || [], 27 | externalLinks: page.extlinks || [], 28 | title: page.title, 29 | }; 30 | }); 31 | }; 32 | 33 | ApiConnectionsBuilder.prototype._buildPageList = function(centralPages) { 34 | return Object.values(this._buildPageMap(centralPages)) 35 | .map(function(page) { 36 | return { 37 | title: page.title, 38 | isExternal: page.external, 39 | isRedirect: page.isRedirect 40 | }; 41 | }); 42 | }; 43 | 44 | ApiConnectionsBuilder.prototype._buildPageMap = function(centralPages) { 45 | let pages = {}; 46 | 47 | centralPages.forEach(function(centralPage) { 48 | 49 | // *** we assume is not a redirect 50 | pages[centralPage.title] = { title: centralPage.title, external: false, isRedirect: false }; 51 | 52 | centralPage.outgoingLinks.forEach( 53 | page => { pages[page.title] = { title: page.title, external: false } } 54 | ); 55 | 56 | centralPage.incomingLinks.forEach( 57 | page => { pages[page.title] = { title: page.title, external: false, isRedirect: ( 'redirect' in page ) } } 58 | ); 59 | 60 | centralPage.externalLinks.forEach( 61 | page => { 62 | let link = page['*']; 63 | let pattern = mw.config.get('wgServer') + mw.config.get('wgArticlePath'); 64 | let titleLocation = pattern.indexOf('$1'); 65 | if (link.indexOf(pattern.substring(0, titleLocation)) === 0) { 66 | let title = mw.Title.newFromText(link.substring(titleLocation)); 67 | if (title !== null) { 68 | let titleStr = title.getPrefixedText(); 69 | page['*'] = titleStr; 70 | pages[titleStr] = { title: titleStr, external: false } 71 | } else { 72 | pages[page['*']] = { title: page['*'], external: true } 73 | } 74 | } else { 75 | pages[page['*']] = { title: page['*'], external: true } 76 | } 77 | } 78 | ); 79 | }); 80 | 81 | return pages; 82 | } 83 | 84 | ApiConnectionsBuilder.prototype._buildLinksList = function(centralPages) { 85 | return centralPages.map( 86 | centralPage => { 87 | return this._buildOutgoingLinks(centralPage.title, centralPage.outgoingLinks) 88 | .concat(this._buildIncomingLinks(centralPage.title, centralPage.incomingLinks)) 89 | .concat(this._buildExternalLinks(centralPage.title, centralPage.externalLinks)); 90 | } 91 | ).flat(); 92 | } 93 | 94 | ApiConnectionsBuilder.prototype._buildOutgoingLinks = function(sourceTitle, targetPages) { 95 | return targetPages.map( 96 | page => { 97 | return { 98 | from: sourceTitle, 99 | to: page.title 100 | }; 101 | } 102 | ); 103 | }; 104 | 105 | ApiConnectionsBuilder.prototype._buildExternalLinks = function(sourceTitle, targetPages) { 106 | return targetPages.map( 107 | page => { 108 | return { 109 | from: sourceTitle, 110 | to: page['*'] 111 | }; 112 | } 113 | ); 114 | }; 115 | 116 | ApiConnectionsBuilder.prototype._buildIncomingLinks = function(targetTitle, sourcePages) { 117 | return sourcePages.map( 118 | page => { 119 | return { 120 | from: page.title, 121 | to: targetTitle 122 | }; 123 | } 124 | ); 125 | }; 126 | 127 | return ApiConnectionsBuilder; 128 | 129 | }() ); 130 | -------------------------------------------------------------------------------- /resources/js/ApiPageConnectionRepo.js: -------------------------------------------------------------------------------- 1 | /** 2 | * MediaWiki API specific, visjs agnostic 3 | */ 4 | module.ApiPageConnectionRepo = ( function ( mw, ApiConnectionsBuilder ) { 5 | "use strict" 6 | 7 | /** 8 | * @param {boolean} enableDisplayTitle 9 | * @constructor 10 | */ 11 | let ApiPageConnectionRepo = function(enableDisplayTitle) { 12 | this._addedPages = []; 13 | this._enableDisplayTitle = enableDisplayTitle; 14 | }; 15 | 16 | /** 17 | * @param {string[]} pageNames 18 | * @return {Promise} 19 | */ 20 | ApiPageConnectionRepo.prototype.addConnections = function(pageNames) { 21 | return new Promise( 22 | function(resolve) { 23 | let pagesToAdd = pageNames.filter(page => !this._addedPages.includes(page)); 24 | 25 | if (pagesToAdd.length === 0) { 26 | resolve({pages: [], links: []}); 27 | } else { 28 | this._addedPages.concat(pagesToAdd); 29 | 30 | this._queryLinks(pagesToAdd).done( 31 | function(apiResponse) { 32 | this._apiResponseToPagesAndLinks(apiResponse).then(connections => resolve(connections)) 33 | }.bind(this) 34 | ); 35 | } 36 | }.bind(this) 37 | ); 38 | }; 39 | 40 | ApiPageConnectionRepo.prototype._apiResponseToPagesAndLinks = function(linkQueryResponse) { 41 | return new Promise( 42 | function(resolve) { 43 | let connections = (new ApiConnectionsBuilder()).connectionsFromApiResponses(linkQueryResponse) 44 | 45 | this._queryPageNodeInfo(connections.pages).done( 46 | function(pageInfoResponse) { 47 | let pages = Object.values(pageInfoResponse.query.pages) 48 | 49 | let missingPages = this._getMissingPages(pages) 50 | 51 | // @Attention!! this won't include the redirects 52 | // (the redirects are at pageInfoResponse.query.redirects !) 53 | // so connections.pages and pageInfoResponse.query.pages 54 | // may differ 55 | let displayTitles = this._getDisplayTitles(pages) 56 | 57 | this._getTitleIcons(pages) 58 | .then(function(titleIcons) { 59 | 60 | connections.pages.forEach(function(page) { 61 | if (missingPages.includes(page.title)) { 62 | page.isMissing = true; 63 | } 64 | 65 | if (page.isExternal) { 66 | page.displayTitle = page.title; 67 | } else if ( !page.isRedirect ) { 68 | page.displayTitle = displayTitles[page.title]; 69 | } else { 70 | page.displayTitle = page.title; 71 | } 72 | 73 | if (titleIcons.images[page.title]) { 74 | page.image = titleIcons.images[page.title]; 75 | } else if (titleIcons.text[page.title]) { 76 | page.text = titleIcons.text[page.title]; 77 | } 78 | }); 79 | 80 | resolve(connections); 81 | }) 82 | }.bind(this) 83 | ) 84 | }.bind(this) 85 | ); 86 | }; 87 | 88 | ApiPageConnectionRepo.prototype._queryLinks = function(pageNames) { 89 | return new mw.Api().get({ 90 | action: 'query', 91 | titles: pageNames, 92 | 93 | prop: ['links', 'linkshere', 'extlinks'], 94 | pllimit: 'max', 95 | lhlimit: 'max', 96 | ellimit: 'max', 97 | 98 | format: 'json', 99 | redirects: 'true' 100 | }); 101 | }; 102 | 103 | ApiPageConnectionRepo.prototype._queryPageNodeInfo = function(pageNodes) { 104 | let titles = pageNodes 105 | .filter(page => page.isExternal !== true) 106 | .map(page => page.title) 107 | 108 | let parameters = { 109 | action: 'query', 110 | titles: titles, 111 | 112 | prop: ['titleicons'], 113 | 114 | format: 'json', 115 | redirects: 'true' 116 | } 117 | if (this._enableDisplayTitle) { 118 | parameters.prop.push('pageprops'); 119 | } 120 | 121 | return new mw.Api().get(parameters); 122 | }; 123 | 124 | ApiPageConnectionRepo.prototype._queryFileUrls = function(fileNames) { 125 | return new mw.Api().get({ 126 | action: 'query', 127 | titles: fileNames, 128 | 129 | prop: ['imageinfo'], 130 | iiprop: 'url', 131 | 132 | format: 'json', 133 | redirects: 'true' 134 | }); 135 | }; 136 | 137 | ApiPageConnectionRepo.prototype._getMissingPages = function(pages) { 138 | return pages 139 | .filter(page => page.missing === '') 140 | .map(page => page.title); 141 | } 142 | 143 | ApiPageConnectionRepo.prototype._getDisplayTitles = function(pages) { 144 | let displayTitles = [] 145 | pages.forEach(function(page) { 146 | if (page.pageprops && page.pageprops.displaytitle) { 147 | displayTitles[page.title] = page.pageprops.displaytitle 148 | } else { 149 | displayTitles[page.title] = page.title 150 | } 151 | }) 152 | return displayTitles 153 | } 154 | 155 | ApiPageConnectionRepo.prototype._getTitleIcons = function(pages) { 156 | return new Promise( 157 | function(resolve) { 158 | let images = []; 159 | let text = []; 160 | let fileIcons = []; 161 | let fileSearch = []; 162 | pages.forEach(function(page) { 163 | if (page.titleicons) { 164 | try { 165 | let icons = JSON.parse(page.titleicons); 166 | for (let index in icons) { 167 | let icon = icons[index] 168 | if (icon.type === 'ooui') { 169 | images[page.title] = 'resources/lib/ooui/themes/wikimediaui/images/icons/' + icon.icon; 170 | break 171 | } else if (icon.type === 'file') { 172 | fileIcons[page.title] = icon.icon; 173 | fileSearch[icon.icon] = true; 174 | break 175 | } else if (icon.type === 'unicode') { 176 | text[page.title] = icon.icon; 177 | break 178 | } 179 | } 180 | } catch (e) { 181 | // do nothing 182 | } 183 | } 184 | }) 185 | 186 | let files = []; 187 | for (let index in fileSearch) { 188 | files.push(index); 189 | } 190 | this._queryFileUrls(files) 191 | .done(function(imageInfoResponse) { 192 | if (imageInfoResponse.query && imageInfoResponse.query.pages) { 193 | let fileUrls = []; 194 | var filePages = Object.values(imageInfoResponse.query.pages); 195 | filePages.forEach(function(filePage) { 196 | if (filePage.imageinfo && filePage.imageinfo[0] && filePage.imageinfo[0].url) { 197 | fileUrls[filePage.title] = filePage.imageinfo[0].url; 198 | } 199 | }) 200 | 201 | for (let page in fileIcons) { 202 | images[page] = fileUrls[fileIcons[page]]; 203 | } 204 | } 205 | 206 | resolve({'images': images, 'text': text}); 207 | }) 208 | }.bind(this) 209 | ) 210 | } 211 | 212 | return ApiPageConnectionRepo; 213 | 214 | }( window.mediaWiki, module.ApiConnectionsBuilder ) ); 215 | -------------------------------------------------------------------------------- /resources/js/Network.js: -------------------------------------------------------------------------------- 1 | module.Network = (function (vis, NetworkData) { 2 | "use strict" 3 | 4 | /** 5 | * @param {string} divId 6 | * @param {module.ApiPageConnectionRepo} pageConnectionRepo 7 | * @param {module.PageExclusionManager} pageExclusionManager 8 | * @param {object} options 9 | * @param {int} labelMaxLength 10 | */ 11 | let Network = function( 12 | divId, 13 | pageConnectionRepo, 14 | pageExclusionManager, 15 | options, 16 | labelMaxLength 17 | ) { 18 | this._pageConnectionRepo = pageConnectionRepo; 19 | this._data = new NetworkData(pageExclusionManager, labelMaxLength); 20 | this._options = options; 21 | this._network = this._newNetwork(divId); 22 | this._lastZoomPosition = {x:0, y:0} 23 | 24 | this._bindEvents(); 25 | }; 26 | 27 | /** 28 | * @param {string[]} pageNames 29 | * @return {Promise} 30 | */ 31 | Network.prototype.showPages = function(pageNames) { 32 | let promise = this._pageConnectionRepo.addConnections(pageNames); 33 | 34 | promise.then( 35 | connections => { 36 | this._data.addPages(connections.pages); 37 | this._data.addLinks(connections.links); 38 | } 39 | ); 40 | 41 | return promise; 42 | }; 43 | 44 | Network.prototype._addPage = function(pageName) { 45 | return this.showPages([pageName]); 46 | }; 47 | 48 | Network.prototype._newNetwork = function(divId) { 49 | return new vis.Network( 50 | document.getElementById(divId), 51 | { 52 | nodes: this._data.nodes, 53 | edges: this._data.edges, 54 | }, 55 | this._options 56 | ); 57 | }; 58 | 59 | Network.prototype._bindEvents = function() { 60 | this._network.on('doubleClick', this._onDoubleClick.bind(this)); 61 | this._network.on('hold', this._onHold.bind(this)); 62 | this._network.on('select', this._onSelect.bind(this)); 63 | this._network.on('zoom', this._onZoom.bind(this)); 64 | this._network.on('dragEnd', this._onDragEnd.bind(this)); 65 | }; 66 | 67 | Network.prototype._onDoubleClick = function(event) { 68 | if (event.nodes.length === 1) { 69 | let url = this._data.nodes.get(event.nodes[0]).getUrl(); 70 | 71 | window.open( url, "_self" ); 72 | } 73 | }; 74 | 75 | Network.prototype._onHold = function(event) { 76 | if (event.nodes.length === 1) { 77 | let node = this._data.nodes.get(event.nodes[0]); 78 | 79 | this._addPage(node.label).then(() => this._network.selectNodes([event.nodes[0]])); 80 | } 81 | }; 82 | 83 | Network.prototype._onSelect = function(event) { 84 | if (event.nodes.length === 0 && event.edges.length === 1) { 85 | let targetNodeId = this._data.edges.get(event.edges[0]).to; 86 | this._network.selectNodes([targetNodeId]); 87 | } 88 | }; 89 | 90 | Network.prototype._onZoom = function(event) { 91 | let MIN_ZOOM = 0.25 92 | let MAX_ZOOM = 3.0 93 | let scale = this._network.getScale() 94 | if (scale <= MIN_ZOOM) { 95 | this._network.moveTo({ 96 | position: this._lastZoomPosition, 97 | scale: MIN_ZOOM 98 | }); 99 | } 100 | else if (scale >= MAX_ZOOM) { 101 | this._network.moveTo({ 102 | position: this._lastZoomPosition, 103 | scale: MAX_ZOOM, 104 | }); 105 | } 106 | else { 107 | this._lastZoomPosition = this._network.getViewPosition() 108 | } 109 | } 110 | 111 | Network.prototype._onDragEnd = function(event) { 112 | this._lastZoomPosition = this._network.getViewPosition() 113 | } 114 | 115 | return Network; 116 | 117 | }(window.vis, module.NetworkData)); 118 | -------------------------------------------------------------------------------- /resources/js/NetworkData.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Visjs specific 3 | */ 4 | module.NetworkData = ( function ( vis, mw ) { 5 | "use strict" 6 | 7 | let NetworkData = function(pageExclusionManager, labelMaxLength) { 8 | this.nodes = new vis.DataSet(); 9 | this.edges = new vis.DataSet(); 10 | this._pageExclusionManager = pageExclusionManager; 11 | this._labelMaxLength = labelMaxLength; 12 | }; 13 | 14 | NetworkData.prototype.addPages = function(pages) { 15 | var maxlength = this._labelMaxLength; 16 | this.nodes.update( 17 | pages 18 | .filter(page => this._pageTitleIsAllowed(page.title)) 19 | .map(function(page) { 20 | if (maxlength > 0 && page.displayTitle.length > maxlength) { 21 | page.label = page.displayTitle.slice(0, maxlength) + '\u2026'; 22 | } else { 23 | page.label = page.displayTitle; 24 | } 25 | if (page.title !== page.displayTitle) { 26 | page.tooltip = page.displayTitle + ' (' + page.title + ')'; 27 | } else { 28 | page.tooltip = page.displayTitle; 29 | } 30 | if ( page.isRedirect ) { 31 | page.tooltip += ' (redirect)'; 32 | } 33 | return page; 34 | }) 35 | .map(function(page) { 36 | let node = { 37 | id: page.title, 38 | label: page.label, 39 | title: page.tooltip, 40 | 41 | getUrl: function() { 42 | if (page.isExternal) { 43 | return page.title; 44 | } 45 | let title = mw.Title.newFromText(page.title, page.ns); 46 | return title === null ? '' : title.getUrl(); 47 | } 48 | } 49 | 50 | if (page.isMissing) { 51 | node.group = 'redlink'; 52 | } else if (page.isExternal) { 53 | node.group = 'externallink'; 54 | } else { 55 | node.group = 'bluelink'; 56 | } 57 | 58 | if (page.image) { 59 | node.image = page.image; 60 | node.shape = 'image'; 61 | } 62 | 63 | if (page.text) { 64 | let txt = document.createElement("textarea"); 65 | txt.innerHTML = page.text + ' ' + node.label; 66 | node.label = txt.value; 67 | node.shape = 'text'; 68 | } 69 | 70 | return node; 71 | }) 72 | ); 73 | } 74 | 75 | NetworkData.prototype._pageTitleIsAllowed = function(pageTitle) { 76 | return !this._pageExclusionManager.isExcluded(pageTitle); 77 | } 78 | 79 | NetworkData.prototype.addLinks = function(links) { 80 | this.edges.update( 81 | links 82 | .filter(link => this._pageTitleIsAllowed(link.from) && this._pageTitleIsAllowed(link.to)) 83 | .map(function(link) { 84 | return { 85 | id: link.from + '|' + link.to, 86 | from: link.from, 87 | to: link.to, 88 | 89 | arrows: 'to', 90 | color: { 91 | inherit: 'to' 92 | } 93 | } 94 | }) 95 | ); 96 | } 97 | 98 | return NetworkData; 99 | 100 | }( window.vis, window.mediaWiki ) ); 101 | -------------------------------------------------------------------------------- /resources/js/PageExclusionManager.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Visjs agnostic 3 | */ 4 | module.PageExclusionManager = ( function (mw ) { 5 | "use strict" 6 | 7 | /** 8 | * @param {string[]} excludedPageNames 9 | * @param {int[]} excludedNamespaces 10 | * @param {boolean} excludeTalkPages 11 | */ 12 | let PageExclusionManager = function(excludedPageNames, excludedNamespaces, excludeTalkPages) { 13 | this.pages = excludedPageNames; 14 | this.namespaces = excludedNamespaces; 15 | this.excludeTalk = excludeTalkPages; 16 | }; 17 | 18 | /** 19 | * @param {string} pageName 20 | */ 21 | PageExclusionManager.prototype.isExcluded = function(pageName) { 22 | if (this.pages.includes(pageName)) { 23 | return true; 24 | } 25 | 26 | let title = mw.Title.newFromText(pageName); 27 | 28 | return title === null 29 | || (this.excludeTalk && this._isTalkPage(title)) 30 | || this.namespaces.includes(title.getNamespaceId().toString()); 31 | }; 32 | 33 | PageExclusionManager.prototype._isTalkPage = function(title) { 34 | // Can replace this function with title.isTalkPage() on MW 1.35+ 35 | let namespaceId = title.getNamespaceId(); 36 | return !!(namespaceId > 0 && namespaceId % 2); 37 | }; 38 | 39 | return PageExclusionManager; 40 | 41 | }( window.mediaWiki ) ); 42 | -------------------------------------------------------------------------------- /resources/js/SpecialForm.js: -------------------------------------------------------------------------------- 1 | 2 | ( function ( mw, netw ) { 3 | "use strict" 4 | 5 | mw.hook('wikipage.content').add(function($content) { 6 | $content.find('div.network-special-form').each(function() { 7 | let $this = $(this); 8 | let defaultValues = $this.data('defaultvalues'); 9 | let namespaces = $this.data('namespaces'); 10 | 11 | let pagesInput = new OO.ui.MultilineTextInputWidget({ 12 | name: 'pages', 13 | value: defaultValues['pages'], 14 | rows: 4 15 | }); 16 | let pagesField = new OO.ui.FieldLayout( 17 | pagesInput, 18 | { 19 | label: mw.message('pagenetwork-pages-field-label').text(), 20 | align: 'top', 21 | help: mw.message('pagenetwork-pages-field-help').text(), 22 | helpInline: true 23 | } ); 24 | 25 | let excludeInput = new OO.ui.MultilineTextInputWidget({ 26 | name: 'exclude', 27 | value: defaultValues['exclude'], 28 | rows: 4 29 | }); 30 | let excludeField = new OO.ui.FieldLayout( 31 | excludeInput, 32 | { 33 | label: mw.message('pagenetwork-exclude-field-label').text(), 34 | align: 'top', 35 | help: mw.message('pagenetwork-exclude-field-help').text(), 36 | helpInline: true 37 | } ); 38 | 39 | let value = []; 40 | let options = []; 41 | var index; 42 | for (index in namespaces) { 43 | if (defaultValues['excludedNamespaces'].includes(index)) { 44 | value.push(index); 45 | } 46 | options.push({ 47 | data: index, 48 | label: namespaces[index] 49 | }); 50 | } 51 | let excludedNamespacesInput = new OO.ui.CheckboxMultiselectInputWidget( { 52 | name: 'excludedNamespaces[]', 53 | value: value, 54 | options: options 55 | } ); 56 | let excludedNamespacesField = new OO.ui.FieldLayout( 57 | excludedNamespacesInput, 58 | { 59 | label: mw.message('pagenetwork-excludedNamespaces-field-label').text(), 60 | align: 'top', 61 | help: mw.message('pagenetwork-excludedNamespaces-field-help').text(), 62 | helpInline: true 63 | } ); 64 | 65 | let classInput = new OO.ui.TextInputWidget({ 66 | name: 'class', 67 | value: defaultValues['class'], 68 | }); 69 | let classField = new OO.ui.FieldLayout( 70 | classInput, 71 | { 72 | label: mw.message('pagenetwork-class-field-label').text(), 73 | align: 'top', 74 | help: mw.message('pagenetwork-class-field-help').text(), 75 | helpInline: true 76 | } ); 77 | 78 | let optionsInput = new OO.ui.MultilineTextInputWidget({ 79 | name: 'options', 80 | value: defaultValues['options'], 81 | rows: 20 82 | }); 83 | let optionsField = new OO.ui.FieldLayout( 84 | optionsInput, 85 | { 86 | label: mw.message('pagenetwork-options-field-label').text(), 87 | align: 'top', 88 | help: mw.message('pagenetwork-options-field-help').text(), 89 | helpInline: true 90 | } ); 91 | 92 | let enableDisplayTitleInput = new OO.ui.CheckboxInputWidget({ 93 | name: 'enableDisplayTitle', 94 | selected: defaultValues['enableDisplayTitle'], 95 | }); 96 | let enableDisplayTitleField = new OO.ui.FieldLayout( 97 | enableDisplayTitleInput, 98 | { 99 | label: mw.message('pagenetwork-enableDisplayTitle-field-label').text(), 100 | align: 'inline', 101 | help: mw.message('pagenetwork-enableDisplayTitle-field-help').text(), 102 | helpInline: true 103 | } ); 104 | 105 | let labelMaxLengthInput = new OO.ui.TextInputWidget({ 106 | name: 'labelMaxLength', 107 | value: defaultValues['labelMaxLength'], 108 | }); 109 | let labelMaxLengthField = new OO.ui.FieldLayout( 110 | labelMaxLengthInput, 111 | { 112 | label: mw.message('pagenetwork-labelMaxLength-field-label').text(), 113 | align: 'top', 114 | help: mw.message('pagenetwork-labelMaxLength-field-help').text(), 115 | helpInline: true 116 | } ); 117 | 118 | let submitButton = new OO.ui.ButtonInputWidget( { 119 | label: mw.message('htmlform-submit').text(), 120 | type: 'submit', 121 | flags: [ 122 | 'primary', 123 | 'progressive' 124 | ] 125 | }); 126 | 127 | let SpecialTabPanel = function TabPanel( name, config ) { 128 | OO.ui.TabPanelLayout.call( this, name, config ); 129 | if ( this.$element.is( ':empty' ) ) { 130 | this.$element.text( this.label ); 131 | } 132 | }; 133 | OO.inheritClass( SpecialTabPanel, OO.ui.TabPanelLayout ); 134 | 135 | let fieldset = new OO.ui.FieldLayout( 136 | new OO.ui.Widget( { 137 | content: [ 138 | new OO.ui.PanelLayout( { 139 | expanded: false, 140 | framed: false, 141 | content: [ 142 | new OO.ui.IndexLayout( { 143 | expanded: false, 144 | framed: false 145 | } ).addTabPanels( [ 146 | new SpecialTabPanel( 'first', { 147 | expanded: false, 148 | label: mw.message('pagenetwork-basic-tab-label').text(), 149 | content: [ 150 | pagesField, 151 | excludeField, 152 | excludedNamespacesField 153 | ] 154 | } ), 155 | new SpecialTabPanel( 'second', { 156 | expanded: false, 157 | label: mw.message('pagenetwork-advanced-tab-label').text(), 158 | content: [ 159 | classField, 160 | optionsField, 161 | enableDisplayTitleField, 162 | labelMaxLengthField 163 | ] 164 | } ), 165 | ] ) 166 | ] 167 | } ) 168 | ] 169 | } ), 170 | { 171 | align: 'top' 172 | } 173 | ); 174 | 175 | var form = new OO.ui.FormLayout( { 176 | items: [ fieldset, submitButton ], 177 | action: mw.Title.newFromText( mw.config.get( 'wgTitle' ), mw.config.get( 'wgNamespaceNumber' ) ).getUrl(), 178 | method: 'post' 179 | } ); 180 | 181 | $this.append( form.$element ); 182 | } ); 183 | 184 | } ); 185 | 186 | }( window.mediaWiki, module ) ); 187 | 188 | window.NetworkExtension = module; 189 | -------------------------------------------------------------------------------- /resources/js/index.js: -------------------------------------------------------------------------------- 1 | 2 | ( function ( mw, netw ) { 3 | "use strict" 4 | 5 | mw.hook('wikipage.content').add(function($content) { 6 | $content.find('div.network-visualization').each(function() { 7 | let $this = $(this); 8 | 9 | let network = new netw.Network( 10 | $this.attr('id'), 11 | new netw.ApiPageConnectionRepo($this.data('enabledisplaytitle')), 12 | new netw.PageExclusionManager( 13 | $this.data('excludedpages'), 14 | $this.data('excludednamespaces'), 15 | mw.config.get('networkExcludeTalkPages') 16 | ), 17 | $this.data('options'), 18 | $this.data('labelmaxlength') 19 | ); 20 | 21 | network.showPages($this.data('pages')).then(function() { 22 | $this.find('canvas:first').attr( 23 | 'aria-label', 24 | mw.message( 25 | 'network-aria', 26 | $this.data('pages').length, 27 | $this.data('pages').join(', ') 28 | ).parse() 29 | ); 30 | }); 31 | } ); 32 | } ); 33 | 34 | }( window.mediaWiki, module ) ); 35 | 36 | window.NetworkExtension = module; 37 | -------------------------------------------------------------------------------- /resources/network.css: -------------------------------------------------------------------------------- 1 | .network-visualization { 2 | width: 100%; 3 | height: 600px; 4 | } 5 | -------------------------------------------------------------------------------- /src/EntryPoints/NetworkFunction.php: -------------------------------------------------------------------------------- 1 | config = $config; 24 | } 25 | 26 | public static function onParserFirstCallInit( Parser $parser ): void { 27 | $parser->setFunctionHook( 28 | 'network', 29 | static function () { 30 | return ( new self( new NetworkConfig() ) )->handleParserFunctionCall( ...func_get_args() ); 31 | } 32 | ); 33 | } 34 | 35 | /** 36 | * @param Parser $parser 37 | * @param string ...$arguments 38 | * @return array|string 39 | */ 40 | public function handleParserFunctionCall( Parser $parser, string ...$arguments ) { 41 | $parser->getOutput()->addModules( [ 'ext.network' ] ); 42 | $parser->getOutput()->setJsConfigVar( 'networkExcludeTalkPages', $this->config->getExcludeTalkPages() ); 43 | 44 | $requestModel = new RequestModel(); 45 | $requestModel->functionArguments = $arguments; 46 | $requestModel->excludedNamespaces = $this->config->getExcludedNamespaces(); 47 | $requestModel->enableDisplayTitle = $this->config->getEnableDisplayTitle(); 48 | $requestModel->labelMaxLength = $this->config->getLabelMaxLength(); 49 | 50 | $title = $parser->getPage(); 51 | if ( $title instanceof Title ) { 52 | $requestModel->renderingPageName = $title->getFullText(); 53 | } 54 | 55 | $presenter = Extension::getFactory()->newParserFunctionNetworkPresenter(); 56 | 57 | $this->newUseCase( $presenter, $this->config )->run( $requestModel ); 58 | 59 | return $presenter->getReturnValue(); 60 | } 61 | 62 | private function newUseCase( NetworkPresenter $presenter, NetworkConfig $config ): NetworkUseCase { 63 | return Extension::getFactory()->newNetworkFunction( $presenter, $config ); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/EntryPoints/SpecialNetwork.php: -------------------------------------------------------------------------------- 1 | setHeaders(); 31 | 32 | $config = new NetworkConfig(); 33 | $params = $this->parseParams( $this->getRequest(), $config ); 34 | 35 | if ( $this->getRequest()->getCheck( 'pages' ) ) { 36 | $this->getOutput()->addHTML( $this->showGraph( $this->formatParams( $params ), $config ) ); 37 | } 38 | 39 | if ( !$this->including() ) { 40 | $this->showForm( $params, $config ); 41 | } 42 | } 43 | 44 | private function parseParams( WebRequest $request, NetworkConfig $config ): array { 45 | $params = []; 46 | 47 | if ( $request->getCheck( 'pages' ) ) { 48 | $params['pages'] = $request->getText( 'pages' ); 49 | if ( $params['pages'] === '' ) { 50 | $params['pages'] = Title::newMainPage()->getPrefixedText(); 51 | } 52 | } else { 53 | $params['pages'] = ''; 54 | } 55 | 56 | $params['exclude'] = $request->getText( 'exclude', '' ); 57 | 58 | /** 59 | * @psalm-suppress PossiblyNullArgument 60 | * @psalm-suppress PossiblyNullArrayAccess 61 | */ 62 | $params['excludedNamespaces'] = array_map( 63 | 'strval', 64 | $request->getArray( 'excludedNamespaces', $config->getExcludedNamespaces() ) 65 | ); 66 | 67 | $params['class'] = $request->getText( 'class', '' ); 68 | 69 | $params['options'] = $request->getText( 'options', json_encode( $config->getOptions(), JSON_PRETTY_PRINT ) ); 70 | 71 | if ( $this->including() ) { 72 | $params['enableDisplayTitle'] = 73 | filter_var( 74 | $request->getText( 'enableDisplayTitle', strval( $config->getEnableDisplayTitle() ) ), 75 | FILTER_VALIDATE_BOOL, 76 | FILTER_NULL_ON_FAILURE 77 | ); 78 | } elseif ( $request->getCheck( 'pages' ) ) { 79 | $params['enableDisplayTitle'] = $request->getCheck( 'enableDisplayTitle' ); 80 | } else { 81 | $params['enableDisplayTitle'] = $config->getEnableDisplayTitle(); 82 | } 83 | 84 | $params['labelMaxLength'] = $request->getInt( 'labelMaxLength', $config->getLabelMaxLength() ); 85 | 86 | return $params; 87 | } 88 | 89 | /** 90 | * @param array $params 91 | * @return string[] 92 | */ 93 | private function formatParams( array $params ): array { 94 | $formattedParams = []; 95 | if ( $params['pages'] === '' ) { 96 | $formattedParams['pages'] = 'pages=' . Title::newMainPage()->getPrefixedText(); 97 | } else { 98 | $formattedParams['pages'] = 'pages=' . strtr( $params['pages'], "\n", '|' ); 99 | } 100 | if ( $params['exclude'] !== '' ) { 101 | $formattedParams['exclude'] = 'exclude=' . strtr( $params['exclude'], "\n", ';' ); 102 | } 103 | if ( $params['excludedNamespaces'] !== [] ) { 104 | $formattedParams['excludedNamespaces'] = 'excludedNamespaces=' . implode( ',', $params['excludedNamespaces'] ); 105 | } 106 | if ( $params['class'] !== '' ) { 107 | $formattedParams['class'] = 'class=' . $params['class']; 108 | } 109 | $formattedParams['options'] = "options=" . $params['options']; 110 | $formattedParams['enableDisplayTitle'] = 'enableDisplayTitle=' . 111 | ( $params['enableDisplayTitle'] ? 'true' : 'false' ); 112 | $formattedParams['labelMaxLength'] = 'labelMaxLength=' . strval( $params['labelMaxLength'] ); 113 | return $formattedParams; 114 | } 115 | 116 | /** 117 | * @param string[] $arguments 118 | * @param NetworkConfig $config 119 | * @return string 120 | */ 121 | public function showGraph( array $arguments, NetworkConfig $config ): string { 122 | $output = $this->getOutput(); 123 | $output->addModules( [ 'ext.network' ] ); 124 | $output->addJsConfigVars( 'networkExcludeTalkPages', $config->getExcludeTalkPages() ); 125 | 126 | $requestModel = new RequestModel(); 127 | $requestModel->functionArguments = $arguments; 128 | $requestModel->excludedNamespaces = $config->getExcludedNamespaces(); 129 | $requestModel->enableDisplayTitle = $config->getEnableDisplayTitle(); 130 | $requestModel->labelMaxLength = $config->getLabelMaxLength(); 131 | 132 | /** 133 | * @psalm-suppress PossiblyNullReference 134 | */ 135 | $requestModel->renderingPageName = $output->getTitle()->getFullText(); 136 | $presenter = Extension::getFactory()->newSpecialNetworkPresenter(); 137 | 138 | $this->newUseCase( $presenter, $config )->run( $requestModel ); 139 | 140 | return $presenter->getReturnValue(); 141 | } 142 | 143 | private function newUseCase( NetworkPresenter $presenter, NetworkConfig $config ): NetworkUseCase { 144 | return Extension::getFactory()->newNetworkFunction( $presenter, $config ); 145 | } 146 | 147 | /** 148 | * @param string[] $defaultValues 149 | * @param NetworkConfig $config 150 | */ 151 | private function showForm( array $defaultValues, NetworkConfig $config ): void { 152 | $output = $this->getOutput(); 153 | $output->addModules( [ 'ext.network.special' ] ); 154 | $output->addHTML( Html::element( 155 | 'div', 156 | [ 157 | 'class' => 'network-special-form', 158 | 'data-defaultvalues' => json_encode( $defaultValues ), 159 | 'data-namespaces' => json_encode( $this->getNamespaces( $config ) ) 160 | ] 161 | ) ); 162 | } 163 | 164 | private function getNamespaces( NetworkConfig $config ): array { 165 | $namespaces = MediaWikiServices::getInstance()->getContentLanguage()->getFormattedNamespaces(); 166 | $namespaces[0] = ( new Message( 'blanknamespace' ) )->plain(); 167 | return array_filter( 168 | $namespaces, 169 | static function ( int $value ) use ( $config ) { 170 | if ( $value < 0 ) { 171 | return false; 172 | } 173 | if ( $config->getExcludeTalkPages() ) { 174 | return !( $value % 2 ); 175 | } 176 | return true; 177 | }, 178 | ARRAY_FILTER_USE_KEY 179 | ); 180 | } 181 | } 182 | -------------------------------------------------------------------------------- /src/Extension.php: -------------------------------------------------------------------------------- 1 | getOptions() ); 21 | } 22 | 23 | public function newParserFunctionNetworkPresenter(): ParserFunctionNetworkPresenter { 24 | return new ParserFunctionNetworkPresenter(); 25 | } 26 | 27 | public function newSpecialNetworkPresenter(): SpecialNetworkPresenter { 28 | return new SpecialNetworkPresenter(); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/NetworkFunction/AbstractNetworkPresenter.php: -------------------------------------------------------------------------------- 1 | html = 17 | Html::element( 18 | 'div', 19 | [ 20 | 'id' => 'network-viz-' . (string)self::$idCounter++, 21 | 'class' => $viewModel->cssClass, 22 | 'data-pages' => json_encode( $viewModel->pageNames ), 23 | 'data-excludedpages' => json_encode( $viewModel->excludedPages ), 24 | 'data-excludednamespaces' => json_encode( $viewModel->excludedNamespaces ), 25 | 'data-options' => json_encode( $viewModel->visJsOptions ), 26 | 'data-enabledisplaytitle' => json_encode( $viewModel->enableDisplayTitle ), 27 | 'data-labelmaxlength' => json_encode( $viewModel->labelMaxLength ), 28 | ] 29 | ); 30 | } 31 | 32 | public function setTooManyPagesError(): void { 33 | // TODO: i18n 34 | $this->html = 'Too many pages. Can only show connections for up to 100 pages.'; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/NetworkFunction/NetworkConfig.php: -------------------------------------------------------------------------------- 1 | getMainConfig(); 37 | $this->options = $config->get( 'PageNetworkOptions' ); 38 | $this->excludeTalkPages = (bool)$config->get( 'PageNetworkExcludeTalkPages' ); 39 | $this->excludedNamespaces = array_map( 'strval', $config->get( 'PageNetworkExcludedNamespaces' ) ); 40 | $this->enableDisplayTitle = (bool)$config->get( 'PageNetworkEnableDisplayTitle' ); 41 | $this->labelMaxLength = (int)$config->get( 'PageNetworkLabelMaxLength' ); 42 | } 43 | 44 | public function getOptions(): array { 45 | return $this->options; 46 | } 47 | 48 | public function getExcludeTalkPages(): bool { 49 | return $this->excludeTalkPages; 50 | } 51 | 52 | public function getExcludedNamespaces(): array { 53 | return $this->excludedNamespaces; 54 | } 55 | 56 | public function getEnableDisplayTitle(): bool { 57 | return $this->enableDisplayTitle; 58 | } 59 | 60 | public function getLabelMaxLength(): int { 61 | return $this->labelMaxLength; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/NetworkFunction/NetworkPresenter.php: -------------------------------------------------------------------------------- 1 | presenter = $presenter; 17 | $this->visJsOptions = $visJsOptions; 18 | } 19 | 20 | public function run( RequestModel $request ): void { 21 | $response = new ResponseModel(); 22 | $response->pageNames = $this->getPageNames( $request ); 23 | 24 | if ( count( $response->pageNames ) > 100 ) { 25 | $this->presenter->setTooManyPagesError(); 26 | return; 27 | } 28 | 29 | $keyValuePairs = $this->parserArgumentsToKeyValuePairs( $request->functionArguments ); 30 | 31 | $response->cssClass = $this->getCssClass( $keyValuePairs ); 32 | $response->excludedPages = $this->getExcludedPages( $keyValuePairs ); 33 | $response->excludedNamespaces = $this->getExcludedNamespaces( $keyValuePairs, $request->excludedNamespaces ); 34 | $response->enableDisplayTitle = $this->getEnableDisplayTitle( $keyValuePairs, $request->enableDisplayTitle ); 35 | $response->labelMaxLength = $this->getLabelMaxLength( $keyValuePairs, $request->labelMaxLength ); 36 | $response->visJsOptions = $this->getVisJsOptions( $keyValuePairs ); 37 | 38 | $this->presenter->buildGraph( $response ); 39 | } 40 | 41 | /** 42 | * @param string[] $arguments 43 | * @return string[] 44 | */ 45 | private function parserArgumentsToKeyValuePairs( array $arguments ): array { 46 | $pairs = []; 47 | 48 | foreach ( $arguments as $argument ) { 49 | [ $key, $value ] = $this->argumentStringToKeyValue( $argument ); 50 | 51 | if ( $key !== null ) { 52 | $pairs[$key] = $value; 53 | } 54 | } 55 | 56 | return $pairs; 57 | } 58 | 59 | private function argumentStringToKeyValue( string $argument ): array { 60 | if ( strpos( $argument, '=' ) === false ) { 61 | return [ null, $argument ]; 62 | } 63 | 64 | [ $key, $value ] = explode( '=', $argument ); 65 | return [ trim( $key ), trim( $value ) ]; 66 | } 67 | 68 | private function getVisJsOptions( array $arguments ): array { 69 | $visJsOptions = array_replace_recursive( 70 | $this->visJsOptions, 71 | json_decode( $arguments['options'] ?? '{}', true ) ?? [] 72 | ); 73 | return $visJsOptions; 74 | } 75 | 76 | /** 77 | * @param RequestModel $request 78 | * @return string[] 79 | */ 80 | private function getPageNames( RequestModel $request ): array { 81 | $pageNames = []; 82 | 83 | foreach ( $request->functionArguments as $argument ) { 84 | [ $key, $value ] = $this->argumentStringToKeyValue( $argument ); 85 | 86 | if ( $value !== '' && $this->isPageKey( $key ) ) { 87 | foreach ( $this->pagesStringToArray( $value, '|' ) as $pageName ) { 88 | $pageNames[] = $pageName; 89 | } 90 | } 91 | } 92 | 93 | if ( $pageNames === [] ) { 94 | $pageNames[] = $request->renderingPageName; 95 | } 96 | 97 | return $pageNames; 98 | } 99 | 100 | private function isPageKey( ?string $key ): bool { 101 | return $key === null || in_array( $key, [ 'page', 'pages' ] ); 102 | } 103 | 104 | /** 105 | * @param string $pages 106 | * @param non-empty-string $delimiter 107 | * @return string[] 108 | */ 109 | private function pagesStringToArray( string $pages, string $delimiter ): array { 110 | return array_values( 111 | array_filter( 112 | array_map( 113 | 'trim', 114 | explode( $delimiter, $pages ) 115 | ), 116 | static function ( string $pageName ): bool { 117 | return $pageName !== ''; 118 | } 119 | ) 120 | ); 121 | } 122 | 123 | private function getCssClass( array $arguments ): string { 124 | return trim( 'network-visualization ' . ( trim( $arguments['class'] ?? '' ) ) ); 125 | } 126 | 127 | /** 128 | * @param string[] $arguments 129 | * @return string[] 130 | */ 131 | private function getExcludedPages( array $arguments ): array { 132 | return $this->pagesStringToArray( $arguments['exclude'] ?? '', ';' ); 133 | } 134 | 135 | /** 136 | * @param string[] $arguments 137 | * @param int[] $excludedNamespaces 138 | * @return int[] 139 | */ 140 | private function getExcludedNamespaces( array $arguments, array $excludedNamespaces ): array { 141 | if ( !isset( $arguments['excludedNamespaces'] ) ) { 142 | return $excludedNamespaces; 143 | } 144 | $namespaces = explode( ',', $arguments['excludedNamespaces'] ); 145 | array_walk( $namespaces, 'intval' ); 146 | return $namespaces; 147 | } 148 | 149 | /** 150 | * @param string[] $arguments 151 | * @param bool $enableDisplayTitle 152 | * @return bool 153 | */ 154 | private function getEnableDisplayTitle( array $arguments, bool $enableDisplayTitle ): bool { 155 | return isset( $arguments['enableDisplayTitle'] ) 156 | ? filter_var( $arguments['enableDisplayTitle'], FILTER_VALIDATE_BOOLEAN ) 157 | : $enableDisplayTitle; 158 | } 159 | 160 | /** 161 | * @param string[] $arguments 162 | * @param int $labelMaxLength 163 | * @return int 164 | */ 165 | private function getLabelMaxLength( array $arguments, int $labelMaxLength ): int { 166 | return isset( $arguments['labelMaxLength'] ) ? (int)$arguments['labelMaxLength'] : $labelMaxLength; 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /src/NetworkFunction/ParserFunctionNetworkPresenter.php: -------------------------------------------------------------------------------- 1 | setHtml( $viewModel ); 16 | $this->parserFunctionReturnValue = [ 17 | $this->html, 18 | 'noparse' => true, 19 | 'isHTML' => true, 20 | ]; 21 | } 22 | 23 | /** 24 | * @return array 25 | */ 26 | public function getReturnValue(): array { 27 | return $this->parserFunctionReturnValue; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/NetworkFunction/RequestModel.php: -------------------------------------------------------------------------------- 1 | setHtml( $viewModel ); 11 | } 12 | 13 | /** 14 | * @return string 15 | */ 16 | public function getReturnValue() { 17 | return $this->html; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /tests/bootstrap.php: -------------------------------------------------------------------------------- 1 | assertSame( 20 | [ self::RENDERING_PAGE_NAME ], 21 | $this->runAndReturnPresenter( $this->newBasicRequestModel() )->getResponseModel()->pageNames 22 | ); 23 | } 24 | 25 | private function runAndReturnPresenter( RequestModel $requestModel ): SpyNetworkPresenter { 26 | $presenter = new SpyNetworkPresenter(); 27 | 28 | $visJsOptions = [ 29 | 'layout' => [ 30 | 'randomSeed' => 42 31 | ], 32 | 'physics' => [ 33 | 'barnesHut' => [ 34 | 'gravitationalConstant' => -5000, 35 | 'damping' => 0.242 36 | ] 37 | ] 38 | ]; 39 | ( new NetworkUseCase( $presenter, $visJsOptions ) )->run( $requestModel ); 40 | 41 | return $presenter; 42 | } 43 | 44 | private function newBasicRequestModel(): RequestModel { 45 | $request = new RequestModel(); 46 | 47 | $request->renderingPageName = 'MyPage'; 48 | $request->functionArguments = [ '' ]; 49 | $request->excludedNamespaces = []; 50 | $request->enableDisplayTitle = true; 51 | $request->labelMaxLength = 20; 52 | 53 | return $request; 54 | } 55 | 56 | public function testSpecifiedPageName() { 57 | $request = $this->newBasicRequestModel(); 58 | $request->functionArguments = [ 'page = Kittens' ]; 59 | 60 | $this->assertSame( 61 | [ 'Kittens' ], 62 | $this->runAndReturnPresenter( $request )->getResponseModel()->pageNames 63 | ); 64 | } 65 | 66 | public function testDefaultCssClass() { 67 | $request = $this->newBasicRequestModel(); 68 | 69 | $this->assertSame( 70 | 'network-visualization', 71 | $this->runAndReturnPresenter( $request )->getResponseModel()->cssClass 72 | ); 73 | } 74 | 75 | public function testSpecifiedCssClass() { 76 | $request = $this->newBasicRequestModel(); 77 | $request->functionArguments = [ 'class = col-lg-3 mt-2 ' ]; 78 | 79 | $this->assertSame( 80 | 'network-visualization col-lg-3 mt-2', 81 | $this->runAndReturnPresenter( $request )->getResponseModel()->cssClass 82 | ); 83 | } 84 | 85 | public function testMultiplePageNames() { 86 | $request = $this->newBasicRequestModel(); 87 | $request->functionArguments = [ 'Kittens', 'Cats', 'page = Tigers', 'page=Bobcats ' ]; 88 | 89 | $this->assertSame( 90 | [ 'Kittens', 'Cats', 'Tigers', 'Bobcats' ], 91 | $this->runAndReturnPresenter( $request )->getResponseModel()->pageNames 92 | ); 93 | } 94 | 95 | public function testPageParametersWithPipe() { 96 | $request = $this->newBasicRequestModel(); 97 | $request->functionArguments = [ 'Kittens|Cats', 'pages = Tigers|Bobcats' ]; 98 | 99 | $this->assertSame( 100 | [ 'Kittens', 'Cats', 'Tigers', 'Bobcats' ], 101 | $this->runAndReturnPresenter( $request )->getResponseModel()->pageNames 102 | ); 103 | } 104 | 105 | public function testNothingExcludedByDefault() { 106 | $this->assertSame( 107 | [], 108 | $this->runAndReturnPresenter( $this->newBasicRequestModel() )->getResponseModel()->excludedPages 109 | ); 110 | } 111 | 112 | public function testExclude() { 113 | $request = $this->newBasicRequestModel(); 114 | $request->functionArguments = [ 'Kittens', 'exclude = Foo ; Bar ; Baz:bah' ]; 115 | 116 | $this->assertSame( 117 | [ 'Foo', 'Bar', 'Baz:bah' ], 118 | $this->runAndReturnPresenter( $request )->getResponseModel()->excludedPages 119 | ); 120 | } 121 | 122 | public function testCanUseMaxPages() { 123 | $request = $this->newBasicRequestModel(); 124 | $request->functionArguments = $this->getPageNames( 100 ); 125 | 126 | $this->assertSame( 127 | $this->getPageNames( 100 ), 128 | $this->runAndReturnPresenter( $request )->getResponseModel()->pageNames 129 | ); 130 | } 131 | 132 | private function getPageNames( int $count ): array { 133 | $pageNames = []; 134 | 135 | for ( $i = 0; $i < $count; $i++ ) { 136 | $pageNames[] = 'Page' . (string)$i; 137 | } 138 | 139 | return $pageNames; 140 | } 141 | 142 | public function testMoreThanMaxPagesResultsInError() { 143 | $request = $this->newBasicRequestModel(); 144 | $request->functionArguments = $this->getPageNames( 101 ); 145 | 146 | $this->assertSame( 147 | [ 'too many pages' ], 148 | $this->runAndReturnPresenter( $request )->getErrors() 149 | ); 150 | } 151 | 152 | public function testDefaultEnableDisplayTitle() { 153 | $request = $this->newBasicRequestModel(); 154 | 155 | $this->assertTrue( 156 | $this->runAndReturnPresenter( $request )->getResponseModel()->enableDisplayTitle 157 | ); 158 | } 159 | 160 | public function testOverrideEnableDisplayTitleTrue() { 161 | $request = $this->newBasicRequestModel(); 162 | $request->functionArguments = [ 'enableDisplayTitle = true' ]; 163 | 164 | $this->assertTrue( 165 | $this->runAndReturnPresenter( $request )->getResponseModel()->enableDisplayTitle 166 | ); 167 | } 168 | 169 | public function testOverrideEnableDisplayTitleFalse() { 170 | $request = $this->newBasicRequestModel(); 171 | $request->functionArguments = [ 'enableDisplayTitle = false' ]; 172 | 173 | $this->assertFalse( 174 | $this->runAndReturnPresenter( $request )->getResponseModel()->enableDisplayTitle 175 | ); 176 | } 177 | 178 | public function testNoOptionsInLocalSettingsAndNoOptionsParameter() { 179 | $presenter = new SpyNetworkPresenter(); 180 | ( new NetworkUseCase( $presenter, [] ) )->run( $this->newBasicRequestModel() ); 181 | 182 | $this->assertSame( 183 | [], 184 | $presenter->getResponseModel()->visJsOptions 185 | ); 186 | } 187 | 188 | public function testOptionsInLocalSettings() { 189 | $setting = [ 190 | 'height' => '42%', 191 | 'layout' => [ 192 | 'foo' => 'bar' 193 | ], 194 | ]; 195 | 196 | $presenter = new SpyNetworkPresenter(); 197 | ( new NetworkUseCase( $presenter, $setting ) )->run( $this->newBasicRequestModel() ); 198 | 199 | $this->assertEquals( 200 | $setting, 201 | $presenter->getResponseModel()->visJsOptions 202 | ); 203 | } 204 | 205 | public function testOptionsParameter() { 206 | $request = $this->newBasicRequestModel(); 207 | $request->functionArguments = [ 'options={"nodes": {"shape": "box"}}' ]; 208 | 209 | $presenter = new SpyNetworkPresenter(); 210 | ( new NetworkUseCase( $presenter, [] ) )->run( $request ); 211 | 212 | $this->assertSame( 213 | [ 214 | 'nodes' => [ 215 | 'shape' => 'box', 216 | ] 217 | ], 218 | $presenter->getResponseModel()->visJsOptions 219 | ); 220 | } 221 | 222 | public function testOptionsParameterWithLocalSettingsConfig() { 223 | $setting = [ 224 | 'height' => '42%', 225 | 'nodes' => [ 226 | 'color' => 'blue', 227 | 'foo' => 'bar' 228 | ] 229 | ]; 230 | 231 | $request = $this->newBasicRequestModel(); 232 | $request->functionArguments = [ 'options={"nodes": {"shape": "box", "color": "red"}}' ]; 233 | 234 | $presenter = new SpyNetworkPresenter(); 235 | ( new NetworkUseCase( $presenter, $setting ) )->run( $request ); 236 | 237 | $this->assertEquals( 238 | [ 239 | 'height' => '42%', 240 | 'nodes' => [ 241 | 'color' => 'red', 242 | 'shape' => 'box', 243 | 'foo' => 'bar' 244 | ], 245 | ], 246 | $presenter->getResponseModel()->visJsOptions 247 | ); 248 | } 249 | } 250 | -------------------------------------------------------------------------------- /tests/php/NetworkFunction/SpyNetworkPresenter.php: -------------------------------------------------------------------------------- 1 | viewModel = $viewModel; 17 | } 18 | 19 | public function getResponseModel(): ?ResponseModel { 20 | return $this->viewModel; 21 | } 22 | 23 | public function setTooManyPagesError(): void { 24 | $this->errors[] = 'too many pages'; 25 | } 26 | 27 | public function getErrors(): array { 28 | return $this->errors; 29 | } 30 | 31 | public function getReturnValue(): array { 32 | return []; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /tests/php/NetworkFunctionIntegrationTest.php: -------------------------------------------------------------------------------- 1 | getParser() 19 | ->parse( $textToParse, \Title::newFromText( self::PAGE_TITLE ), new \ParserOptions( \User::newSystemUser( 'TestUser' ) ) )->getText(); 20 | } 21 | 22 | public function testWhenThereAreNoParameters_contextPageIsUsed() { 23 | $this->assertStringContainsString( 24 | 'data-pages="["ContextPageTitle"]"', 25 | $this->parse( '{{#network:}}' ) 26 | ); 27 | } 28 | 29 | public function testOptionsParameters() { 30 | $this->assertStringContainsString( 31 | '"shape":"tomato"', 32 | $this->parse( '{{#network:options={"nodes": {"shape": "tomato"} } }}' ) 33 | ); 34 | } 35 | 36 | } 37 | --------------------------------------------------------------------------------