From 19ae54775b0c7e210462363cc4bfc72bdeb8103f Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 14 Jan 2009 01:04:49 -0500 Subject: Move favor and disfavor form to their own classes --- lib/favorform.php | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 lib/favorform.php (limited to 'lib/favorform.php') diff --git a/lib/favorform.php b/lib/favorform.php new file mode 100644 index 000000000..c67e18697 --- /dev/null +++ b/lib/favorform.php @@ -0,0 +1,130 @@ +. + * + * @category Form + * @package Laconica + * @author Evan Prodromou + * @author Sarven Capadisli + * @copyright 2009 Control Yourself, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + +if (!defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/form.php'; + +/** + * Form for favoring a notice + * + * @category Form + * @package Laconica + * @author Evan Prodromou + * @author Sarven Capadisli + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + * + * @see DisfavorForm + */ + +class FavorForm extends Form +{ + /** + * Notice to favor + */ + + var $notice = null; + + /** + * Constructor + * + * @param HTMLOutputter $out output channel + * @param Notice $notice notice to favor + */ + + function __construct($out=null, $notice=null) + { + parent::__construct($out); + + $this->notice = $notice; + } + + /** + * ID of the form + * + * @return int ID of the form + */ + + function id() + { + return 'favor-' . $this->notice->id; + } + + /** + * Action of the form + * + * @return string URL of the action + */ + + function action() + { + common_local_url('favor'); + } + + /** + * Include a session token for CSRF protection + * + * @return void + */ + + function sessionToken() + { + $this->out->hidden('token-' . $this->notice->id, + common_session_token()); + } + + /** + * Data elements + * + * @return void + */ + + function formData() + { + $this->out->hidden('notice-n'.$this->notice->id, + $this->notice->id, + 'notice'); + } + + /** + * Action elements + * + * @return void + */ + + function formActions() + { + $this->out->submit('favor-submit-' . $this->notice->id, + _('Make a favorite')); + } +} \ No newline at end of file -- cgit v1.2.3-54-g00ecf