https://wiki.hisgis.nl/index.php?title=Module:Ns_has_subpages&feed=atom&action=historyModule:Ns has subpages - Bewerkingsoverzicht2024-03-28T12:11:33ZBewerkingsoverzicht voor deze pagina op de wikiMediaWiki 1.38.2https://wiki.hisgis.nl/index.php?title=Module:Ns_has_subpages&diff=1071&oldid=prevThomas: 1 versie geïmporteerd2019-09-05T16:57:51Z<p>1 versie geïmporteerd</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<tr class="diff-title" lang="nl">
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">← Oudere versie</td>
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">Versie van 5 sep 2019 17:57</td>
</tr><tr><td colspan="2" class="diff-notice" lang="nl"><div class="mw-diff-empty">(geen verschil)</div>
</td></tr></table>Thomashttps://wiki.hisgis.nl/index.php?title=Module:Ns_has_subpages&diff=1072&oldid=previnterwiki>Mr. Stradivarius: Protected Module:Ns has subpages: High-risk Lua module ([Edit=Allow only template editors and admins] (indefinite) [Move=Allow only template editors and admins] (indefinite))2014-12-10T06:37:29Z<p>Protected Module:Ns has subpages: <a href="/index.php?title=WP:High-risk_templates&action=edit&redlink=1" class="new" title="WP:High-risk templates (de pagina bestaat niet)">High-risk Lua module</a> ([Edit=Allow only template editors and admins] (indefinite) [Move=Allow only template editors and admins] (indefinite))</p>
<p><b>Nieuwe pagina</b></p><div>-- This module implements [[Template:Ns has subpages]].<br />
-- While the template is fairly simple, this information is made available to<br />
-- Lua directly, so using a module means that we don't have to update the<br />
-- template as new namespaces are added.<br />
<br />
local p = {}<br />
<br />
function p._main(ns, frame)<br />
-- Get the current namespace if we were not passed one.<br />
if not ns then<br />
ns = mw.title.getCurrentTitle().namespace<br />
end<br />
<br />
-- Look up the namespace table from mw.site.namespaces. This should work<br />
-- for a majority of cases.<br />
local nsTable = mw.site.namespaces[ns]<br />
<br />
-- Try using string matching to get the namespace from page names.<br />
-- Do a quick and dirty bad title check to try and make sure we do the same<br />
-- thing as {{NAMESPACE}} in most cases.<br />
if not nsTable and type(ns) == 'string' and not ns:find('[<>|%[%]{}]') then<br />
local nsStripped = ns:gsub('^[_%s]*:', '')<br />
nsStripped = nsStripped:gsub(':.*$', '')<br />
nsTable = mw.site.namespaces[nsStripped]<br />
end<br />
<br />
-- If we still have no match then try the {{NAMESPACE}} parser function,<br />
-- which should catch the remainder of cases. Don't use a mw.title object,<br />
-- as this would increment the expensive function count for each new page<br />
-- tested.<br />
if not nsTable then<br />
frame = frame or mw.getCurrentFrame()<br />
local nsProcessed = frame:callParserFunction('NAMESPACE', ns)<br />
nsTable = nsProcessed and mw.site.namespaces[nsProcessed]<br />
end<br />
<br />
return nsTable and nsTable.hasSubpages<br />
end<br />
<br />
function p.main(frame)<br />
local ns = frame:getParent().args[1]<br />
if ns then<br />
ns = ns:match('^%s*(.-)%s*$') -- trim whitespace<br />
ns = tonumber(ns) or ns<br />
end<br />
local hasSubpages = p._main(ns, frame)<br />
return hasSubpages and 'yes' or ''<br />
end<br />
<br />
return p</div>interwiki>Mr. Stradivarius