123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- <?php
- if (!defined('STATUSNET')) {
-
-
- exit(1);
- }
- class BookmarkforurlAction extends Action
- {
- protected $url = null;
- protected $oembed = null;
- protected $thumbnail = null;
- protected $title = null;
-
- function prepare($args)
- {
- parent::prepare($args);
- if (!$this->isPost()) {
- throw new ClientException(_('POST only'), 405);
- }
- $this->checkSessionToken();
- $this->url = $this->trimmed('url');
- if (empty($this->url)) {
- throw new ClientException(_('URL is required.'), 400);
- }
- if (!common_valid_http_url($this->url)) {
- throw new ClientException(_('Invalid URL.'), 400);
- }
- try {
-
- $f = File::processNew($this->url);
- } catch (ServerException $e) {
- $f = null;
- }
-
- if ($f instanceof File) {
-
- $this->oembed = File_oembed::getKV('file_id', $f->id);
- if ($this->oembed instanceof File_oembed) {
- $this->title = $this->oembed->title;
- }
- $this->thumbnail = File_thumbnail::getKV('file_id', $f->id);
- }
- return true;
- }
-
- function handle($args=null)
- {
- $this->startHTML('text/xml;charset=utf-8');
- $this->elementStart('head');
- $this->element('title', null, _('Bookmark form'));
- $this->elementEnd('head');
- $this->elementStart('body');
- $bf = new BookmarkForm($this, $this->title, $this->url, null, null, $this->thumbnail);
- $bf->show();
- $this->elementEnd('body');
- $this->endHTML();
- }
-
- function isReadOnly($args)
- {
- return false;
- }
- }
|