]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/Bookmark/bookmarkform.php
Merge branch '1.0.x' into testing
[quix0rs-gnu-social.git] / plugins / Bookmark / bookmarkform.php
1 <?php
2 /**
3  * StatusNet - the distributed open-source microblogging tool
4  * Copyright (C) 2010, StatusNet, Inc.
5  *
6  * Form for adding a new bookmark
7  * 
8  * PHP version 5
9  *
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.
14  *
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.
19  *
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/>.
22  *
23  * @category  Bookmark
24  * @package   StatusNet
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/
29  */
30
31 if (!defined('STATUSNET')) {
32     // This check helps protect against security problems;
33     // your code file can't be executed directly from the web.
34     exit(1);
35 }
36
37 /**
38  * Form to add a new bookmark
39  *
40  * @category  Bookmark
41  * @package   StatusNet
42  * @author    Evan Prodromou <evan@status.net>
43  * @copyright 2010 StatusNet, Inc.
44  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
45  * @link      http://status.net/
46  */
47
48 class BookmarkForm extends Form
49 {
50     private $_title       = null;
51     private $_url         = null;
52     private $_tags        = null;
53     private $_description = null;
54
55     /**
56      * Construct a bookmark form
57      *
58      * @param HTMLOutputter $out         output channel
59      * @param string        $title       Title of the bookmark
60      * @param string        $url         URL of the bookmark
61      * @param string        $tags        Tags to show
62      * @param string        $description Description of the bookmark
63      *
64      * @return void
65      */
66
67     function __construct($out=null, $title=null, $url=null, $tags=null,
68                          $description=null)
69     {
70         parent::__construct($out);
71
72         $this->_title       = $title;
73         $this->_url         = $url;
74         $this->_tags        = $tags;
75         $this->_description = $description;
76     }
77
78     /**
79      * ID of the form
80      *
81      * @return int ID of the form
82      */
83
84     function id()
85     {
86         return 'form_new_bookmark';
87     }
88
89     /**
90      * class of the form
91      *
92      * @return string class of the form
93      */
94
95     function formClass()
96     {
97         return 'form_settings ajax-notice';
98     }
99
100     /**
101      * Action of the form
102      *
103      * @return string URL of the action
104      */
105
106     function action()
107     {
108         return common_local_url('newbookmark');
109     }
110
111     /**
112      * Data elements of the form
113      *
114      * @return void
115      */
116
117     function formData()
118     {
119         $this->out->elementStart('fieldset', array('id' => 'new_bookmark_data'));
120         $this->out->elementStart('ul', 'form_data');
121
122         $this->li();
123         $this->out->input('title',
124                           _m('LABEL','Title'),
125                           $this->_title,
126                           _m('Title of the bookmark'));
127         $this->unli();
128
129         $this->li();
130         $this->out->input('url',
131                           _m('LABEL','URL'),
132                           $this->_url,   
133                           _m('URL to bookmark'));
134         $this->unli();
135
136         $this->li();
137         $this->out->input('tags',
138                           _m('LABEL','Tags'),
139                           $this->_tags,   
140                           _m('Comma- or space-separated list of tags'));
141         $this->unli();
142
143         $this->li();
144         $this->out->input('description',
145                           _m('LABEL','Description'),
146                           $this->_description,   
147                           _m('Description of the URL'));
148         $this->unli();
149
150         $this->out->elementEnd('ul');
151
152         $toWidget = new ToSelector($this->out,
153                                    common_current_user(),
154                                    null);
155         $toWidget->show();
156
157         $this->out->elementEnd('fieldset');
158     }
159
160     /**
161      * Action elements
162      *
163      * @return void
164      */
165
166     function formActions()
167     {
168         $this->out->submit('submit', _m('BUTTON', 'Save'));
169     }
170 }