- * @return void
- */
- function showEnd()
- {
- $this->out->elementEnd('li');
- }
-}
-
-class Attachment extends AttachmentListItem
-{
- function showLink() {
- $this->out->elementStart('div', array('id' => 'attachment_view',
- 'class' => 'hentry'));
- $this->out->elementStart('div', 'entry-title');
- $this->out->element('a', $this->linkAttr(), $this->linkTitle());
- $this->out->elementEnd('div');
-
- $this->out->elementStart('div', 'entry-content');
- $this->showRepresentation();
- $this->out->elementEnd('div');
-
- if (!empty($this->oembed->author_name) || !empty($this->oembed->provider)) {
- $this->out->elementStart('div', array('id' => 'oembed_info',
- 'class' => 'entry-content'));
- if (!empty($this->oembed->author_name)) {
- $this->out->elementStart('dl', 'vcard author');
- // TRANS: DT element label in attachment list item.
- $this->out->element('dt', null, _('Author'));
- $this->out->elementStart('dd', 'fn');
- if (empty($this->oembed->author_url)) {
- $this->out->text($this->oembed->author_name);
- } else {
- $this->out->element('a', array('href' => $this->oembed->author_url,
- 'class' => 'url'), $this->oembed->author_name);
- }
- $this->out->elementEnd('dd');
- $this->out->elementEnd('dl');
- }
- if (!empty($this->oembed->provider)) {
- $this->out->elementStart('dl', 'vcard');
- // TRANS: DT element label in attachment list item.
- $this->out->element('dt', null, _('Provider'));
- $this->out->elementStart('dd', 'fn');
- if (empty($this->oembed->provider_url)) {
- $this->out->text($this->oembed->provider);
- } else {
- $this->out->element('a', array('href' => $this->oembed->provider_url,
- 'class' => 'url'), $this->oembed->provider);
- }
- $this->out->elementEnd('dd');
- $this->out->elementEnd('dl');
- }
- $this->out->elementEnd('div');
- }
- $this->out->elementEnd('div');
- }
-
- function show() {
- $this->showNoticeAttachment();
- }
-
- function linkAttr() {
- return array('rel' => 'external', 'href' => $this->attachment->url);
- }
-
- function linkTitle() {
- return $this->attachment->url;
- }
-
- function showRepresentation() {
- if (empty($this->oembed->type)) {
- if (empty($this->attachment->mimetype)) {
- $this->showFallback();
- } else {
- switch ($this->attachment->mimetype) {
- case 'image/gif':
- case 'image/png':
- case 'image/jpg':
- 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;
-
- case 'text/html':
- if ($this->attachment->filename) {
- // Locally-uploaded HTML. Scrub and display inline.
- $this->showHtmlFile($this->attachment);
- break;
- }
- // Fall through to default.
-
- default:
- $this->showFallback();
- }
- }
- } else {
- switch ($this->oembed->type) {
- case 'rich':
- case 'video':
- case 'link':
- if (!empty($this->oembed->html)) {
- require_once INSTALLDIR.'/extlib/htmLawed/htmLawed.php';
- $config = array(
- 'safe'=>1,
- 'elements'=>'*+object+embed');
- $this->out->raw(htmLawed($this->oembed->html,$config));
- //$this->out->raw($this->oembed->html);
- }
- break;
-
- case 'photo':
- $this->out->element('img', array('src' => $this->oembed->url, 'width' => $this->oembed->width, 'height' => $this->oembed->height, 'alt' => 'alt'));
- break;
-
- default:
- $this->showFallback();
- }
- }
- }
-
- protected function showHtmlFile(File $attachment)
- {
- $body = $this->scrubHtmlFile($attachment);
- if ($body) {
- $this->out->raw($body);
- }
- }
-
- /**
- * @return mixed false on failure, HTML fragment string on success