3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2010, StatusNet, Inc.
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Affero General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Affero General Public License for more details.
20 * You should have received a copy of the GNU Affero General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 * @author Evan Prodromou <evan@status.net>
26 * @copyright 2010 StatusNet, Inc.
27 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
28 * @link http://status.net/
30 if (!defined('STATUSNET')) {
31 // This check helps protect against security problems;
32 // your code file can't be executed directly from the web.
41 * @author Evan Prodromou <evan@status.net>
42 * @copyright 2010 StatusNet, Inc.
43 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
44 * @link http://status.net/
46 class NewbookmarkAction extends FormAction
48 protected $complete = null;
49 protected $title = null;
50 protected $url = null;
51 protected $tags = null;
52 protected $description = null;
56 // TRANS: Title for action to create a new bookmark.
57 return _m('New bookmark');
60 protected function doPreparation()
62 $this->title = $this->trimmed('title');
63 $this->url = $this->trimmed('url');
64 $this->tags = preg_split('/[\s,]+/', $this->trimmed('tags'), null, PREG_SPLIT_NO_EMPTY);
65 $this->description = $this->trimmed('description');
77 if (empty($this->title)) {
78 // TRANS: Client exception thrown when trying to create a new bookmark without a title.
79 throw new ClientException(_m('Bookmark must have a title.'));
82 if (empty($this->url)) {
83 // TRANS: Client exception thrown when trying to create a new bookmark without a URL.
84 throw new ClientException(_m('Bookmark must have an URL.'));
89 ToSelector::fillOptions($this, $options);
91 $saved = Bookmark::addNew($this->scoped,
102 * Used to generate the notice code for Ajax results.
104 * @param Notice $notice Notice that was saved
108 function showNotice(Notice $notice)
110 class_exists('NoticeList'); // @fixme hack for autoloader
111 $nli = new NoticeListItem($notice, $this);
116 * Show the bookmark form
120 function showContent()
122 if (!empty($this->error)) {
123 $this->element('p', 'error', $this->error);
126 $form = new BookmarkForm($this,
138 * Return true if read only.
142 * @param array $args other arguments
144 * @return boolean is read only action?
146 function isReadOnly($args)
148 if ($_SERVER['REQUEST_METHOD'] == 'GET' ||
149 $_SERVER['REQUEST_METHOD'] == 'HEAD') {