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
22f2e49c
Commit
22f2e49c
authored
Aug 27, 2007
by
Penny Leach
Committed by
Nigel McNie
Oct 17, 2007
Browse files
more deleting
parent
2225e6d5
Changes
4
Hide whitespace changes
Inline
Side-by-side
htdocs/artefact/blog/lib.php
View file @
22f2e49c
...
...
@@ -229,111 +229,15 @@ class ArtefactTypeBlog extends ArtefactType {
}
}
/**
* This function overrides the default functionality for listing children,
* using a smarty template and tablerenderer stuff.
*
* @param array
* @return string
*/
protected
function
listchildren
(
$options
)
{
// This is because if there are multiple blocks on a page, they need separate
// js variables.
$blockid
=
isset
(
$options
[
'blockid'
])
?
$options
[
'blockid'
]
:
mt_rand
();
$this
->
add_to_render_path
(
$options
);
// This uses the above blockid, so needs to be inlcuded after.
$javascript
=
require
(
get_config
(
'docroot'
)
.
'artefact/blog/render/blog_listchildren.js.php'
);
$smarty
=
smarty
();
$smarty
->
assign
(
'artefact'
,
$this
);
$smarty
->
assign
(
'blockid'
,
$blockid
);
$smarty
->
assign_by_ref
(
'options'
,
$options
);
return
array
(
'html'
=>
$smarty
->
fetch
(
'artefact:blog:render/blog_listchildren.tpl'
),
'javascript'
=>
$javascript
);
}
public
function
describe_size
()
{
return
$this
->
count_children
()
.
' '
.
get_string
(
'posts'
,
'artefact.blog'
);
}
/**
* This function implements the render_full functionality for blogs.
* Rendering full involves rendering blog posts with render_full, and
* possibly some other stuff.
*
* @param array
* @return string
*/
function
render_full
(
$options
)
{
// This is because if there are multiple blocks on a page, they need separate
// js variables.
$blockid
=
isset
(
$options
[
'blockid'
])
?
$options
[
'blockid'
]
:
mt_rand
();
$this
->
add_to_render_path
(
$options
);
// This uses the above blockid, so needs to be inlcuded after.
$javascript
=
require
(
get_config
(
'docroot'
)
.
'artefact/blog/render/blog_renderfull.js.php'
);
$smarty
=
smarty
();
if
(
isset
(
$options
[
'viewid'
]))
{
$smarty
->
assign
(
'artefacttitle'
,
'<a href="'
.
get_config
(
'wwwroot'
)
.
'view/view.php?view='
.
$options
[
'viewid'
]
.
'&artefact='
.
$this
->
get
(
'id'
)
.
'">'
.
$this
->
get
(
'title'
)
.
'</a>'
);
}
else
{
$smarty
->
assign
(
'artefacttitle'
,
$this
->
get
(
'title'
));
}
$smarty
->
assign
(
'blockid'
,
$blockid
);
$smarty
->
assign_by_ref
(
'options'
,
$options
);
return
array
(
'html'
=>
$smarty
->
fetch
(
'artefact:blog:render/blog_renderfull.tpl'
),
'javascript'
=>
$javascript
);
}
protected
function
get_metadata
(
$options
=
array
())
{
$data
=
parent
::
get_metadata
(
$options
);
$data
[
'description'
]
=
array
(
'name'
=>
get_string
(
'description'
),
'value'
=>
$this
->
get
(
'description'
));
$data
[
'type'
][
'value'
]
=
get_string
(
$this
->
get
(
'artefacttype'
),
'artefact.blog'
);
$data
[
'size'
]
=
array
(
'name'
=>
get_string
(
'size'
),
'value'
=>
$this
->
count_children
()
.
' '
.
get_string
(
'posts'
,
'artefact.blog'
));
if
(
isset
(
$options
[
'viewid'
])
&&
artefact_in_view
(
$id
=
$this
->
get
(
'id'
),
$options
[
'viewid'
]))
{
$data
[
'title'
][
'value'
]
=
'<a href="'
.
get_config
(
'wwwroot'
)
.
'view/view.php?view='
.
$options
[
'viewid'
]
.
'&artefact='
.
$id
.
'">'
.
$data
[
'title'
][
'value'
]
.
'</a>'
;
}
return
$data
;
}
protected
function
render_metadata
(
$options
)
{
$smarty
=
smarty
();
$smarty
->
assign
(
'PROPERTIES'
,
$this
->
get_metadata
(
$options
));
return
array
(
'html'
=>
$smarty
->
fetch
(
'artefact:blog:render/blog_rendermetadata.tpl'
),
'javascript'
=>
null
);
}
public
function
get_icon
()
{
}
public
static
function
get_render_list
()
{
return
array_values
(
array_unique
(
array_merge
(
array
(
FORMAT_ARTEFACT_LISTCHILDREN
,
FORMAT_ARTEFACT_RENDERFULL
),
parent
::
get_render_list
()
)));
}
public
static
function
is_singular
()
{
return
false
;
}
...
...
@@ -527,47 +431,6 @@ class ArtefactTypeBlogPost extends ArtefactType {
return
$this
->
count_attachments
()
.
' '
.
get_string
(
'attachments'
,
'artefact.blog'
);
}
/**
* This function displays the blogpost in renderfull mode.
*
* @param array
*/
protected
function
render_full
(
$options
)
{
$smarty
=
smarty
();
if
(
isset
(
$options
[
'viewid'
]))
{
$smarty
->
assign
(
'artefacttitle'
,
'<a href="'
.
get_config
(
'wwwroot'
)
.
'view/view.php?view='
.
$options
[
'viewid'
]
.
'&artefact='
.
$this
->
get
(
'id'
)
.
'">'
.
$this
->
get
(
'title'
)
.
'</a>'
);
}
else
{
$smarty
->
assign
(
'artefacttitle'
,
$this
->
get
(
'title'
));
}
// We need to make sure that the images in the post have the right viewid associated with them
$postcontent
=
$this
->
get
(
'description'
);
if
(
isset
(
$options
[
'viewid'
]))
{
$postcontent
=
preg_replace
(
'#(<img src=".*artefact/file/download\.php\?file=\d+)#'
,
'\1&view='
.
$options
[
'viewid'
],
$postcontent
);
}
$smarty
->
assign
(
'artefactdescription'
,
$postcontent
);
$smarty
->
assign
(
'artefact'
,
$this
);
$attachments
=
$this
->
get_attached_files
();
if
(
$attachments
)
{
$this
->
add_to_render_path
(
$options
);
require_once
(
'artefact.php'
);
foreach
(
$attachments
as
&
$attachment
)
{
$f
=
artefact_instance_from_id
(
$attachment
->
id
);
$rf
=
$f
->
render
(
FORMAT_ARTEFACT_LISTSELF
,
$options
);
$attachment
->
content
=
$rf
[
'html'
];
}
$smarty
->
assign
(
'attachments'
,
$attachments
);
}
$smarty
->
assign
(
'postedbyon'
,
get_string
(
'postedbyon'
,
'artefact.blog'
,
display_name
(
$this
->
owner
),
format_date
(
$this
->
ctime
)));
return
array
(
'html'
=>
$smarty
->
fetch
(
'artefact:blog:render/blogpost_renderfull.tpl'
),
'javascript'
=>
null
);
}
public
function
attachment_id_list
()
{
if
(
!
$list
=
get_column
(
'artefact_blog_blogpost_file'
,
'file'
,
'blogpost'
,
$this
->
get
(
'id'
)))
{
$list
=
array
();
...
...
@@ -613,28 +476,9 @@ class ArtefactTypeBlogPost extends ArtefactType {
}
protected
function
render_metadata
(
$options
=
array
())
{
$smarty
=
smarty
();
$smarty
->
assign
(
'PROPERTIES'
,
$this
->
get_metadata
(
$options
));
return
array
(
'html'
=>
$smarty
->
fetch
(
'artefact:blog:render/blog_rendermetadata.tpl'
),
'javascript'
=>
null
);
}
public
function
get_icon
()
{
}
public
static
function
get_render_list
()
{
return
array_values
(
array_unique
(
array_merge
(
array
(
FORMAT_ARTEFACT_LISTSELF
,
FORMAT_ARTEFACT_RENDERFULL
),
parent
::
get_render_list
()
)));
}
public
static
function
is_singular
()
{
return
false
;
}
...
...
@@ -691,45 +535,6 @@ class ArtefactTypeBlogPost extends ArtefactType {
}
/**
* This function returns a list of rendered blog posts.
*
* @param integer
* @param integer
* @param integer
* @param integer
*/
public
static
function
render_posts
(
$format
,
$options
,
$id
,
$limit
=
self
::
pagination
,
$offset
=
0
)
{
(
$postids
=
get_records_sql_array
(
"
SELECT a.id
FROM
{
artefact
}
a
LEFT OUTER JOIN
{
artefact_blog_blogpost
}
bp
ON a.id = bp.blogpost
WHERE a.parent = ?
AND bp.published = 1
ORDER BY a.ctime DESC
LIMIT ? OFFSET ?;"
,
array
(
$id
,
$limit
,
$offset
)))
||
(
$postids
=
array
());
$posts
=
array
();
foreach
(
$postids
as
$postid
)
{
$blogpost
=
new
ArtefactTypeBlogPost
(
$postid
->
id
);
$posts
[]
=
array
(
'id'
=>
$postid
->
id
,
'content'
=>
$blogpost
->
render
(
$format
,
(
array
)
$options
)
);
}
$count
=
(
int
)
get_field_sql
(
"
SELECT COUNT(*)
FROM
{
artefact
}
a
LEFT OUTER JOIN
{
artefact_blog_blogpost
}
bp
ON a.id = bp.blogpost
WHERE a.parent = ?
AND bp.published = 1"
,
array
(
$id
));
return
array
(
$count
,
$posts
);
}
/**
* This function creates a new blog post.
*
...
...
htdocs/artefact/file/lib.php
View file @
22f2e49c
...
...
@@ -325,10 +325,6 @@ abstract class ArtefactTypeFileBase extends ArtefactType {
$this
->
dirty
=
false
;
}
public
static
function
get_render_list
()
{
return
array
(
FORMAT_ARTEFACT_LISTSELF
,
FORMAT_ARTEFACT_RENDERMETADATA
);
}
public
static
function
is_singular
()
{
return
false
;
}
...
...
@@ -414,22 +410,6 @@ abstract class ArtefactTypeFileBase extends ArtefactType {
usort
(
$filedata
,
array
(
"ArtefactTypeFileBase"
,
"my_files_cmp"
));
return
$filedata
;
}
protected
function
get_metadata
(
$options
=
array
())
{
$data
=
parent
::
get_metadata
(
$options
);
$data
[
'description'
]
=
array
(
'name'
=>
get_string
(
'description'
),
'value'
=>
$this
->
description
);
$data
[
'type'
][
'value'
]
=
get_string
(
$this
->
get
(
'artefacttype'
),
'artefact.file'
);
return
$data
;
}
protected
function
render_metadata
(
$options
)
{
$smarty
=
smarty
();
$smarty
->
assign
(
'PROPERTIES'
,
$this
->
get_metadata
(
$options
));
return
array
(
'html'
=>
$smarty
->
fetch
(
'artefact:file:file_render_metadata.tpl'
),
'javascript'
=>
null
);
}
}
class
ArtefactTypeFile
extends
ArtefactTypeFileBase
{
...
...
@@ -699,10 +679,6 @@ class ArtefactTypeFile extends ArtefactTypeFileBase {
return
$data
;
}
public
static
function
get_render_list
()
{
return
array
(
FORMAT_ARTEFACT_LISTSELF
,
FORMAT_ARTEFACT_RENDERMETADATA
);
}
public
static
function
get_links
(
$id
)
{
$wwwroot
=
get_config
(
'wwwroot'
);
...
...
@@ -730,49 +706,6 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
return
get_records_array
(
'artefact'
,
'parent'
,
$this
->
get
(
'id'
));
}
public
function
render_full
(
$options
)
{
$smarty
=
smarty
();
$smarty
->
assign
(
'artefact'
,
$this
);
if
(
$options
==
null
)
{
$options
=
array
();
}
$smarty
->
assign
(
'options'
,
array_merge
(
array
(
'date'
=>
true
,
'icon'
=>
true
),
$options
));
if
(
$childrecords
=
$this
->
folder_contents
())
{
$this
->
add_to_render_path
(
$options
);
usort
(
$childrecords
,
array
(
"ArtefactTypeFileBase"
,
"my_files_cmp"
));
$children
=
array
();
require_once
(
'artefact.php'
);
foreach
(
$childrecords
as
&
$child
)
{
$c
=
artefact_instance_from_id
(
$child
->
id
);
$rc
=
$c
->
render
(
FORMAT_ARTEFACT_LISTSELF
,
$options
);
$child
->
title
=
$rc
[
'html'
];
$child
->
date
=
format_date
(
strtotime
(
$child
->
mtime
),
'strfdaymonthyearshort'
);
$child
->
iconsrc
=
theme_get_url
(
'images/'
.
$child
->
artefacttype
.
'.gif'
);
}
$smarty
->
assign
(
'children'
,
$childrecords
);
}
return
array
(
'html'
=>
$smarty
->
fetch
(
'artefact:file:folder_renderfull.tpl'
),
'javascript'
=>
null
);
}
public
function
listchildren
(
$options
)
{
$smarty
=
smarty
();
if
(
$childrecords
=
$this
->
folder_contents
())
{
$this
->
add_to_render_path
(
$options
);
usort
(
$childrecords
,
array
(
"ArtefactTypeFileBase"
,
"my_files_cmp"
));
$children
=
array
();
require_once
(
'artefact.php'
);
foreach
(
$childrecords
as
$child
)
{
$c
=
artefact_instance_from_id
(
$child
->
id
);
$rc
=
$c
->
render
(
FORMAT_ARTEFACT_LISTSELF
,
$options
);
$children
[]
=
$rc
[
'html'
];
}
$smarty
->
assign
(
'children'
,
$children
);
}
return
array
(
'html'
=>
$smarty
->
fetch
(
'artefact:file:folder_listchildren.tpl'
),
'javascript'
=>
null
);
}
public
function
describe_size
()
{
return
$this
->
count_children
()
.
' '
.
get_string
(
'files'
,
'artefact.file'
);
}
...
...
@@ -785,11 +718,6 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
return
'file'
;
}
public
static
function
get_render_list
()
{
return
array
(
FORMAT_ARTEFACT_LISTSELF
,
FORMAT_ARTEFACT_LISTCHILDREN
,
FORMAT_ARTEFACT_RENDERFULL
,
FORMAT_ARTEFACT_RENDERMETADATA
);
}
public
static
function
admin_public_folder_id
()
{
$name
=
get_string
(
'adminpublicdirname'
,
'admin'
);
$folderid
=
get_field_sql
(
'
...
...
@@ -920,46 +848,6 @@ class ArtefactTypeImage extends ArtefactTypeFile {
return
'file'
;
}
public
function
render_full
(
$options
)
{
$smarty
=
smarty
();
$src
=
get_config
(
'wwwroot'
)
.
'artefact/file/download.php?file='
.
$this
->
id
;
if
(
isset
(
$options
[
'viewid'
]))
{
$src
.
=
'&view='
.
$options
[
'viewid'
];
}
$smarty
->
assign
(
'src'
,
$src
);
$smarty
->
assign
(
'title'
,
$this
->
title
);
$smarty
->
assign
(
'description'
,
$this
->
description
);
if
(
isset
(
$options
[
'width'
]))
{
$width
=
$options
[
'width'
];
}
else
{
$width
=
$this
->
get
(
'width'
);
}
$smarty
->
assign
(
'width'
,
$width
?
$width
:
''
);
if
(
isset
(
$options
[
'height'
]))
{
$height
=
$options
[
'height'
];
}
else
{
$height
=
$this
->
get
(
'height'
);
}
if
((
isset
(
$options
[
'width'
])
||
isset
(
$options
[
'height'
]))
&&
isset
(
$options
[
'viewid'
]))
{
$url
=
get_config
(
'wwwroot'
)
.
'view/view.php?artefact='
.
$this
->
get
(
'id'
)
.
'&view='
.
$options
[
'viewid'
];
if
(
isset
(
$options
[
'path'
]))
{
$url
.
=
'&path='
.
$options
[
'path'
];
}
$smarty
->
assign
(
'url'
,
$url
);
}
$smarty
->
assign
(
'height'
,
$height
?
$height
:
''
);
return
array
(
'html'
=>
$smarty
->
fetch
(
'artefact:file:image_renderfull.tpl'
),
'javascript'
=>
null
);
}
public
static
function
get_render_list
()
{
return
array
(
FORMAT_ARTEFACT_LISTSELF
,
FORMAT_ARTEFACT_RENDERFULL
,
FORMAT_ARTEFACT_RENDERMETADATA
);
}
public
static
function
is_image_mime_type
(
$type
)
{
require_once
(
'file.php'
);
return
is_image_mime_type
(
$type
);
...
...
htdocs/artefact/internal/lib.php
View file @
22f2e49c
...
...
@@ -153,19 +153,10 @@ class ArtefactTypeProfile extends ArtefactType {
return
parent
::
set
(
$field
,
$value
);
}
public
function
render_full
(
$options
)
{
return
array
(
'html'
=>
$this
->
title
,
'javascript'
=>
null
);
}
public
function
get_icon
()
{
}
public
static
function
get_render_list
()
{
return
array
(
FORMAT_ARTEFACT_LISTSELF
,
FORMAT_ARTEFACT_RENDERFULL
,
FORMAT_ARTEFACT_RENDERMETADATA
);
}
public
static
function
is_singular
()
{
return
true
;
}
...
...
@@ -350,40 +341,6 @@ class ArtefactTypeProfileField extends ArtefactTypeProfile {
public
static
function
collapse_config
()
{
return
'profile'
;
}
/**
* This method is optional, and specifies how child data should be formatted
* for the artefact tree.
*
* It should return a StdClass object, with the following fields set:
*
* - id
* - title
* - text
* - container
* - parent
*
* @param object $data The data to reformat. Contains some fields from the
* <kbd>artefact</kbd> table, namely title, artefacttype
* and container
* @return object The reformatted data
*/
public
static
function
format_child_data
(
$data
,
$pluginname
)
{
$res
=
new
StdClass
;
$res
->
id
=
$data
->
id
;
$res
->
title
=
$data
->
title
;
$res
->
isartefact
=
true
;
if
(
$data
->
artefacttype
==
'email'
)
{
$res
->
text
=
get_string
(
'email'
)
.
' - '
.
$data
->
title
;
}
else
{
$res
->
text
=
get_string
(
$data
->
artefacttype
,
"artefact.
$pluginname
"
);
}
$res
->
container
=
0
;
$res
->
parent
=
null
;
return
$res
;
}
}
class
ArtefactTypeCachedProfileField
extends
ArtefactTypeProfileField
{
...
...
@@ -454,16 +411,8 @@ class ArtefactTypeEmail extends ArtefactTypeProfileField {
class
ArtefactTypeStudentid
extends
ArtefactTypeProfileField
{}
class
ArtefactTypeIntroduction
extends
ArtefactTypeProfileField
{}
class
ArtefactTypeWebAddress
extends
ArtefactTypeProfileField
{
public
function
listself
(
$options
)
{
if
(
$options
[
'link'
]
==
true
)
{
$html
=
make_link
(
$this
->
title
);
}
else
{
$html
=
$this
->
title
;
}
return
array
(
'html'
=>
$html
,
'javascript'
=>
null
);
}
public
function
render_full
(
$options
)
{
public
function
render_self
(
$options
)
{
if
(
$options
[
'link'
]
==
true
)
{
$html
=
make_link
(
$this
->
title
);
}
...
...
@@ -480,11 +429,10 @@ class ArtefactTypeAddress extends ArtefactTypeProfileField {}
class
ArtefactTypeTown
extends
ArtefactTypeProfileField
{}
class
ArtefactTypeCity
extends
ArtefactTypeProfileField
{}
class
ArtefactTypeCountry
extends
ArtefactTypeProfileField
{
public
function
listself
(
$options
)
{
return
array
(
'html'
=>
get_string
(
"country.
{
$this
->
title
}
"
),
'javascript'
=>
null
);
}
public
function
render_full
(
$options
)
{
return
array
(
'html'
=>
get_string
(
"country.
{
$this
->
title
}
"
),
'javascript'
=>
null
);
public
function
render_self
(
$options
)
{
$countries
=
getoptions_country
();
return
array
(
'html'
=>
$countries
[
$this
->
title
],
'javascript'
=>
null
);
}
}
class
ArtefactTypeHomenumber
extends
ArtefactTypeProfileField
{}
...
...
@@ -505,7 +453,7 @@ class ArtefactTypeProfileIcon extends ArtefactTypeProfileField {
return
true
;
}
public
function
render_
full
(
$options
)
{
public
function
render_
self
(
$options
)
{
$html
=
'<img src="'
.
get_config
(
'wwwroot'
)
.
'thumb.php?type=profileiconbyid&id='
.
$this
->
id
.
'"'
.
'alt="'
.
hsc
(
$this
->
title
)
.
'"'
;
if
(
isset
(
$options
[
'width'
]))
{
...
...
htdocs/artefact/resume/lib.php
View file @
22f2e49c
...
...
@@ -165,7 +165,7 @@ class ArtefactTypeContactinformation extends ArtefactTypeResume {
foreach
(
$fields
as
$f
)
{
try
{
$$f
=
artefact_instance_from_type
(
$f
);
$rendered
=
$$f
->
render
(
FORMAT_ARTEFACT_RENDERFULL
,
array
()
);
$rendered
=
$$f
->
render
_self
(
);
$smarty
->
assign
(
$f
,
$rendered
[
'html'
]);
}
catch
(
Exception
$e
)
{
}
...
...
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