Add seperate tag that contains fields
This commit is contained in:
parent
bc410afa0c
commit
d83d268e80
@ -22,10 +22,15 @@ local function cmd(args)
|
|||||||
entry.attrs.date = env.stringDate(os.date("*t",os.time()))
|
entry.attrs.date = env.stringDate(os.date("*t",os.time()))
|
||||||
entry.children = {}
|
entry.children = {}
|
||||||
entry.children[1] = {}
|
entry.children[1] = {}
|
||||||
entry.children[1].tag = "history"
|
entry.children[1].tag = "fields"
|
||||||
entry.children[1].attrs = {}
|
entry.children[1].attrs = {}
|
||||||
entry.children[1].children = {}
|
entry.children[1].children = {}
|
||||||
entry.children[1].parent = entry
|
entry.children[1].parent = entry
|
||||||
|
entry.children[2] = {}
|
||||||
|
entry.children[2].tag = "history"
|
||||||
|
entry.children[2].attrs = {}
|
||||||
|
entry.children[2].children = {}
|
||||||
|
entry.children[2].parent = entry
|
||||||
|
|
||||||
entry.parent = entries
|
entry.parent = entries
|
||||||
table.insert(entries.children,entry)
|
table.insert(entries.children,entry)
|
||||||
|
@ -12,9 +12,17 @@ local function cmd(args)
|
|||||||
hentry.children = {}
|
hentry.children = {}
|
||||||
hentry.parent = history
|
hentry.parent = history
|
||||||
|
|
||||||
for i,field in pairs(env.xmlFindTags(entry,"field")) do
|
local hfields = {}
|
||||||
|
hfields.tag = "fields"
|
||||||
|
hfields.attrs = {}
|
||||||
|
hfields.children = {}
|
||||||
|
hfields.parent = hentry
|
||||||
|
table.insert(hentry.children,hfields)
|
||||||
|
|
||||||
|
local fields = env.xmlFindTags(entry,"fields")[1]
|
||||||
|
for i,field in pairs(fields.children) do
|
||||||
local hfield = {}
|
local hfield = {}
|
||||||
hfield.tag = "field"
|
hfield.tag = field.tag
|
||||||
hfield.attrs = {}
|
hfield.attrs = {}
|
||||||
hfield.children = {}
|
hfield.children = {}
|
||||||
hfield.parent = hfields
|
hfield.parent = hfields
|
||||||
@ -23,7 +31,7 @@ local function cmd(args)
|
|||||||
end
|
end
|
||||||
hfield.children[1] = {}
|
hfield.children[1] = {}
|
||||||
hfield.children[1].text = field.children[1].text
|
hfield.children[1].text = field.children[1].text
|
||||||
table.insert(hentry.children,hfield)
|
table.insert(hfields.children,hfield)
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(history.children,hentry)
|
table.insert(history.children,hentry)
|
||||||
|
@ -4,6 +4,7 @@ local function cmd(args)
|
|||||||
if entry.attrs.id == args[2] then
|
if entry.attrs.id == args[2] then
|
||||||
entry.attrs.removed = "true"
|
entry.attrs.removed = "true"
|
||||||
env.changed = true
|
env.changed = true
|
||||||
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -2,8 +2,7 @@ local function cmd(args)
|
|||||||
local entries = env.xmlFindTags(env.db,"entries")[1]
|
local entries = env.xmlFindTags(env.db,"entries")[1]
|
||||||
for i,v in pairs(entries.children) do
|
for i,v in pairs(entries.children) do
|
||||||
if v.attrs.id == args[2] then
|
if v.attrs.id == args[2] then
|
||||||
local fields = env.xmlFindTags(v,"field")
|
for i,v in pairs(env.xmlFindTags(v,"fields")[1].children) do
|
||||||
for i,v in pairs(fields) do
|
|
||||||
if v.attrs.name == args[3] then
|
if v.attrs.name == args[3] then
|
||||||
print(v.children[1].text)
|
print(v.children[1].text)
|
||||||
end
|
end
|
||||||
|
@ -2,8 +2,7 @@ local function cmd(args)
|
|||||||
local entries = env.xmlFindTags(env.db,"entries")[1]
|
local entries = env.xmlFindTags(env.db,"entries")[1]
|
||||||
for i,v in pairs(entries.children) do
|
for i,v in pairs(entries.children) do
|
||||||
if v.attrs.id == args[2] then
|
if v.attrs.id == args[2] then
|
||||||
local fields = env.xmlFindTags(v,"field")
|
for i,v in pairs(env.xmlFindTags(v,"fields")[1].children) do
|
||||||
for i,v in pairs(fields) do
|
|
||||||
if v.attrs.name == args[3] then
|
if v.attrs.name == args[3] then
|
||||||
print(v.attrs.type)
|
print(v.attrs.type)
|
||||||
end
|
end
|
||||||
|
@ -2,8 +2,7 @@ local function cmd(args)
|
|||||||
local entries = env.xmlFindTags(env.db,"entries")[1]
|
local entries = env.xmlFindTags(env.db,"entries")[1]
|
||||||
for i,v in pairs(entries.children) do
|
for i,v in pairs(entries.children) do
|
||||||
if v.attrs.id == args[2] and not v.attrs.deleted then
|
if v.attrs.id == args[2] and not v.attrs.deleted then
|
||||||
local fields = env.xmlFindTags(v,"field")
|
for i,v in pairs(env.xmlFindTags(v,"fields")[1].children) do
|
||||||
for i,v in pairs(fields) do
|
|
||||||
print(v.attrs.name)
|
print(v.attrs.name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
local function cmd(args)
|
local function cmd(args)
|
||||||
local entries = env.xmlFindTags(env.db,"entries")[1]
|
local entries = env.xmlFindTags(env.db,"entries")[1]
|
||||||
for i,entry in pairs(entries.children) do
|
for i,entry in pairs(entries.children) do
|
||||||
if entry.attrs.id == args[2] then
|
local fields = env.xmlFindTags(entry,"fields")[1]
|
||||||
for i,field in pairs(entry.children) do
|
for i,v in pairs(fields.children) do
|
||||||
if field.tag == "field" then
|
if v.attrs.name == args[3] then
|
||||||
if field.attrs.name == args[3] then
|
table.remove(fields.children,i)
|
||||||
table.remove(entry.children,i)
|
|
||||||
entry.attrs.date = env.stringDate(os.date("*t",os.time()))
|
entry.attrs.date = env.stringDate(os.date("*t",os.time()))
|
||||||
env.changed = true
|
env.changed = true
|
||||||
end
|
break
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -2,9 +2,9 @@ local function cmd(args)
|
|||||||
local entries = env.xmlFindTags(env.db,"entries")[1]
|
local entries = env.xmlFindTags(env.db,"entries")[1]
|
||||||
for i,entry in pairs(entries.children) do
|
for i,entry in pairs(entries.children) do
|
||||||
if entry.attrs.id == args[2] then
|
if entry.attrs.id == args[2] then
|
||||||
local fields = env.xmlFindTags(entry,"field")
|
local fields = env.xmlFindTags(entry,"fields")[1]
|
||||||
local field = false
|
local field = false
|
||||||
for i,v in pairs(fields) do
|
for i,v in pairs(fields.children) do
|
||||||
if v.attrs.name == args[3] then
|
if v.attrs.name == args[3] then
|
||||||
field = v
|
field = v
|
||||||
end
|
end
|
||||||
@ -22,7 +22,7 @@ local function cmd(args)
|
|||||||
field.parent = fields
|
field.parent = fields
|
||||||
field.children = {}
|
field.children = {}
|
||||||
field.children[1] = {}
|
field.children[1] = {}
|
||||||
table.insert(entry.children,field)
|
table.insert(fields.children,field)
|
||||||
end
|
end
|
||||||
|
|
||||||
if field.children[1] == nil then field.children[1] = {} end
|
if field.children[1] == nil then field.children[1] = {} end
|
||||||
|
@ -2,8 +2,7 @@ local function cmd(args)
|
|||||||
local entries = env.xmlFindTags(env.db,"entries")[1]
|
local entries = env.xmlFindTags(env.db,"entries")[1]
|
||||||
for i,entry in pairs(entries.children) do
|
for i,entry in pairs(entries.children) do
|
||||||
if entry.attrs.id == args[2] then
|
if entry.attrs.id == args[2] then
|
||||||
local fields = env.xmlFindTags(entry,"field")
|
for i,v in pairs(env.xmlFindTags(entry,"fields")[1].children) do
|
||||||
for i,v in pairs(fields) do
|
|
||||||
if v.attrs.name == args[3] then
|
if v.attrs.name == args[3] then
|
||||||
v.attrs.type = args[4]
|
v.attrs.type = args[4]
|
||||||
entry.attrs.date = env.stringDate(os.date("*t",os.time()))
|
entry.attrs.date = env.stringDate(os.date("*t",os.time()))
|
||||||
|
Loading…
Reference in New Issue
Block a user