BxBaseConnectionFriend.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 BxBaseConnectionFriend extends BxDolConnectionFriend
  13. {
  14. protected function __construct($aObject)
  15. {
  16. parent::__construct($aObject);
  17. $this->_aT = array_merge($this->_aT, [
  18. 'done_initiator' => '_sys_conn_friends_done_initiator',
  19. 'done_initiator_mutual' => '_sys_conn_friends_done_initiator_mutual',
  20. 'do_content' => '_sys_conn_friends_do_content',
  21. 'counter' => '_sys_conn_friends_counter'
  22. ]);
  23. }
  24. protected function _getActions($iInitiator, $iContent, $aParams = [])
  25. {
  26. $sName = $sTitle = '';
  27. $aActions = [];
  28. if($this->isConnectedNotMutual($iInitiator, $iContent)) {
  29. $sName = 'default';
  30. $sTitle = $this->_aT['done_initiator'];
  31. $aActions = [[
  32. 'name' => 'remove',
  33. 'title' => ($sKey = 'txt_unfriend_cancel') && !empty($aParams[$sKey]) ? $aParams[$sKey] : '_sys_menu_item_title_sm_unfriend_cancel'
  34. ], [
  35. /*
  36. * An empty array item to show all items in popup.
  37. * More actions will be added later.
  38. */
  39. ]];
  40. }
  41. else if($this->isConnectedNotMutual($iContent, $iInitiator)) {
  42. $sName = 'add';
  43. $sTitle = $this->_aT['do_content'];
  44. $aActions = [[
  45. 'name' => 'add',
  46. 'title' => ($sKey = 'txt_befriend_confirm') && !empty($aParams[$sKey]) ? $aParams[$sKey] : '_sys_menu_item_title_sm_befriend_confirm'
  47. ], [
  48. 'name' => 'remove',
  49. 'title' => ($sKey = 'txt_unfriend_reject') && !empty($aParams[$sKey]) ? $aParams[$sKey] : '_sys_menu_item_title_sm_unfriend_reject'
  50. ]];
  51. }
  52. else if($this->isConnected($iInitiator, $iContent, true)) {
  53. $sName = 'default';
  54. $sTitle = $this->_aT['done_initiator_mutual'];
  55. $aActions = [[
  56. 'name' => 'remove',
  57. 'title' => ($sKey = 'txt_unfriend') && !empty($aParams[$sKey]) ? $aParams[$sKey] : '_sys_menu_item_title_sm_unfriend'
  58. ], [
  59. /*
  60. * An empty array item to show all items in popup.
  61. * More actions will be added later.
  62. */
  63. ]];
  64. }
  65. else
  66. $aActions = [[
  67. 'name' => 'add',
  68. 'title' => ($sKey = 'txt_befriend') && !empty($aParams[$sKey]) ? $aParams[$sKey] : '_sys_menu_item_title_sm_befriend'
  69. ]];
  70. return [
  71. 'name' => $sName,
  72. 'title' => $sTitle,
  73. 'items' => $aActions
  74. ];
  75. }
  76. protected function _getActionIconAsIcon($sAction)
  77. {
  78. $sDefault = 'user';
  79. $aA2I = [
  80. 'add' => 'user-plus',
  81. 'remove' => 'user-times'
  82. ];
  83. return isset($aA2I[$sAction]) ? $aA2I[$sAction] : $sDefault;
  84. }
  85. protected function _getActionIconAsEmoji($sAction)
  86. {
  87. $sDefault = '💕';
  88. $aA2I = [
  89. 'add' => '❤️',
  90. 'remove' => '💔'
  91. ];
  92. return isset($aA2I[$sAction]) ? $aA2I[$sAction] : $sDefault;
  93. }
  94. protected function _getActionIconAsImage($sAction)
  95. {
  96. $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-user-round-icon lucide-user-round"><circle cx="12" cy="8" r="5"/><path d="M20 21a8 8 0 0 0-16 0"/></svg>';
  97. $aA2I = [
  98. 'add' => '<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-user-round-plus-icon lucide-user-round-plus"><path d="M2 21a8 8 0 0 1 13.292-6"/><circle cx="10" cy="8" r="5"/><path d="M19 16v6"/><path d="M22 19h-6"/></svg>',
  99. 'remove' => '<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-user-round-x-icon lucide-user-round-x"><path d="M2 21a8 8 0 0 1 11.873-7"/><circle cx="10" cy="8" r="5"/><path d="m17 17 5 5"/><path d="m22 17-5 5"/></svg>'
  100. ];
  101. return isset($aA2I[$sAction]) ? $aA2I[$sAction] : $sDefault;
  102. }
  103. }