summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRobin Millette <millette@controlyourself.ca>2009-05-26 21:20:04 -0400
committerRobin Millette <millette@controlyourself.ca>2009-05-26 21:20:04 -0400
commitaf700ea27703bbec5aa1078a84f9fd44c0260322 (patch)
treea227167390948f5791b8190435fbb9cfdbd0bc38 /lib
parent4edb1c6e0cfcaee256757ed20b4ff8d482158906 (diff)
Let's you upload a file with a notice and have it shown with other attachments.
Diffstat (limited to 'lib')
-rw-r--r--lib/attachmentlist.php6
-rw-r--r--lib/form.php16
-rw-r--r--lib/noticeform.php12
-rw-r--r--lib/noticelist.php11
-rw-r--r--lib/router.php6
5 files changed, 42 insertions, 9 deletions
diff --git a/lib/attachmentlist.php b/lib/attachmentlist.php
index d0478bad3..a58a50f6f 100644
--- a/lib/attachmentlist.php
+++ b/lib/attachmentlist.php
@@ -80,13 +80,15 @@ class AttachmentList extends Widget
function show()
{
+ $atts = new File;
+ $att = $atts->getAttachments($this->notice->id);
+ if (empty($att)) return 0;
+
$this->out->elementStart('dl', array('id' =>'attachment'));
$this->out->element('dt', null, _('Attachments'));
$this->out->elementStart('dd');
$this->out->elementStart('ul', array('class' => 'attachments'));
- $atts = new File;
- $att = $atts->getAttachments($this->notice->id);
foreach ($att as $n=>$attachment) {
$item = $this->newListItem($attachment);
$item->show();
diff --git a/lib/form.php b/lib/form.php
index 5317df471..f872aef0b 100644
--- a/lib/form.php
+++ b/lib/form.php
@@ -52,6 +52,8 @@ require_once INSTALLDIR.'/lib/widget.php';
class Form extends Widget
{
+ var $enctype = null;
+
/**
* Show the form
*
@@ -63,11 +65,15 @@ class Form extends Widget
function show()
{
- $this->out->elementStart('form',
- array('id' => $this->id(),
- 'class' => $this->formClass(),
- 'method' => 'post',
- 'action' => $this->action()));
+ $attributes = array('id' => $this->id(),
+ 'class' => $this->formClass(),
+ 'method' => 'post',
+ 'action' => $this->action());
+
+ if (!empty($this->enctype)) {
+ $attributes['enctype'] = $this->enctype;
+ }
+ $this->out->elementStart('form', $attributes);
$this->out->elementStart('fieldset');
$this->formLegend();
$this->sessionToken();
diff --git a/lib/noticeform.php b/lib/noticeform.php
index 606b5d028..707768cd5 100644
--- a/lib/noticeform.php
+++ b/lib/noticeform.php
@@ -89,7 +89,8 @@ class NoticeForm extends Form
} else {
$this->user = common_current_user();
}
-
+
+ $this->enctype = 'multipart/form-data';
}
/**
@@ -136,18 +137,25 @@ class NoticeForm extends Form
{
$this->out->element('label', array('for' => 'notice_data-text'),
sprintf(_('What\'s up, %s?'), $this->user->nickname));
+ $this->out->elementStart('span', array('style' => 'float: right; margin-top: 2em;'));
+// $this->out->element('a', array('href' => '#attach'), ' [ATTACH]');
+ $this->out->elementEnd('span');
// XXX: vary by defined max size
$this->out->element('textarea', array('id' => 'notice_data-text',
'cols' => 35,
'rows' => 4,
'name' => 'status_textarea'),
($this->content) ? $this->content : '');
-
$this->out->elementStart('dl', 'form_note');
$this->out->element('dt', null, _('Available characters'));
$this->out->element('dd', array('id' => 'notice_text-count'),
'140');
$this->out->elementEnd('dl');
+ $this->out->element('br', array('style' => 'clear:both'));
+// $this->out->elementStart('a', array('href' => '#'));
+ $this->out->element('label', array('for' => 'notice_data-attach'), _('Upload: '));
+// $this->out->elementEnd('a');
+ $this->out->element('input', array('id' => 'notice_data-attach', 'type' => 'file', 'name' => 'attach'));
if ($this->action) {
$this->out->hidden('notice_return-to', $this->action, 'returnto');
diff --git a/lib/noticelist.php b/lib/noticelist.php
index 50a95cfcb..420272515 100644
--- a/lib/noticelist.php
+++ b/lib/noticelist.php
@@ -206,6 +206,7 @@ class NoticeListItem extends Widget
return 'shownotice' !== $this->out->args['action'];
}
+/*
function attachmentCount($discriminant = true) {
$file_oembed = new File_oembed;
$query = "select count(*) as c from file_oembed join file_to_post on file_oembed.file_id = file_to_post.file_id where post_id=" . $this->notice->id;
@@ -213,11 +214,16 @@ class NoticeListItem extends Widget
$file_oembed->fetch();
return intval($file_oembed->c);
}
+*/
+
+ function showWithAttachment() {
+ }
function showNoticeInfo()
{
$this->out->elementStart('div', 'entry-content');
$this->showNoticeLink();
+// $this->showWithAttachment();
$this->showNoticeSource();
$this->showContext();
$this->out->elementEnd('div');
@@ -388,6 +394,11 @@ class NoticeListItem extends Widget
$this->out->element('abbr', array('class' => 'published',
'title' => $dt),
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('dd');
$this->out->elementEnd('dl');
diff --git a/lib/router.php b/lib/router.php
index fc119821b..bd482eafa 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -164,6 +164,12 @@ class Router
array('action' => 'newnotice'),
array('replyto' => '[A-Za-z0-9_-]+'));
+/*
+ $m->connect('notice/:notice/file',
+ array('action' => 'file'),
+ array('notice' => '[0-9]+'));
+*/
+
$m->connect('notice/:notice',
array('action' => 'shownotice'),
array('notice' => '[0-9]+'));