ActivityVerbHandlerModule.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 ActivityVerbHandlerModule extends ActivityHandlerModule
  25. {
  26. public $widgetOpts;
  27. public $scoped;
  28. public function onActivityVerbTitle(ManagedAction $action, $verb, Notice $target, Profile $scoped, &$title)
  29. {
  30. if (!$this->isMyVerb($verb)) {
  31. return true;
  32. }
  33. $title = $this->getActionTitle($action, $verb, $target, $scoped);
  34. return false;
  35. }
  36. abstract protected function getActionTitle(ManagedAction $action, $verb, Notice $target, Profile $scoped);
  37. public function onActivityVerbShowContent(ManagedAction $action, $verb, Notice $target, Profile $scoped)
  38. {
  39. if (!$this->isMyVerb($verb)) {
  40. return true;
  41. }
  42. return $this->showActionContent($action, $verb, $target, $scoped);
  43. }
  44. protected function showActionContent(ManagedAction $action, $verb, Notice $target, Profile $scoped)
  45. {
  46. if (!GNUsocial::isAjax()) {
  47. $nl = new NoticeListItem($target, $action, array('options'=>false, 'attachments'=>false,
  48. 'item_tag'=>'div', 'id_prefix'=>'fave'));
  49. $nl->show();
  50. }
  51. $form = $this->getActivityForm($action, $verb, $target, $scoped);
  52. $form->show();
  53. return false;
  54. }
  55. public function onActivityVerbDoPreparation(ManagedAction $action, $verb, Notice $target, Profile $scoped)
  56. {
  57. if (!$this->isMyVerb($verb)) {
  58. return true;
  59. }
  60. return $this->doActionPreparation($action, $verb, $target, $scoped);
  61. }
  62. abstract protected function doActionPreparation(ManagedAction $action, $verb, Notice $target, Profile $scoped);
  63. public function onActivityVerbDoPost(ManagedAction $action, $verb, Notice $target, Profile $scoped)
  64. {
  65. if (!$this->isMyVerb($verb)) {
  66. return true;
  67. }
  68. return $this->doActionPost($action, $verb, $target, $scoped);
  69. }
  70. abstract protected function doActionPost(ManagedAction $action, $verb, Notice $target, Profile $scoped);
  71. abstract protected function getActivityForm(ManagedAction $action, $verb, Notice $target, Profile $scoped);
  72. }