Jump to content
MediaWiki

Rozšíření funkcí parseru

From mediawiki.org
This page is a translated version of the page Parser function extensions and the translation is 100% complete.
Tato stránka je zastaralá.
Byla napsána pro starší verzi MediaWiki a nemusí se vztahovat na nejnovější verzi. Pokud jste zkontrolovali nebo aktualizovali tuto stránku a zjistili jste, že obsah je vhodný, odstraňte toto upozornění.

"Funkce analyzátoeu (parseru) " je konstrukt podobný šabloně, který vrací hodnotu na základě alespoň jednoho nepojmenovaného parametru odděleného od názvu funkce dvojtečkou [:]. Mohou existovat i další parametry; stejně jako u běžných šablon, i těmto dodatečným parametrům předchází "svislítko" [|]. V případě znaku hash na začátku názvu funkce (který zabraňuje kolizi s jmennými prostory a prefixy interwiki) může, ale nemusí být tento znak považován za součást názvu. Pokud je považován za součást názvu, syntaxe má tvar

{{functionname: argument 1 | argument 2 | argument 3...}}
Pokud volající nemá žádné argumenty pro poskytnutí funkce parseru, pak je tvar jednoduše {{functionname:}}<nowiki>, nebo pokud je použit znak hash (jak je obvykle případ), pak je tvar <nowiki>{{#functionname:<nowiki>

<nowiki>. Pokud není zadána koncová dvojtečka, pak functionname není parserem rozpoznán.}}

Argumenty nemohou přímo obsahovat "|" nebo "}}", s výjimkou případů, kdy jsou součástí kódu volání šablony, volání funkce parseru, proměnné, odkazu nebo obrázku, ale mohou je obsahovat libovolně pomocí šablony, např. m:Template:!, nebo funkce parseru.

Kód může určit, zda se v názvu funkce rozlišují velká a malá písmena.

Oddělení argumentů od sebe navzájem je pomocí "|" a od názvu funkce je pomocí prvního středníku ":". Rozbalení každé z těchto částí je standardní, jako v Special:ExpandTemplates (což je mimochodem dobré místo pro experimentování, pokud se tyto věci učíte) a je mimo kontrolu samotné funkce parseru.

Všechno ostatní se však může u jednotlivých parserových funkcí lišit, včetně:

  • zda je argument pouze hodnotou, nebo má tvar parname = parvalue nebo cokoli jiného
  • pokud je to relevantní, zda se v názvech parametrů rozlišují velká a malá písmena

Syntaxe předepsaná rozšířením funkce parseru

Vzhledem k výše uvedenému je výhodné vytvořit rozšíření tak, aby syntaxe použitá v argumentu neobsahovala znak svislé čáry "|" ani dvojité závorky (konkrétněji dvojité uzavírací závorky "}}"). A to i přes skutečnost, že by se svislá čára jinak jevila jako vhodný symbol např. pro volbu nebo sjednocení (viz např. [1]). Povolení takových kódů je neškodné, pokud je povolen i alternativní kód, např. "\" pro "|".

Tabulka funkcí

rozšíření funkce verze MediaWiki
built-in lc 1.7+
built-in uc 1.7+
built-in lcfirst 1.7+
built-in ucfirst 1.7+
built-in urlencode 1.7+
built-in anchorencode 1.8+
built-in localurl 1.7+
built-in fullurl 1.7+
built-in #language 1.7+
built-in #special 1.9+
built-in #tag 1.12+
ParserFunctions (usage ) #expr 1.19+
ParserFunctions (usage ) #ifexpr 1.19+
ParserFunctions (usage ) #if 1.19+
ParserFunctions (usage ) #ifeq 1.19+
ParserFunctions (usage ) #ifexist 1.19+
ParserFunctions (usage ) #rel2abs 1.19+
ParserFunctions (usage ) #titleparts 1.19+
ParserFunctions (usage ) #switch 1.19+
ParserFunctions (usage ) #time 1.19+
AddScriptCss #addscript Archived
Arrays #arraydefine 1.23+
Arrays #arraydiff 1.23+
Arrays #arrayindex 1.23+
Arrays #arrayintersect 1.23+
Arrays #arraymerge 1.23+
Arrays #arrayprint 1.23+
Arrays #arrayreset 1.23+
Arrays #arraysearch 1.23+
Arrays #arraysearcharray 1.23+
Arrays #arraysize 1.23+
Arrays #arrayslice 1.23+
Arrays #arraysort 1.23+
Arrays #arraytohash 1.23+
Arrays #arrayunion 1.23+
Arrays #arrayunique 1.23+
Arrays #hashtoarray 1.23+
Attachments #attach 1.31+
Attachments #exturl 1.31+
Babylón #babel 1.30+
CSS #css 1.25+
Coordinate #coordinate Archived
Counter #+ 1.15+
Data #data Archived
Data #sort Archived
DynamicFunctions #arg Archived
DynamicFunctions #ip Archived
DynamicFunctions #rand Archived
DynamicFunctions #skin Archived
DynamicPageList (third-party) #dpl Archived
DynamicPageList3 #dpl 1.39+
ExpandAfter #expandafter (deprecated , see: #tag) Archived
ForeachFunction #foreachx Archived
ForeachFunction #foreachy Archived
HasCategory #ifhascat Archived
HideNamespace #hidens Archived
HideNamespace #unhidens Archived
ImageLink #img (old: #imagelink, deprecated ) Archived
Infobox Data Capture #dataentry Archived
Infobox Data Capture #listsplit Archived
InterWikiLinkManager #iwl Archived
KeyValue #keyvalue Archived
Labeled Section Transclusion #lst 1.25+
Labeled Section Transclusion #lstx 1.25+
Labeled Section Transclusion #lsth 1.25+
LoopFunctions #for 1.23+
LoopFunctions #foreach 1.25+
Loops #while 1.25+
Loops #dowhile 1.25+
Loops #forargs 1.25+
Loops #fornumargs 1.25+
Loops #loop 1.25+
Maps #geocode 1.27+
Maps #display_map 1.27+
Maps #display_point 1.27+
Maps #coordinates 1.27+
Maps #distance 1.27+
MediaFunctions #media.. 1.23+
PageAfterAndBefore #pagebefore Archived
PageAfterAndBefore #pageafter Archived
PageAfterAndBefore #firstpage Archived
PageAfterAndBefore #lastpage Archived
PageFunctions #pagetitle Archived
PageFunctions #pagesubtitle Archived
PageFunctions #pageexists Archived
PageFunctions #varset Archived
PageFunctions #varget Archived
PageFunctions #varcapset Archived
PageFunctions #cshow Archived
PageFunctions #varaset Archived
PageFunctions #varaget Archived
ParserFunctions (extended) #expr (extended) Archived
ParserFunctions (extended) #ifexpr (extended) Archived
ParserFunctions (extended) #min Archived
ParserFunctions (extended) #max Archived
ParserFunctions (extended) #if Archived
ParserFunctions (extended) #ifeq Archived
ParserFunctions (extended) #ifexist Archived
ParserFunctions (extended) #rel2abs Archived
ParserFunctions (extended) #switch Archived
ParserFunctions (extended) #time Archived
Pipe Escape #! 1.23+
QPoll #qpuserchoice Archived
RegexTools #regex Archived
RegexTools #regex_vars Archived
Scribunto #invoke
SecureProperties #pg Archived
SecureProperties #ps Archived
SecureProperties #pf Archived
SecureProperties #gg Archived
SecureProperties #gs Archived
Semantic MediaWiki #ask 1.27+
Semantic MediaWiki #concept 1.27+
Semantic MediaWiki #info 1.27+
Semantic MediaWiki #show 1.27+
Semantic MediaWiki #set 1.27+
StringFunctions #len 1.7+
StringFunctions #pos 1.7+
StringFunctions #rpos 1.7+
StringFunctions #sub 1.7+
StringFunctions #pad 1.7+
StringFunctions #replace 1.7+
StringFunctions #explode 1.7+
StringFunctions #urlencode 1.7+
StringFunctions #urldecode 1.7+
TreeAndMenu #tree 1.23+
TreeAndMenu #menu 1.23+
Variables #vardefine 1.29+
Variables #vardefineecho 1.29+
Variables #var 1.29+
Variables #varexists 1.29+
Variables #var_final 1.29+
Wikibase Client #property
Wikibase Client #statements

Související odkazy

AltStyle によって変換されたページ (->オリジナル) /