123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- <?php
- if (!defined('STATUSNET')) {
-
-
- exit(1);
- }
- class NewbookmarkAction extends FormAction
- {
- protected $complete = null;
- protected $title = null;
- protected $url = null;
- protected $tags = null;
- protected $description = null;
- function title()
- {
-
- return _m('New bookmark');
- }
- protected function doPreparation()
- {
- $this->title = $this->trimmed('title');
- $this->url = $this->trimmed('url');
- $this->tags = preg_split('/[\s,]+/', $this->trimmed('tags'), null, PREG_SPLIT_NO_EMPTY);
- $this->description = $this->trimmed('description');
- return true;
- }
-
- function handlePost()
- {
- if (empty($this->title)) {
-
- throw new ClientException(_m('Bookmark must have a title.'));
- }
- if (empty($this->url)) {
-
- throw new ClientException(_m('Bookmark must have an URL.'));
- }
- $options = array();
- ToSelector::fillOptions($this, $options);
- $saved = Bookmark::addNew($this->scoped,
- $this->title,
- $this->url,
- $this->tags,
- $this->description,
- $options);
- }
-
- function showNotice(Notice $notice)
- {
- class_exists('NoticeList');
- $nli = new NoticeListItem($notice, $this);
- $nli->show();
- }
-
- function showContent()
- {
- if (!empty($this->error)) {
- $this->element('p', 'error', $this->error);
- }
- $form = new BookmarkForm($this,
- $this->title,
- $this->url,
- $this->tags,
- $this->description);
- $form->show();
- return;
- }
-
- function isReadOnly($args)
- {
- if ($_SERVER['REQUEST_METHOD'] == 'GET' ||
- $_SERVER['REQUEST_METHOD'] == 'HEAD') {
- return true;
- } else {
- return false;
- }
- }
- }
|