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