From: Mikael Nordfeldth Date: Thu, 12 Mar 2015 15:33:34 +0000 (+0100) Subject: Share plugin now handles showing form in NoticeOptionItems X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=dcfcceb6f2d4d35eb2a0d19f96aefb38c4b37533;p=quix0rs-gnu-social.git Share plugin now handles showing form in NoticeOptionItems --- diff --git a/actions/showstream.php b/actions/showstream.php index eb6300fec2..8dd6c7deff 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -225,10 +225,7 @@ class ShowstreamAction extends ProfileAction function showNotices() { - $pnl = null; - if (Event::handle('ShowStreamNoticeList', array($this->notice, $this, &$pnl))) { - $pnl = new ProfileNoticeList($this->notice, $this); - } + $pnl = new NoticeList($this->notice, $this); $cnt = $pnl->show(); if (0 == $cnt) { $this->showEmptyListMessage(); diff --git a/lib/default.php b/lib/default.php index 8b15d57857..e9382a86bc 100644 --- a/lib/default.php +++ b/lib/default.php @@ -302,6 +302,7 @@ $default = 'AuthCrypt' => array(), 'Cronish' => array(), 'Favorite' => array(), + 'Share' => array(), 'LRDD' => array(), 'StrictTransportSecurity' => array(), ), diff --git a/lib/noticelistitem.php b/lib/noticelistitem.php index 9c2f2ed406..bb1eb17eb3 100644 --- a/lib/noticelistitem.php +++ b/lib/noticelistitem.php @@ -193,7 +193,6 @@ class NoticeListItem extends Widget $this->out->elementStart('div', 'notice-options'); if (Event::handle('StartShowNoticeOptionItems', array($this))) { $this->showReplyLink(); - $this->showRepeatForm(); $this->showDeleteLink(); Event::handle('EndShowNoticeOptionItems', array($this)); } @@ -605,34 +604,6 @@ class NoticeListItem extends Widget } } - /** - * show the form to repeat a notice - * - * @return void - */ - function showRepeatForm() - { - if ($this->notice->scope == Notice::PUBLIC_SCOPE || - $this->notice->scope == Notice::SITE_SCOPE) { - $user = common_current_user(); - if (!empty($user) && - $user->id != $this->notice->profile_id) { - $this->out->text(' '); - $profile = $user->getProfile(); - if ($profile->hasRepeated($this->notice)) { - $this->out->element('span', array('class' => 'repeated', - // TRANS: Title for repeat form status in notice list when a notice has been repeated. - 'title' => _('Notice repeated.')), - // TRANS: Repeat form status in notice list when a notice has been repeated. - _('Repeated')); - } else { - $rf = new RepeatForm($this->out, $this->notice); - $rf->show(); - } - } - } - } - /** * finish the notice * diff --git a/lib/profilenoticelist.php b/lib/profilenoticelist.php deleted file mode 100644 index d95709e7e9..0000000000 --- a/lib/profilenoticelist.php +++ /dev/null @@ -1,11 +0,0 @@ -out); - } -} diff --git a/lib/profilenoticelistitem.php b/lib/profilenoticelistitem.php deleted file mode 100644 index d7773cab31..0000000000 --- a/lib/profilenoticelistitem.php +++ /dev/null @@ -1,49 +0,0 @@ -repeat)) { - - // FIXME: this code is almost identical to default; need to refactor - - $attrs = array('href' => $this->profile->profileurl, - 'class' => 'url'); - - if (!empty($this->profile->fullname)) { - $attrs['title'] = $this->profile->getFancyName(); - } - - $this->out->elementStart('span', 'repeat'); - - $text_link = XMLStringer::estring('a', $attrs, $this->profile->nickname); - - // TRANS: Link to the author of a repeated notice. %s is a linked nickname. - $this->out->raw(sprintf(_('Repeat of %s'), $text_link)); - - $this->out->elementEnd('span'); - } - } -} diff --git a/lib/repeatform.php b/lib/repeatform.php deleted file mode 100644 index f0ce37fb62..0000000000 --- a/lib/repeatform.php +++ /dev/null @@ -1,129 +0,0 @@ -. - * - * @category Form - * @package StatusNet - * @author Evan Prodromou - * @copyright 2009 StatusNet, Inc. - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://status.net/ - */ - -if (!defined('STATUSNET')) { - exit(1); -} - -/** - * Form for repeating a notice - * - * @category Form - * @package StatusNet - * @author Evan Prodromou - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://status.net/ - */ -class RepeatForm extends Form -{ - /** - * Notice to repeat - */ - var $notice = null; - - /** - * Constructor - * - * @param HTMLOutputter $out output channel - * @param Notice $notice notice to repeat - */ - 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 'repeat-' . $this->notice->id; - } - - /** - * Action of the form - * - * @return string URL of the action - */ - function action() - { - return common_local_url('repeat'); - } - - /** - * Legend of the Form - * - * @return void - */ - function formLegend() - { - // TRANS: For legend for notice repeat form. - $this->out->element('legend', null, _('Repeat this notice?')); - } - - /** - * 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('repeat-submit-' . $this->notice->id, - // TRANS: Button text to repeat a notice on notice repeat form. - _m('BUTTON','Yes'), 'submit', null, - // TRANS: Button title to repeat a notice on notice repeat form. - _('Repeat this notice.')); - } - - /** - * Class of the form. - * - * @return string the form's class - */ - function formClass() - { - return 'form_repeat'; - } -} diff --git a/plugins/GNUsocialProfileExtensions/GNUsocialProfileExtensionsPlugin.php b/plugins/GNUsocialProfileExtensions/GNUsocialProfileExtensionsPlugin.php index 6b3c757b1e..c4628c4ecc 100644 --- a/plugins/GNUsocialProfileExtensions/GNUsocialProfileExtensionsPlugin.php +++ b/plugins/GNUsocialProfileExtensions/GNUsocialProfileExtensionsPlugin.php @@ -137,21 +137,4 @@ class GNUsocialProfileExtensionsPlugin extends Plugin array('nickname' => $nav->action->trimmed('nickname'))), _('Bio'), _('The user\'s extended profile'), $nav->action->trimmed('action') == 'bio', 'nav_bio'); } - - //Why the heck is this shoved into this plugin!?!? It deserves its own! - function onShowStreamNoticeList($notice, $action, &$pnl) - { - //TODO: This function is called after the notices in $notice are superfluously retrieved in showstream.php - $newnotice = new Notice(); - $newnotice->profile_id = $action->user->id; - $newnotice->orderBy('modified DESC'); - $newnotice->whereAdd('reply_to IS NULL'); - $newnotice->limit(($action->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); - $newnotice->find(); - - $pnl = new NoticeTree($newnotice, $action); - return false; - } - } - diff --git a/plugins/ModPlus/actions/remoteprofile.php b/plugins/ModPlus/actions/remoteprofile.php index 133646480c..4203672030 100644 --- a/plugins/ModPlus/actions/remoteprofile.php +++ b/plugins/ModPlus/actions/remoteprofile.php @@ -39,10 +39,7 @@ class RemoteProfileAction extends ShowstreamAction $this->raw(common_markup_to_html($markdown)); }else{ - $pnl = null; - if (Event::handle('ShowStreamNoticeList', array($this->notice, $this, &$pnl))) { - $pnl = new ProfileNoticeList($this->notice, $this); - } + $pnl = new NoticeList($this->notice, $this); $cnt = $pnl->show(); if (0 == $cnt) { $this->showEmptyListMessage(); diff --git a/plugins/Share/SharePlugin.php b/plugins/Share/SharePlugin.php index 18143d5a63..0a974701c0 100644 --- a/plugins/Share/SharePlugin.php +++ b/plugins/Share/SharePlugin.php @@ -161,22 +161,16 @@ class SharePlugin extends ActivityVerbHandlerPlugin // ActivityObject is instead turned into an Activity $object = new Activity(); $object->verb = ActivityVerb::SHARE; - $object->type = $notice->object_type; - $object->title = sprintf(_('%1$s repeated a notice by %2$s'), - $object->getProfile()->getNickname(), - $target->getProfile()->getNickname()); $object->content = $notice->rendered; + $this->extendActivity($stored, $act); + return $object; } public function deleteRelated(Notice $notice) { - try { - $fave = Fave::fromStored($notice); - $fave->delete(); - } catch (NoResultException $e) { - // Cool, no problem. We wanted to get rid of it anyway. - } + // No action needed as we don't have a separate table for share objects. + return true; } // API stuff @@ -260,20 +254,26 @@ class SharePlugin extends ActivityVerbHandlerPlugin * * @return void */ - public function onStartShowNoticeOptionItems($nli) + public function onEndShowNoticeOptionItems($nli) { - if (Event::handle('StartShowFaveForm', array($nli))) { + // FIXME: Use bitmasks (but be aware that PUBLIC_SCOPE is 0!) + if ($nli->notice->scope == Notice::PUBLIC_SCOPE || + $nli->notice->scope == Notice::SITE_SCOPE) { $scoped = Profile::current(); - if ($scoped instanceof Profile) { - if (Fave::existsForProfile($nli->notice, $scoped)) { - $disfavor = new DisfavorForm($nli->out, $nli->notice); - $disfavor->show(); + if ($scoped instanceof Profile && + $scoped->getID() !== $nli->notice->getProfile()->getID()) { + + if ($scoped->hasRepeated($nli->notice)) { + $nli->out->element('span', array('class' => 'repeated', + // TRANS: Title for repeat form status in notice list when a notice has been repeated. + 'title' => _('Notice repeated.')), + // TRANS: Repeat form status in notice list when a notice has been repeated. + _('Repeated')); } else { - $favor = new FavorForm($nli->out, $nli->notice); - $favor->show(); + $repeat = new RepeatForm($nli->out, $nli->notice); + $repeat->show(); } } - Event::handle('EndShowFaveForm', array($nli)); } } diff --git a/plugins/Share/forms/repeat.php b/plugins/Share/forms/repeat.php new file mode 100644 index 0000000000..f0ce37fb62 --- /dev/null +++ b/plugins/Share/forms/repeat.php @@ -0,0 +1,129 @@ +. + * + * @category Form + * @package StatusNet + * @author Evan Prodromou + * @copyright 2009 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + exit(1); +} + +/** + * Form for repeating a notice + * + * @category Form + * @package StatusNet + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ +class RepeatForm extends Form +{ + /** + * Notice to repeat + */ + var $notice = null; + + /** + * Constructor + * + * @param HTMLOutputter $out output channel + * @param Notice $notice notice to repeat + */ + 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 'repeat-' . $this->notice->id; + } + + /** + * Action of the form + * + * @return string URL of the action + */ + function action() + { + return common_local_url('repeat'); + } + + /** + * Legend of the Form + * + * @return void + */ + function formLegend() + { + // TRANS: For legend for notice repeat form. + $this->out->element('legend', null, _('Repeat this notice?')); + } + + /** + * 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('repeat-submit-' . $this->notice->id, + // TRANS: Button text to repeat a notice on notice repeat form. + _m('BUTTON','Yes'), 'submit', null, + // TRANS: Button title to repeat a notice on notice repeat form. + _('Repeat this notice.')); + } + + /** + * Class of the form. + * + * @return string the form's class + */ + function formClass() + { + return 'form_repeat'; + } +}