Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
ad306c96
Commit
ad306c96
authored
May 05, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor cleanup in config handling, reduce xmlparse call overhead
parent
7953e21f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
19 deletions
+20
-19
Config.php
src/opnsense/mvc/app/library/OPNsense/Core/Config.php
+20
-19
No files found.
src/opnsense/mvc/app/library/OPNsense/Core/Config.php
View file @
ad306c96
...
@@ -98,43 +98,44 @@ class Config extends Singleton
...
@@ -98,43 +98,44 @@ class Config extends Singleton
}
}
foreach
(
$node
->
children
()
as
$xmlNode
)
{
foreach
(
$node
->
children
()
as
$xmlNode
)
{
$xmlNodeName
=
$xmlNode
->
getName
();
if
(
$xmlNode
->
count
()
>
0
)
{
if
(
$xmlNode
->
count
()
>
0
)
{
$tmpNode
=
$this
->
toArray
(
$forceList
,
$xmlNode
);
$tmpNode
=
$this
->
toArray
(
$forceList
,
$xmlNode
);
if
(
array_key_exists
(
$xmlNode
->
getName
()
,
$result
))
{
if
(
array_key_exists
(
$xmlNode
Name
,
$result
))
{
$old_content
=
$result
[
$xmlNode
->
getName
()
];
$old_content
=
$result
[
$xmlNode
Name
];
// check if array content is associative, move items to new list
// check if array content is associative, move items to new list
// (handles first item of specific type)
// (handles first item of specific type)
if
(
!
$this
->
isArraySequential
(
$old_content
))
{
if
(
!
$this
->
isArraySequential
(
$old_content
))
{
$result
[
$xmlNode
->
getName
()
]
=
array
();
$result
[
$xmlNode
Name
]
=
array
();
$result
[
$xmlNode
->
getName
()
][]
=
$old_content
;
$result
[
$xmlNode
Name
][]
=
$old_content
;
}
}
$result
[
$xmlNode
->
getName
()
][]
=
$tmpNode
;
$result
[
$xmlNode
Name
][]
=
$tmpNode
;
}
elseif
(
is_array
(
$forceList
)
&&
array_key_exists
(
$xmlNode
->
getName
()
,
$forceList
))
{
}
elseif
(
is_array
(
$forceList
)
&&
array_key_exists
(
$xmlNode
Name
,
$forceList
))
{
// force tag in an array
// force tag in an array
$result
[
$xmlNode
->
getName
()
]
=
array
();
$result
[
$xmlNode
Name
]
=
array
();
$result
[
$xmlNode
->
getName
()
][]
=
$tmpNode
;
$result
[
$xmlNode
Name
][]
=
$tmpNode
;
}
else
{
}
else
{
$result
[
$xmlNode
->
getName
()
]
=
$tmpNode
;
$result
[
$xmlNode
Name
]
=
$tmpNode
;
}
}
}
else
{
}
else
{
if
(
array_key_exists
(
$xmlNode
->
getName
()
,
$result
))
{
if
(
array_key_exists
(
$xmlNode
Name
,
$result
))
{
// repeating item
// repeating item
if
(
!
is_array
(
$result
[
$xmlNode
->
getName
()
]))
{
if
(
!
is_array
(
$result
[
$xmlNode
Name
]))
{
// move first item into list
// move first item into list
$tmp
=
$result
[
$xmlNode
->
getName
()
];
$tmp
=
$result
[
$xmlNode
Name
];
$result
[
$xmlNode
->
getName
()
]
=
array
();
$result
[
$xmlNode
Name
]
=
array
();
$result
[
$xmlNode
->
getName
()
][]
=
$tmp
;
$result
[
$xmlNode
Name
][]
=
$tmp
;
}
}
$result
[
$xmlNode
->
getName
()
][]
=
$xmlNode
->
__toString
();
$result
[
$xmlNode
Name
][]
=
$xmlNode
->
__toString
();
}
else
{
}
else
{
// single content item
// single content item
if
(
is_array
(
$forceList
)
&&
array_key_exists
(
$xmlNode
->
getName
()
,
$forceList
))
{
if
(
is_array
(
$forceList
)
&&
array_key_exists
(
$xmlNode
Name
,
$forceList
))
{
$result
[
$xmlNode
->
getName
()
]
=
array
();
$result
[
$xmlNode
Name
]
=
array
();
if
(
$xmlNode
->
__toString
()
!=
null
&&
trim
(
$xmlNode
->
__toString
())
!==
""
)
{
if
(
$xmlNode
->
__toString
()
!=
null
&&
trim
(
$xmlNode
->
__toString
())
!==
""
)
{
$result
[
$xmlNode
->
getName
()
][]
=
$xmlNode
->
__toString
();
$result
[
$xmlNode
Name
][]
=
$xmlNode
->
__toString
();
}
}
}
else
{
}
else
{
$result
[
$xmlNode
->
getName
()
]
=
$xmlNode
->
__toString
();
$result
[
$xmlNode
Name
]
=
$xmlNode
->
__toString
();
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment