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
e17c4120
Commit
e17c4120
authored
Dec 12, 2006
by
Martyn Smith
Committed by
Martyn Smith
Dec 12, 2006
Browse files
Added rendering fixes, and code to retain artefact placement
parent
b9e6ddb4
Changes
1
Hide whitespace changes
Inline
Side-by-side
htdocs/lib/template.php
View file @
e17c4120
...
...
@@ -311,7 +311,7 @@ function template_render($template, $mode, $data=array()) {
$attr
=
array
(
'id'
=>
$t
[
'id'
],
'class'
=>
array
(
'block'
),
'class'
=>
array
(),
);
if
(
isset
(
$t
[
'width'
])
&&
isset
(
$t
[
'height'
]))
{
...
...
@@ -323,6 +323,7 @@ function template_render($template, $mode, $data=array()) {
switch
(
$t
[
'type'
])
{
case
'label'
;
if
(
$mode
==
TEMPLATE_RENDER_EDITMODE
)
{
$attr
[
'class'
][]
=
'block'
;
$block
.
=
template_render_label_editmode
(
$t
,
$data
);
}
else
{
...
...
@@ -342,12 +343,12 @@ function template_render($template, $mode, $data=array()) {
break
;
case
'description'
;
if
(
isset
(
$data
[
'description'
]))
{
$block
.
=
hsc
(
$data
[
'description'
]
)
;
$block
.
=
$data
[
'description'
];
}
break
;
case
'artefact'
;
$
classes
=
array
(
'block'
)
;
$
attr
[
'class'
][]
=
'block'
;
$droplist
[
$t
[
'id'
]]
=
array
(
'artefacttype'
=>
isset
(
$t
[
'artefacttype'
])
?
$t
[
'artefacttype'
]
:
null
,
'plugintype'
=>
isset
(
$t
[
'plugintype'
])
?
$t
[
'plugintype'
]
:
null
,
...
...
@@ -363,9 +364,29 @@ function template_render($template, $mode, $data=array()) {
$format
=
$data
[
$t
[
'id'
]][
'format'
];
}
$block
.
=
$artefact
->
render
(
$format
,
null
);
$block
.
=
'<input type="hidden" name="template['
.
$t
[
'id'
]
.
'][id]" value="'
.
hsc
(
$data
[
$t
[
'id'
]][
'id'
])
.
'">'
;
$block
.
=
'<input type="hidden" name="template['
.
$t
[
'id'
]
.
'][format]" value="'
.
hsc
(
$format
)
.
'">'
;
}
else
if
(
isset
(
$t
[
'defaultartefacttype'
])
)
{
$artefact
=
null
;
try
{
$artefact
=
artefact_instance_from_type
(
$t
[
'defaultartefacttype'
]);
}
catch
(
ArtefactNotFoundException
$e
)
{
}
if
(
$artefact
===
null
)
{
$block
.
=
template_render_empty_artefact_block
();
}
else
{
$block
.
=
$artefact
->
render
(
$t
[
'defaultformat'
],
null
);
$block
.
=
'<input type="hidden" name="template['
.
$t
[
'id'
]
.
'][id]" value="'
.
hsc
(
$artefact
->
get
(
'id'
))
.
'">'
;
$block
.
=
'<input type="hidden" name="template['
.
$t
[
'id'
]
.
'][format]" value="'
.
hsc
(
$t
[
'defaultformat'
])
.
'">'
;
}
}
else
{
$block
.
=
'<i>'
.
get_string
(
'empty_block'
,
'view'
)
.
'</i>'
;
$block
.
=
template_render_empty_artefact_block
()
;
}
break
;
...
...
@@ -514,7 +535,8 @@ EOF;
*/
function
template_render_label_editmode
(
$block
,
$data
)
{
if
(
isset
(
$data
[
$block
[
'id'
]][
'value'
]))
{
return
'<script type="text/javascript">addLoadEvent(function() { $('
.
json_encode
(
$block
[
'id'
])
.
').labelValue = '
.
json_encode
(
$data
[
$block
[
'id'
]][
'value'
])
.
';});</script><span class="clickable" onclick="setLabel('
.
hsc
(
json_encode
(
$block
[
'id'
]))
.
');">'
.
hsc
(
$data
[
$block
[
'id'
]][
'value'
])
.
'</span>'
;
return
'<script type="text/javascript">addLoadEvent(function() { $('
.
json_encode
(
$block
[
'id'
])
.
').labelValue = '
.
json_encode
(
$data
[
$block
[
'id'
]][
'value'
])
.
';});</script><span class="clickable" onclick="setLabel('
.
hsc
(
json_encode
(
$block
[
'id'
]))
.
');">'
.
hsc
(
$data
[
$block
[
'id'
]][
'value'
])
.
'</span>'
.
'<input type="hidden" name="template['
.
$block
[
'id'
]
.
'][value]" value="'
.
hsc
(
$data
[
$block
[
'id'
]][
'value'
])
.
'">'
;
}
else
{
return
'<em class="clickable" onclick="setLabel('
.
hsc
(
json_encode
(
$block
[
'id'
]))
.
');">'
.
get_string
(
'emptylabel'
,
'view'
)
.
'</em>'
;
...
...
@@ -530,10 +552,10 @@ function template_render_attributes($attr) {
$html
=
''
;
foreach
(
$attr
as
$key
=>
$value
)
{
if
(
is_array
(
$value
))
{
if
(
is_array
(
$value
)
&&
count
(
$value
)
>
0
)
{
$html
.
=
' '
.
$key
.
'="'
.
join
(
' '
,
array_map
(
'hsc'
,
$value
))
.
'"'
;
}
else
{
else
if
(
!
is_array
(
$value
))
{
$html
.
=
' '
.
$key
.
'="'
.
hsc
(
$value
)
.
'"'
;
}
}
...
...
@@ -577,4 +599,8 @@ function template_format_owner($format, $user) {
}
}
function
template_render_empty_artefact_block
()
{
return
'<i>'
.
get_string
(
'empty_block'
,
'view'
)
.
'</i>'
;
}
?>
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