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
975bafa8
Commit
975bafa8
authored
Dec 19, 2006
by
Richard Mansfield
Browse files
Display list of files attached to blog posts
parent
cec5ab99
Changes
6
Hide whitespace changes
Inline
Side-by-side
htdocs/artefact/blog/attachedfiles.json.php
0 → 100644
View file @
975bafa8
<?php
/**
* This program is part of Mahara
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* @package mahara
* @subpackage artefact-blog
* @author Richard Mansfield <richard.mansfield@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define
(
'INTERNAL'
,
1
);
require
(
dirname
(
dirname
(
dirname
(
__FILE__
)))
.
'/init.php'
);
safe_require
(
'artefact'
,
'blog'
);
$limit
=
param_integer
(
'limit'
,
null
);
$offset
=
param_integer
(
'offset'
,
0
);
$id
=
param_integer
(
'blogpost'
,
0
);
if
(
$id
)
{
$blogpost
=
new
ArtefactTypeBlogPost
(
$id
);
if
(
!
$filelist
=
$blogpost
->
get_attached_files
())
{
$filelist
=
array
();
}
}
else
{
$filelist
=
array
();
}
$result
=
array
(
'count'
=>
count
(
$filelist
),
'limit'
=>
$limit
,
'offset'
=>
$offset
,
'data'
=>
$filelist
,
'error'
=>
false
,
'message'
=>
get_string
(
'attachedfilelistloaded'
),
);
json_headers
();
print
json_encode
(
$result
);
htdocs/artefact/blog/editpost.php
View file @
975bafa8
...
...
@@ -34,8 +34,8 @@ safe_require('artefact', 'blog');
// For a new post, the 'blog' parameter will be set to the blog's artefact id.
// For an existing post, the 'post' parameter will be set to the blogpost's artefact id.
$post
=
param_integer
(
'post'
,
0
);
if
(
!
$post
)
{
$
blog
post
=
param_integer
(
'
blog
post'
,
0
);
if
(
!
$
blog
post
)
{
// This is a new post; get a create id so we can attach files to it.
$createid
=
$SESSION
->
get
(
'createid'
);
if
(
empty
(
$createid
))
{
...
...
@@ -43,24 +43,57 @@ if (!$post) {
}
$SESSION
->
set
(
'createid'
,
$createid
+
1
);
$blog
=
param_integer
(
'blog'
);
$post
=
''
;
$
blog
post
=
0
;
$title
=
''
;
$description
=
''
;
$checked
=
''
;
$pagetitle
=
'newblogpost'
;
}
else
{
$blogpost
=
new
ArtefactTypeBlogPost
(
$post
);
if
(
$blogpost
->
get
(
'owner'
)
!=
$USER
->
get
(
'id'
))
{
$blogpost
obj
=
new
ArtefactTypeBlogPost
(
$
blog
post
);
if
(
$blogpost
obj
->
get
(
'owner'
)
!=
$USER
->
get
(
'id'
))
{
return
;
}
$blog
=
$blogpost
->
get
(
'parent'
);
$title
=
$blogpost
->
get
(
'title'
);
$description
=
$blogpost
->
get
(
'description'
);
$checked
=
!
$blogpost
->
get
(
'published'
);
$blog
=
$blogpost
obj
->
get
(
'parent'
);
$title
=
$blogpost
obj
->
get
(
'title'
);
$description
=
$blogpost
obj
->
get
(
'description'
);
$checked
=
!
$blogpost
obj
->
get
(
'published'
);
$pagetitle
=
'editblogpost'
;
}
$getstring
=
quotestrings
(
array
(
'mahara'
=>
array
(
),
'artefact.blog'
=>
array
(
'nofilesattachedtothispost'
,
)));
$attachedhtml
=
'<h3>'
.
get_string
(
'attachedfiles'
,
'artefact.blog'
)
.
"</h3>
\n
"
;
$attachedhtml
.
=
"<table id='attachedfiles'><tbody><tr><td></td></tr></tbody></table>
\n
"
;
//$blogpostjs = $blogpost ? $blogpost : 'null';
$javascript
=
<<<
EOF
var
attached
=
new
TableRenderer
(
'attachedfiles'
,
'attachedfiles.json.php'
,
[
'title'
,
'description'
,
function
()
{
return
TD
(
null
);
}
]
);
attached
.
emptycontent
=
{
$getstring
[
'nofilesattachedtothispost'
]};
attached
.
paginate
=
false
;
attached
.
blogpost
=
{
$blogpost
};
attached
.
statevars
.
push
(
'blogpost'
);
attached
.
rowfunction
=
function
(
r
)
{
return
TR
({
'id'
:
'attached_old_'
+
r
.
id
});
};
attached
.
updateOnLoad
();
EOF
;
$form
=
pieform
(
array
(
'name'
=>
'editpost'
,
'method'
=>
'post'
,
...
...
@@ -72,7 +105,7 @@ $form = pieform(array(
),
'id'
=>
array
(
'type'
=>
'hidden'
,
'value'
=>
$post
,
'value'
=>
$
blog
post
,
),
'title'
=>
array
(
'type'
=>
'text'
,
...
...
@@ -100,6 +133,10 @@ $form = pieform(array(
'description'
=>
get_string
(
'thisisdraftdesc'
,
'artefact.blog'
),
'checked'
=>
$checked
),
'attachedfiles'
=>
array
(
'type'
=>
'html'
,
'value'
=>
$attachedhtml
,
),
'submit'
=>
array
(
'type'
=>
'submitcancel'
,
'value'
=>
array
(
...
...
@@ -110,15 +147,11 @@ $form = pieform(array(
)
));
$javascript
=
<<<
EOF
EOF
;
$smarty
=
smarty
();
$smarty
=
smarty
(
array
(
'tablerenderer'
));
$smarty
->
assign
(
'INLINEJAVASCRIPT'
,
$javascript
);
$smarty
->
assign
(
'pagetitle'
,
$pagetitle
);
$smarty
->
assign_by_ref
(
'editpostform'
,
$form
);
$smarty
->
display
(
'artefact:blog:editpost.tpl'
);
exit
;
/**
* This function gets called to create a new blog post, and publish it
...
...
htdocs/artefact/blog/lang/en.utf8/artefact.blog.php
View file @
975bafa8
...
...
@@ -32,6 +32,9 @@ $string['description'] = 'description';
$string
[
'addblog'
]
=
'Add Blog'
;
$string
[
'newblog'
]
=
'New Blog'
;
$string
[
'attachedfiles'
]
=
'Attached files'
;
$string
[
'nofilesattachedtothispost'
]
=
'No attached files'
;
$string
[
'blogtitle'
]
=
'Title'
;
$string
[
'blogtitledesc'
]
=
'e.g., ‘Jill’s Travel Blog’.'
;
$string
[
'blogdesc'
]
=
'Description'
;
...
...
htdocs/artefact/blog/lib.php
View file @
975bafa8
...
...
@@ -75,10 +75,10 @@ class PluginArtefactBlog extends PluginArtefact {
*/
public
static
function
clean_post_files
()
{
safe_require
(
'artefact'
,
'file'
);
(
$files
=
get_records_sql_array
(
"
SELECT file
FROM artefact_blog_blogpost_file_pending
FROM
"
.
get_config
(
'dbprefix'
)
.
"
artefact_blog_blogpost_file_pending
WHERE when + ?::INTERVAL < CURRENT_TIMESTAMP"
,
array
(
self
::
maxpending
)))
||
(
$files
=
array
());
...
...
@@ -572,6 +572,21 @@ class ArtefactTypeBlogPost extends ArtefactType {
}
return
true
;
}
/**
* This function returns a list of files attached to a post to use
* when displaying or editing a blog post
*
* @return array
*/
public
function
get_attached_files
()
{
$prefix
=
get_config
(
'dbprefix'
);
return
get_records_sql_array
(
'SELECT a.id, a.artefacttype, a.title, a.description
FROM '
.
$prefix
.
'artefact_blog_blogpost_file f
INNER JOIN '
.
$prefix
.
'artefact a ON a.id = f.file
WHERE f.blogpost = '
.
$this
->
id
,
''
);
}
}
?>
htdocs/artefact/blog/theme/default/editpost.tpl
View file @
975bafa8
...
...
@@ -11,14 +11,16 @@
</div>
<div
id=
"column-left"
>
<div
class=
"content"
>
<div
class=
"box-cnrs"
><span
class=
"cnr-tl"
><span
class=
"cnr-tr"
><span
class=
"cnr-bl"
><span
class=
"cnr-br"
>
<div
class=
"maincontent"
>
<h2>
{
str
section
=
"artefact.blog"
tag
=
$pagetitle
}
</h2>
{
$editpostform
}
</div>
</span></span></span></span></div>
<div
class=
"content"
>
<div
class=
"box-cnrs"
>
<span
class=
"cnr-tl"
><span
class=
"cnr-tr"
><span
class=
"cnr-bl"
><span
class=
"cnr-br"
>
<div
class=
"maincontent"
>
<h2>
{
str
section
=
"artefact.blog"
tag
=
$pagetitle
}
</h2>
{
$editpostform
}
</div>
</span></span></span></span>
</div>
</div>
</div>
{
include
file
=
"footer.tpl"
}
htdocs/artefact/blog/view/index.js.php
View file @
975bafa8
...
...
@@ -84,7 +84,7 @@ postlist.rowfunction = function(d, n, gd) {
INPUT(
{
'type' : 'hidden',
'name' : 'post',
'name' : '
blog
post',
'value' : d.id
}
),
...
...
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