BxBaseConnectionSubscription.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaBaseView UNA Base Representation Classes
  7. * @{
  8. */
  9. /**
  10. * @see BxBaseConnection
  11. */
  12. class BxBaseConnectionSubscription extends BxDolConnectionSubscription
  13. {
  14. protected function __construct($aObject)
  15. {
  16. parent::__construct($aObject);
  17. $this->_aT = array_merge($this->_aT, [
  18. 'do_initiator' => '_sys_conn_subscriptions_do_initiator',
  19. 'counter' => '_sys_conn_subscriptions_counter'
  20. ]);
  21. }
  22. protected function _getActions($iInitiator, $iContent, $aParams = [])
  23. {
  24. $sName = $sTitle = '';
  25. $aActions = [];
  26. if($this->isConnected($iInitiator, $iContent)) {
  27. $sName = 'remove';
  28. $sTitle = $this->_aT['do_initiator'];
  29. $aActions = [[
  30. 'name' => 'remove',
  31. 'title' => ($sKey = 'txt_unsubscribe') && !empty($aParams[$sKey]) ? $aParams[$sKey] : '_sys_menu_item_title_sm_unsubscribe'
  32. ], [
  33. /*
  34. * An empty array item to show all items in popup.
  35. * More actions will be added later.
  36. */
  37. ]];
  38. } else
  39. $aActions = [[
  40. 'name' => 'add',
  41. 'title' => ($sKey = 'txt_subscribe') && !empty($aParams[$sKey]) ? $aParams[$sKey] : '_sys_menu_item_title_sm_subscribe'
  42. ]];
  43. return [
  44. 'name' => $sName,
  45. 'title' => $sTitle,
  46. 'items' => $aActions
  47. ];
  48. }
  49. protected function _getActionIconAsIcon($sAction)
  50. {
  51. $sDefault = 'check';
  52. $aA2I = [
  53. 'add' => $sDefault,
  54. 'remove' => $sDefault
  55. ];
  56. return isset($aA2I[$sAction]) ? $aA2I[$sAction] : $sDefault;
  57. }
  58. protected function _getActionIconAsEmoji($sAction)
  59. {
  60. $sDefault = '✔️';
  61. $aA2I = [
  62. 'add' => $sDefault,
  63. 'remove' => $sDefault
  64. ];
  65. return isset($aA2I[$sAction]) ? $aA2I[$sAction] : $sDefault;
  66. }
  67. protected function _getActionIconAsImage($sAction)
  68. {
  69. $sDefault = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check-icon lucide-check"><path d="M20 6 9 17l-5-5"/></svg>';
  70. $aA2I = [
  71. 'add' => $sDefault,
  72. 'remove' => $sDefault
  73. ];
  74. return isset($aA2I[$sAction]) ? $aA2I[$sAction] : $sDefault;
  75. }
  76. }