BxBaseConnectionSubscription.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. //TODO: Get emoji similar to
  59. protected function _getActionIconAsEmoji($sAction)
  60. {
  61. $sDefault = '';
  62. $aA2I = [
  63. 'add' => $sDefault,
  64. 'remove' => $sDefault
  65. ];
  66. return isset($aA2I[$sAction]) ? $aA2I[$sAction] : $sDefault;
  67. }
  68. protected function _getActionIconAsImage($sAction)
  69. {
  70. $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>';
  71. $aA2I = [
  72. 'add' => $sDefault,
  73. 'remove' => $sDefault
  74. ];
  75. return isset($aA2I[$sAction]) ? $aA2I[$sAction] : $sDefault;
  76. }
  77. }