BxBaseConnectionFriend.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. 'do_initiator' => '_sys_conn_friends_do_initiator',
  19. 'do_content' => '_sys_conn_friends_do_content',
  20. 'counter' => '_sys_conn_friends_counter'
  21. ]);
  22. }
  23. protected function _getActions($iInitiator, $iContent, $aParams = [])
  24. {
  25. $sName = $sTitle = '';
  26. $aActions = [];
  27. if($this->isConnectedNotMutual($iInitiator, $iContent)) {
  28. $aActions = [[
  29. 'name' => 'remove',
  30. 'title' => ($sKey = 'txt_unfriend_cancel') && !empty($aParams[$sKey]) ? $aParams[$sKey] : '_sys_menu_item_title_sm_unfriend_cancel'
  31. ]];
  32. }
  33. else if($this->isConnectedNotMutual($iContent, $iInitiator)) {
  34. $sName = 'add';
  35. $sTitle = $this->_aT['do_content'];
  36. $aActions = [[
  37. 'name' => 'add',
  38. 'title' => ($sKey = 'txt_befriend_confirm') && !empty($aParams[$sKey]) ? $aParams[$sKey] : '_sys_menu_item_title_sm_befriend_confirm'
  39. ], [
  40. 'name' => 'remove',
  41. 'title' => ($sKey = 'txt_unfriend_reject') && !empty($aParams[$sKey]) ? $aParams[$sKey] : '_sys_menu_item_title_sm_unfriend_reject'
  42. ]];
  43. }
  44. else if($this->isConnected($iInitiator, $iContent, true)) {
  45. $sName = 'default';
  46. $sTitle = $this->_aT['do_initiator'];
  47. $aActions = [[
  48. 'name' => 'remove',
  49. 'title' => ($sKey = 'txt_unfriend') && !empty($aParams[$sKey]) ? $aParams[$sKey] : '_sys_menu_item_title_sm_unfriend'
  50. ], [
  51. /*
  52. * An empty array item to show all items in popup.
  53. * More actions will be added later.
  54. */
  55. ]];
  56. }
  57. else
  58. $aActions = [[
  59. 'name' => 'add',
  60. 'title' => ($sKey = 'txt_befriend') && !empty($aParams[$sKey]) ? $aParams[$sKey] : '_sys_menu_item_title_sm_befriend'
  61. ]];
  62. return [
  63. 'name' => $sName,
  64. 'title' => $sTitle,
  65. 'items' => $aActions
  66. ];
  67. }
  68. protected function _getActionIconAsIcon($sAction)
  69. {
  70. $sDefault = 'user';
  71. $aA2I = [
  72. 'add' => 'user-plus',
  73. 'remove' => 'user-times'
  74. ];
  75. return isset($aA2I[$sAction]) ? $aA2I[$sAction] : $sDefault;
  76. }
  77. protected function _getActionIconAsEmoji($sAction)
  78. {
  79. $sDefault = '💕';
  80. $aA2I = [
  81. 'add' => '❤️',
  82. 'remove' => '💔'
  83. ];
  84. return isset($aA2I[$sAction]) ? $aA2I[$sAction] : $sDefault;
  85. }
  86. protected function _getActionIconAsImage($sAction)
  87. {
  88. $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>';
  89. $aA2I = [
  90. '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>',
  91. '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>'
  92. ];
  93. return isset($aA2I[$sAction]) ? $aA2I[$sAction] : $sDefault;
  94. }
  95. }