Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
964d059e
Commit
964d059e
authored
Dec 07, 2006
by
Penny Leach
Browse files
added unique id validation in template parser. fixed the blog and profile
template to obey this
parent
3aaaa1b9
Changes
2
Hide whitespace changes
Inline
Side-by-side
htdocs/lib/template.php
View file @
964d059e
...
...
@@ -39,7 +39,7 @@ function template_parse($templatename) {
preg_match_all
(
'/(.*?)\{\{(.*?)\}\}/xms'
,
$fragment
,
$matches
,
PREG_SET_ORDER
);
$strlen
=
0
;
$blockids
=
array
();
foreach
(
$matches
as
$m
)
{
$temp
=
array
(
'type'
=>
'html'
,
'content'
=>
$m
[
1
],
...
...
@@ -49,11 +49,17 @@ function template_parse($templatename) {
'data'
=>
template_parse_block
(
$m
[
2
]),
);
$t
[]
=
$temp
;
$blockids
[]
=
$temp
[
'data'
][
'id'
];
$strlen
+=
strlen
(
$m
[
0
]);
}
if
(
count
(
$blockids
)
!=
count
(
array_unique
(
$blockids
)))
{
$dups
=
array_unique
(
array_diff_assoc
(
$blockids
,
array_unique
(
$blockids
)));
throw
new
InvalidArgumentException
(
"This template (
$templatename
) has duplicate block ids: "
.
implode
(
', '
,
$dups
));
}
$temp
=
array
(
'type'
=>
'html'
,
'content'
=>
substr
(
$fragment
,
$strlen
),
);
...
...
htdocs/lib/templates/blogandprofile/fragment.template
View file @
964d059e
...
...
@@ -9,7 +9,7 @@
<td>
{{block type="label" id="tpl_blogslabel"}}<br>
{{block type="artefact" id="tpl_blog1" artefacttype="blog"}}<br>
{{block type="artefact" id="tpl_blog
1
" artefacttype="blog"}}<br>
{{block type="artefact" id="tpl_blog
2
" artefacttype="blog"}}<br>
</td>
<td>
{{block type="label" id="tpl_profilelabel"}}<br>
...
...
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