Improve file upload and attachment interface.
This commit is contained in:
parent
fe38827a76
commit
27af3c67a2
@ -277,6 +277,18 @@ class Notice extends Memcached_DataObject
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getUploadedAttachment() {
|
||||||
|
$post = clone $this;
|
||||||
|
$query = 'select file.url as uploaded from file join file_to_post on file.id = file_id where post_id=' . $post->escape($post->id) . ' and url like "%/notice/%/file"';
|
||||||
|
$post->query($query);
|
||||||
|
$post->fetch();
|
||||||
|
$ret = $post->uploaded;
|
||||||
|
// var_dump($post);
|
||||||
|
$post->free();
|
||||||
|
// die();
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
function hasAttachments() {
|
function hasAttachments() {
|
||||||
$post = clone $this;
|
$post = clone $this;
|
||||||
$query = "select count(file_id) as n_attachments from file join file_to_post on (file_id = file.id) join notice on (post_id = notice.id) where post_id = " . $post->escape($post->id);
|
$query = "select count(file_id) as n_attachments from file join file_to_post on (file_id = file.id) join notice on (post_id = notice.id) where post_id = " . $post->escape($post->id);
|
||||||
|
@ -188,6 +188,7 @@ $config =
|
|||||||
'application/vnd.oasis.opendocument.formula-template',
|
'application/vnd.oasis.opendocument.formula-template',
|
||||||
'application/vnd.oasis.opendocument.text-master',
|
'application/vnd.oasis.opendocument.text-master',
|
||||||
'application/vnd.oasis.opendocument.text-web',
|
'application/vnd.oasis.opendocument.text-web',
|
||||||
|
'application/x-zip',
|
||||||
'application/zip',
|
'application/zip',
|
||||||
'text/plain',
|
'text/plain',
|
||||||
'video/mpeg',
|
'video/mpeg',
|
||||||
|
@ -364,6 +364,10 @@ class NoticeListItem extends Widget
|
|||||||
// versions (>> 0.4.x)
|
// versions (>> 0.4.x)
|
||||||
$this->out->raw(common_render_content($this->notice->content, $this->notice));
|
$this->out->raw(common_render_content($this->notice->content, $this->notice));
|
||||||
}
|
}
|
||||||
|
$uploaded = $this->notice->getUploadedAttachment();
|
||||||
|
if ($uploaded) {
|
||||||
|
$this->out->element('a', array('href' => $uploaded, 'class' => 'attachment'), $uploaded);
|
||||||
|
}
|
||||||
$this->out->elementEnd('p');
|
$this->out->elementEnd('p');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -395,10 +399,6 @@ class NoticeListItem extends Widget
|
|||||||
'title' => $dt),
|
'title' => $dt),
|
||||||
common_date_string($this->notice->created));
|
common_date_string($this->notice->created));
|
||||||
|
|
||||||
$f2p = File_to_post::staticGet('post_id', $this->notice->id);
|
|
||||||
if (!empty($f2p)) {
|
|
||||||
$this->out->text(_(' (with attachments) '));
|
|
||||||
}
|
|
||||||
$this->out->elementEnd('a');
|
$this->out->elementEnd('a');
|
||||||
$this->out->elementEnd('dd');
|
$this->out->elementEnd('dd');
|
||||||
$this->out->elementEnd('dl');
|
$this->out->elementEnd('dl');
|
||||||
|
Loading…
Reference in New Issue
Block a user