Wikipedia:Lua/Modul/PageUtil/en
Wikipedia:Lua Modul PageUtil en
| Vorlagenprogrammierung | Diskussionen | Lua | Unterseiten | |||
| Modul | Deutsch | English
|
Modul: | Dokumentation | ||
PageUtil – Module with functions for entire wiki pages.
Functions for templates
- getCategories
- Which categories apply to this page?
- Parameter (optional):
- 1
- Page name
- Default: Current page
- Result is a list of category titles separated by
|- „Wikipedia:Lua/Modul/Dokumentation“
getContentModel- Obsolete since September 2025; use parser function {{#contentmodel}}
- Parameter (optional):
- 1
- Page name
- Default: Current page
- Result is canonical content model of this page
- getProtection
- Is this page protected?
- Parameters (all optional):
- 1
- Page name
- Default: Current page
- 2
- action
- Default:
edit - Others:
move/create/upload
- Result is one of: empty,
½,¾,1 - isRedirect
- Is this a redirect page?
- Result is empty, if transcluded in regular page; on redirect page a non-empty string
- merge
- Merge pages.
- Result is a string concatenating particular content without line breaks.
- Up to 200 pages and sections might be transcluded.
- Parameters (all optional):
- 1
- First text element.
- One of following formats:
[[page name]]- Transclude entire page.
- Links on this page will be replaced by internal links.
#lst: [[page name]]mark
#lstx: [[page name]]mark- Transclude section of a page.
- Since it is unknown which fragments could be accessed, for this page no inner links will be modified.
- Other arbitrary text.
- Line breaks can be created safely by the following syntax:
| <nowiki />
=== Conclusion ===
<nowiki />
- 2 3 4 5 6 7 8 9 …
- More text elements, any number.
- The text elements will be transcluded in numerical sequence of parameter name.
- failsafe
The Failsafe interface is heading for version management of globally distributed Lua modules. It enables modules equipped with this interface to
- ensure, that a library module required by a template or another module available as local copy does support certain functionality, or complain if not.
- administrate global updating and linking of module codes via Wikidata.
The Failsafe interface is present both at template level and for direct Lua access.
The functions in detail are (not all supported yet completely by every library):
| Value | Result | current |
|---|---|---|
nothingfalse
|
local version ID | »2025-01-01« |
| Minimal version | version ID required at least date in ISO format It will be compared whether the current local implementation matches this version or later.
|
|
wikidata
|
version ID of global upstream
|
»2025-01-01« |
item
|
ID of the Wikidata item
|
Q89064539
|
~
|
Corresponding version ID locally and registered at Wikidata
|
»« |
@
|
Is the current (module) page linked correctly with Wikidata item?
|
|
The return value is in template programming empty or under Lua false, otherwis a non-empty string as described.
| ||
Functions for Lua modules (API)
Some functions described above can be used by other modules per require():
local lucky, PageUtil = pcall( require, "Module:PageUtil" )
if type( PageUtil ) == "table" then
PageUtil = PageUtil()
else
-- error case; PageUtil contains message
return "<span class=\"error\">" .. PageUtil .. "</span>"
end
Subsequently there are available:
- PageUtil.getProtection( source, stage )
-
- source – (optional) string or mw.title for that page
- stage – (optional) string with action
- Returns number, one of: 0, 0.5, 0.75, 1
- PageUtil.merge( args, frame )
-
- args – table with parameters like for templates
- frame – object or
nil
- PageUtil.failsafe( since )
Directly available are:
mw.title.getCurrentTitle().categories
mw.title.getCurrentTitle().contentModel
mw.title.getCurrentTitle().isRedirect
Usage
General library; no limitations.
Dependencies
None.
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.