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/disfavorform.php | 130 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 lib/disfavorform.php (limited to 'lib/disfavorform.php') diff --git a/lib/disfavorform.php b/lib/disfavorform.php new file mode 100644 index 000000000..25f99f43c --- /dev/null +++ b/lib/disfavorform.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 disfavoring 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 FavorForm + */ + +class DisfavorForm extends Form +{ + /** + * Notice to disfavor + */ + + var $notice = null; + + /** + * Constructor + * + * @param HTMLOutputter $out output channel + * @param Notice $notice notice to disfavor + */ + + 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 'disfavor-' . $this->notice->id; + } + + /** + * Action of the form + * + * @return string URL of the action + */ + + function action() + { + common_local_url('disfavor'); + } + + /** + * 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('disfavor-submit-' . $this->notice->id, + _('Disfavor favorite')); + } +} \ No newline at end of file -- cgit v1.2.3-54-g00ecf