summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/attachmentlist.php22
-rw-r--r--lib/common.php57
-rw-r--r--lib/form.php16
-rw-r--r--lib/noticeform.php8
-rw-r--r--lib/noticelist.php11
-rw-r--r--lib/router.php4
-rw-r--r--lib/util.php5
7 files changed, 103 insertions, 20 deletions
diff --git a/lib/attachmentlist.php b/lib/attachmentlist.php
index 559962acc..45e4fa319 100644
--- a/lib/attachmentlist.php
+++ b/lib/attachmentlist.php
@@ -80,13 +80,14 @@ 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' =>'attachments'));
$this->out->element('dt', null, _('Attachments'));
$this->out->elementStart('dd');
$this->out->elementStart('ol', array('class' => 'attachments'));
- $atts = new File;
- $att = $atts->getAttachments($this->notice->id);
foreach ($att as $n=>$attachment) {
$item = $this->newListItem($attachment);
$item->show();
@@ -267,6 +268,23 @@ class Attachment extends AttachmentListItem
case 'image/jpeg':
$this->out->element('img', array('src' => $this->attachment->url, 'alt' => 'alt'));
break;
+
+ case 'application/ogg':
+ case 'audio/x-speex':
+ case 'video/mpeg':
+ case 'audio/mpeg':
+ case 'video/mp4':
+ case 'video/quicktime':
+ $arr = array('type' => $this->attachment->mimetype,
+ 'data' => $this->attachment->url,
+ 'width' => 320,
+ 'height' => 240
+ );
+ $this->out->elementStart('object', $arr);
+ $this->out->element('param', array('name' => 'src', 'value' => $this->attachment->url));
+ $this->out->element('param', array('name' => 'autoStart', 'value' => 1));
+ $this->out->elementEnd('object');
+ break;
}
}
} else {
diff --git a/lib/common.php b/lib/common.php
index 4a98741e8..ceb50337c 100644
--- a/lib/common.php
+++ b/lib/common.php
@@ -163,6 +163,41 @@ $config =
array('run' => 'web',
'frequency' => 10000,
'reporturl' => 'http://laconi.ca/stats/report'),
+ 'attachments' =>
+ array('supported' => array('image/png',
+ 'image/jpeg',
+ 'image/gif',
+ 'image/svg+xml',
+ 'audio/mpeg',
+ 'audio/x-speex',
+ 'application/ogg',
+ 'application/pdf',
+ 'application/vnd.oasis.opendocument.text',
+ 'application/vnd.oasis.opendocument.text-template',
+ 'application/vnd.oasis.opendocument.graphics',
+ 'application/vnd.oasis.opendocument.graphics-template',
+ 'application/vnd.oasis.opendocument.presentation',
+ 'application/vnd.oasis.opendocument.presentation-template',
+ 'application/vnd.oasis.opendocument.spreadsheet',
+ 'application/vnd.oasis.opendocument.spreadsheet-template',
+ 'application/vnd.oasis.opendocument.chart',
+ 'application/vnd.oasis.opendocument.chart-template',
+ 'application/vnd.oasis.opendocument.image',
+ 'application/vnd.oasis.opendocument.image-template',
+ 'application/vnd.oasis.opendocument.formula',
+ 'application/vnd.oasis.opendocument.formula-template',
+ 'application/vnd.oasis.opendocument.text-master',
+ 'application/vnd.oasis.opendocument.text-web',
+ 'application/zip',
+ 'text/plain',
+ 'video/mpeg',
+ 'video/mp4',
+ 'video/quicktime',
+ 'video/mpeg'),
+ 'file_quota' => 5000000,
+ 'user_quota' => 50000000,
+ 'monthly_quota' => 15000000,
+ ),
);
$config['db'] = &PEAR::getStaticProperty('DB_DataObject','options');
@@ -224,19 +259,19 @@ if ($_db_name != 'laconica' && !array_key_exists('ini_'.$_db_name, $config['db']
// XXX: how many of these could be auto-loaded on use?
-require_once('Validate.php');
-require_once('markdown.php');
+require_once 'Validate.php';
+require_once 'markdown.php';
-require_once(INSTALLDIR.'/lib/util.php');
-require_once(INSTALLDIR.'/lib/action.php');
-require_once(INSTALLDIR.'/lib/theme.php');
-require_once(INSTALLDIR.'/lib/mail.php');
-require_once(INSTALLDIR.'/lib/subs.php');
-require_once(INSTALLDIR.'/lib/Shorturl_api.php');
-require_once(INSTALLDIR.'/lib/twitter.php');
+require_once INSTALLDIR.'/lib/util.php';
+require_once INSTALLDIR.'/lib/action.php';
+require_once INSTALLDIR.'/lib/theme.php';
+require_once INSTALLDIR.'/lib/mail.php';
+require_once INSTALLDIR.'/lib/subs.php';
+require_once INSTALLDIR.'/lib/Shorturl_api.php';
+require_once INSTALLDIR.'/lib/twitter.php';
-require_once(INSTALLDIR.'/lib/clientexception.php');
-require_once(INSTALLDIR.'/lib/serverexception.php');
+require_once INSTALLDIR.'/lib/clientexception.php';
+require_once INSTALLDIR.'/lib/serverexception.php';
// XXX: other formats here
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..7c88bd7b1 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';
}
/**
@@ -142,17 +143,20 @@ class NoticeForm extends Form
'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->element('label', array('for' => 'notice_data-attach'), _('Upload: '));
+ $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');
}
$this->out->hidden('notice_in-reply-to', $this->action, 'inreplyto');
+ $this->out->hidden('MAX_FILE_SIZE', common_config('attachments', 'file_quota'));
}
/**
diff --git a/lib/noticelist.php b/lib/noticelist.php
index 0e80a9778..5513e317e 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..456d1793e 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -164,6 +164,10 @@ 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]+'));
diff --git a/lib/util.php b/lib/util.php
index d56f44f7b..ab1272309 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -499,6 +499,11 @@ function common_linkify($url) {
// if this URL is an attachment, then we set class='attachment' and id='attahcment-ID'
// where ID is the id of the attachment for the given URL.
+//
+// we need a better test telling what can be shown as an attachment
+// we're currently picking up oembeds only.
+// I think the best option is another file_view table in the db
+// and associated dbobject.
$query = "select file_oembed.file_id as file_id from file join file_oembed on file.id = file_oembed.file_id where file.url='$longurl'";
$file = new File;
$file->query($query);