BxBaseConnectionFriend.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. $sName = 'remove';
  29. $sTitle = $this->_aT['do_initiator'];
  30. $aActions = [[
  31. 'name' => 'add',
  32. 'title' => ($sKey = 'txt_befriend_sent') && !empty($aParams[$sKey]) ? $aParams[$sKey] : '_sys_menu_item_title_sm_befriend_sent'
  33. ], [
  34. 'name' => 'remove',
  35. 'title' => ($sKey = 'txt_unfriend_cancel') && !empty($aParams[$sKey]) ? $aParams[$sKey] : '_sys_menu_item_title_sm_unfriend_cancel'
  36. ]];
  37. }
  38. else if($this->isConnectedNotMutual($iContent, $iInitiator)) {
  39. $sName = 'add';
  40. $sTitle = $this->_aT['do_content'];
  41. $aActions = [[
  42. 'name' => 'add',
  43. 'title' => ($sKey = 'txt_befriend_confirm') && !empty($aParams[$sKey]) ? $aParams[$sKey] : '_sys_menu_item_title_sm_befriend_confirm'
  44. ], [
  45. 'name' => 'remove',
  46. 'title' => ($sKey = 'txt_unfriend_reject') && !empty($aParams[$sKey]) ? $aParams[$sKey] : '_sys_menu_item_title_sm_unfriend_reject'
  47. ]];
  48. }
  49. else if($this->isConnected($iInitiator, $iContent, true))
  50. $aActions = [[
  51. 'name' => 'remove',
  52. 'title' => ($sKey = 'txt_unfriend') && !empty($aParams[$sKey]) ? $aParams[$sKey] : '_sys_menu_item_title_sm_unfriend'
  53. ]];
  54. else
  55. $aActions = [[
  56. 'name' => 'add',
  57. 'title' => ($sKey = 'txt_befriend') && !empty($aParams[$sKey]) ? $aParams[$sKey] : '_sys_menu_item_title_sm_befriend'
  58. ]];
  59. return [
  60. 'name' => $sName,
  61. 'title' => $sTitle,
  62. 'items' => $aActions
  63. ];
  64. }
  65. protected function _getActionIconAsIcon($sAction)
  66. {
  67. $sDefault = 'user';
  68. $aA2I = [
  69. 'add' => 'user-plus',
  70. 'remove' => 'user-times'
  71. ];
  72. return isset($aA2I[$sAction]) ? $aA2I[$sAction] : $sDefault;
  73. }
  74. //TODO: Get emoji similar to
  75. protected function _getActionIconAsEmoji($sAction)
  76. {
  77. $sDefault = '';
  78. $aA2I = [
  79. 'add' => '',
  80. 'remove' => ''
  81. ];
  82. return isset($aA2I[$sAction]) ? $aA2I[$sAction] : $sDefault;
  83. }
  84. protected function _getActionIconAsImage($sAction)
  85. {
  86. $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-icon lucide-user"><path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>';
  87. $aA2I = [
  88. '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>',
  89. '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>'
  90. ];
  91. return isset($aA2I[$sAction]) ? $aA2I[$sAction] : $sDefault;
  92. }
  93. }