*
* @return boolean true
*/
- function prepare($args)
+ function prepare(array $args = array())
{
parent::prepare($args);
throw new ClientException(_('URL is required.'), 400);
}
- if (!Validate::uri($this->url, array('allowed_schemes' => array('http', 'https')))) {
+ if (!common_valid_http_url($this->url)) {
throw new ClientException(_('Invalid URL.'), 400);
}
- $f = File::getKV('url', $this->url);
-
- if (empty($url)) {
- $f = File::processNew($this->url);
+ try {
+ // processNew will first try to fetch a locally stored File entry
+ $f = File::processNew($this->url);
+ } catch (ServerException $e) {
+ $f = null;
}
// How about now?
- if (!empty($f)) {
+ if ($f instanceof File) {
+ // FIXME: Use some File metadata Event instead
$this->oembed = File_oembed::getKV('file_id', $f->id);
- if (!empty($this->oembed)) {
+ if ($this->oembed instanceof File_oembed) {
$this->title = $this->oembed->title;
}
$this->thumbnail = File_thumbnail::getKV('file_id', $f->id);
$bf = new BookmarkForm($this, $this->title, $this->url, null, null, $this->thumbnail);
$bf->show();
$this->elementEnd('body');
- $this->elementEnd('html');
+ $this->endHTML();
}
/**