Template:EditButton/CheckList
From Metabolomics.JP
< Template:EditButton(Difference between revisions)
m (Sandbox93 moved to Template:EditButton/CheckList) |
|||
(9 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | # | + | <!-- |
+ | {{#get:listpage}} リストページ | ||
+ | {{#get:initset}} 現在セットされている項目。&&区切りの文字列 | ||
+ | {{#get:prevpage}} 飛んできたページ | ||
+ | {{#get:title}} 「species」や「効能」と言ったようなタイトル | ||
+ | {{#get:separator}} Separator symbol for the selected items | ||
+ | -->{{#lua: | ||
+ | --%% Preprocessing %%-- | ||
+ | local list = {} -- データリスト | ||
+ | local i = 0; | ||
+ | for line in string.gmatch(stdin,"[^\n]+") do --%% 空行を飛ばして読み込む %%-- | ||
+ | list[i] = string.gsub(line, "^%s*(.-)%s*$", "%1"); | ||
+ | i = i + 1; | ||
+ | end | ||
+ | --%% Display Setting %%-- | ||
+ | print('{{#form' .. 'tag:form|action="/wiki/{{#get:prevpage}}" method="post"|') | ||
+ | print('{{#form' .. 'tag:input|type="submit" value="update"}}<br>') | ||
+ | |||
+ | local head, body; | ||
+ | for i = 0, table.maxn(list) do | ||
+ | head = string.match(list[i], "^([\*\#]+%s*)"); | ||
+ | --%% If *,# precedes a line, then place a checkbox, otherwise not. %%-- | ||
+ | if (head ~= nil) then | ||
+ | body = string.sub(list[i],string.len(head)+1); | ||
+ | --%% Check whether items are already selected.%%-- | ||
+ | if (string.match("{{#get:initset}}", "{{#get:separator}}" .. body .. "{{#get:separator}}", 0) or | ||
+ | string.match("{{#get:initset}}", "^" .. body .. "{{#get:separator}}", 0) or | ||
+ | string.match("{{#get:initset}}", "{{#get:separator}}" .. body .. "$", 0) ) then | ||
+ | checked = ' checked="yes"' | ||
+ | else | ||
+ | checked = '' | ||
+ | end | ||
+ | print(head .. '{{#form' .. 'tag:input|type="checkbox" value="' .. body .. '" name="list[]" id="' .. body .. '"' .. checked .. '}}{{#form' .. 'tag:label|for="' .. body .. '"|' .. body .. '}}<br>') | ||
+ | else | ||
+ | print(list[i]); | ||
+ | end | ||
+ | end | ||
+ | print('{{#form' .. 'tag:input|type="hidden" name="listpage" value="{{#get:listpage}}"}}') | ||
+ | print('{{#form' .. 'tag:input|type="hidden" name="title" value="{{#get:title}}"}}') | ||
+ | print('{{#form' .. 'tag:input|type="hidden" name="separator" value="{{#get:separator}}"}}') | ||
+ | print('{{#form' .. 'tag:input|type="hidden" name="hookinsert" value="__HOOK_AND_INSERT__"}}') | ||
+ | print('{{#form' .. 'tag:input|type="submit" value="update"}}') | ||
+ | print('}}') | ||
+ | |{{ {{#get:listpage}} }} | ||
+ | }} |