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
32bfe22b
Commit
32bfe22b
authored
Jan 17, 2007
by
Richard Mansfield
Browse files
Add size and link options for file listself rendering
parent
f9778cdc
Changes
3
Hide whitespace changes
Inline
Side-by-side
htdocs/artefact/file/lang/en.utf8/artefact.file.php
View file @
32bfe22b
...
...
@@ -27,6 +27,7 @@
defined
(
'INTERNAL'
)
||
die
();
$string
[
'adminfilesloaded'
]
=
'Admin files loaded'
;
$string
[
'bytes'
]
=
'bytes'
;
$string
[
'changessaved'
]
=
'Changes saved'
;
$string
[
'contents'
]
=
'Contents'
;
$string
[
'copyrightnotice'
]
=
'Copyright notice'
;
...
...
htdocs/artefact/file/lib.php
View file @
32bfe22b
...
...
@@ -460,13 +460,41 @@ class ArtefactTypeFile extends ArtefactTypeFileBase {
set_config_plugin
(
'artefact'
,
'file'
,
'defaultquota'
,
$values
[
'defaultquota'
]);
}
public
function
short_size
()
{
$bytes
=
$this
->
get
(
'size'
);
if
(
$bytes
<
1024
)
{
return
$bytes
<=
0
?
'0'
:
(
$bytes
.
' '
.
get_string
(
'bytes'
,
'artefact.file'
));
}
if
(
$bytes
<
1048576
)
{
return
floor
((
$bytes
/
1024
)
*
10
+
0.5
)
/
10
.
'k'
;
}
return
floor
((
$bytes
/
1048576
)
*
10
+
0.5
)
/
10
.
'M'
;
}
private
function
file_url
()
{
return
get_config
(
'wwwroot'
)
.
'artefact/file/download.php?file='
.
$this
->
get
(
'id'
);
}
public
function
listself
(
$options
)
{
$smarty
=
smarty
();
if
(
isset
(
$options
[
'link'
])
&&
$options
[
'link'
])
{
$smarty
->
assign
(
'title'
,
'<a href="'
.
$this
->
file_url
()
.
'">'
.
$this
->
get
(
'title'
)
.
'</a>'
);
}
else
{
$smarty
->
assign
(
'title'
,
$this
->
get
(
'title'
));
}
if
(
isset
(
$options
[
'size'
])
&&
$options
[
'size'
])
{
$smarty
->
assign
(
'size'
,
$this
->
short_size
());
}
return
$smarty
->
fetch
(
'artefact:file:file_listself.tpl'
);
}
protected
function
get_metadata
()
{
$data
=
parent
::
get_metadata
();
$data
[
'size'
]
=
array
(
'name'
=>
get_string
(
'size'
,
'artefact.file'
),
'value'
=>
$this
->
get
(
'size'
));
$url
=
get_config
(
'wwwroot'
)
.
'artefact/file/download.php?file='
.
$this
->
get
(
'id'
);
'value'
=>
$this
->
get
(
'size'
)
.
' '
.
get_string
(
'bytes'
,
'artefact.file'
));
$data
[
'download'
]
=
array
(
'name'
=>
get_string
(
'download'
,
'artefact.file'
),
'value'
=>
make_link
(
$url
));
'value'
=>
make_link
(
$
this
->
file_
url
()
));
return
$data
;
}
...
...
@@ -513,7 +541,7 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
$smarty
=
smarty
();
$smarty
->
assign
(
'title'
,
$this
->
get
(
'title'
));
if
(
isset
(
$options
[
'size'
])
&&
$options
[
'size'
])
{
$smarty
->
assign
(
'size'
,
$this
->
count_children
());
$smarty
->
assign
(
'size'
,
$this
->
count_children
()
.
' '
.
get_string
(
'files'
,
'artefact.file'
)
);
}
return
$smarty
->
fetch
(
'artefact:file:folder_listself.tpl'
);
}
...
...
@@ -585,7 +613,7 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
protected
function
get_metadata
()
{
$data
=
parent
::
get_metadata
();
$data
[
'size'
]
=
array
(
'name'
=>
get_string
(
'size'
,
'artefact.file'
),
'value'
=>
$this
->
count_children
());
'value'
=>
$this
->
count_children
()
.
' '
.
get_string
(
'files'
,
'artefact.file'
)
);
return
$data
;
}
...
...
htdocs/artefact/file/theme/default/folder_listself.tpl
View file @
32bfe22b
<div>
{
$title
}
{
if
isset
(
$size
)
}
(
{
$size
}
{
str
tag
=
files
section
=
artefact
.
file
}
)
(
{
$size
}
)
{/
if
}
</div>
Write
Preview
Supports
Markdown
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