ActivityVerbHandlerPlugin.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /*
  3. * GNU Social - a federating social network
  4. * Copyright (C) 2014, Free Software Foundation, Inc.
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. if (!defined('GNUSOCIAL')) { exit(1); }
  20. /**
  21. * @package Activity
  22. * @maintainer Mikael Nordfeldth <mmn@hethane.se>
  23. */
  24. abstract class ActivityVerbHandlerPlugin extends ActivityHandlerPlugin
  25. {
  26. public function onActivityVerbTitle(ManagedAction $action, $verb, Notice $target, Profile $scoped, &$title)
  27. {
  28. if (!$this->isMyVerb($verb)) {
  29. return true;
  30. }
  31. $title = $this->getActionTitle($action, $verb, $target, $scoped);
  32. return false;
  33. }
  34. abstract protected function getActionTitle(ManagedAction $action, $verb, Notice $target, Profile $scoped);
  35. public function onActivityVerbShowContent(ManagedAction $action, $verb, Notice $target, Profile $scoped)
  36. {
  37. if (!$this->isMyVerb($verb)) {
  38. return true;
  39. }
  40. return $this->showActionContent($action, $verb, $target, $scoped);
  41. }
  42. protected function showActionContent(ManagedAction $action, $verb, Notice $target, Profile $scoped)
  43. {
  44. if (!GNUsocial::isAjax()) {
  45. $nl = new NoticeListItem($target, $action, array('options'=>false, 'attachments'=>false,
  46. 'item_tag'=>'div', 'id_prefix'=>'fave'));
  47. $nl->show();
  48. }
  49. $form = $this->getActivityForm($action, $verb, $target, $scoped);
  50. $form->show();
  51. return false;
  52. }
  53. public function onActivityVerbDoPreparation(ManagedAction $action, $verb, Notice $target, Profile $scoped)
  54. {
  55. if (!$this->isMyVerb($verb)) {
  56. return true;
  57. }
  58. return $this->doActionPreparation($action, $verb, $target, $scoped);
  59. }
  60. abstract protected function doActionPreparation(ManagedAction $action, $verb, Notice $target, Profile $scoped);
  61. public function onActivityVerbDoPost(ManagedAction $action, $verb, Notice $target, Profile $scoped)
  62. {
  63. if (!$this->isMyVerb($verb)) {
  64. return true;
  65. }
  66. return $this->doActionPost($action, $verb, $target, $scoped);
  67. }
  68. abstract protected function doActionPost(ManagedAction $action, $verb, Notice $target, Profile $scoped);
  69. abstract protected function getActivityForm(ManagedAction $action, $verb, Notice $target, Profile $scoped);
  70. }