BxDolProfileUndefined.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup DolphinCore Dolphin Core
  7. * @{
  8. */
  9. /**
  10. * When profile is not available (for example profile is deleted) then use this special class.
  11. *
  12. * @section example Example of usage
  13. *
  14. * @code
  15. * bx_import('BxDolProfile');
  16. * $oProfile = BxDolProfile::getInstance($iId);
  17. * if (!$oProfile) {
  18. * bx_import('BxDolProfileUndefined');
  19. * $oProfile = BxDolProfileUndefined::getInstance();
  20. * }
  21. * @endcode
  22. */
  23. class BxDolProfileUndefined extends BxDol implements iBxDolSingleton, iBxDolProfile
  24. {
  25. /**
  26. * Constructor
  27. */
  28. protected function __construct ()
  29. {
  30. parent::__construct();
  31. }
  32. /**
  33. * Prevent cloning the instance
  34. */
  35. public function __clone()
  36. {
  37. $sClass = get_class($this);
  38. if (isset($GLOBALS['bxDolClasses'][$sClass]))
  39. trigger_error('Clone is not allowed for the class: ' . get_class($this), E_USER_ERROR);
  40. }
  41. /**
  42. * Get singleton instance of the class
  43. */
  44. public static function getInstance()
  45. {
  46. $sClass = __CLASS__;
  47. if(!isset($GLOBALS['bxDolClasses'][$sClass]))
  48. $GLOBALS['bxDolClasses'][$sClass] = new $sClass();
  49. return $GLOBALS['bxDolClasses'][$sClass];
  50. }
  51. /**
  52. * Get profile id
  53. */
  54. public function id()
  55. {
  56. return 0;
  57. }
  58. /**
  59. * Get profile display name
  60. */
  61. public function getDisplayName()
  62. {
  63. return _t('_uknown');
  64. }
  65. /**
  66. * Get profile url
  67. */
  68. public function getUrl()
  69. {
  70. return 'javascript:void(0);';
  71. }
  72. /**
  73. * Get profile unit
  74. */
  75. public function getUnit()
  76. {
  77. return '<div>' . $this->getDisplayName() . '</div>';
  78. }
  79. /**
  80. * Get profile avatar
  81. */
  82. public function getAvatar()
  83. {
  84. return BxDolTemplate::getInstance()->getImageUrl('account-avatar.png');
  85. }
  86. /**
  87. * Get profile thumb
  88. */
  89. public function getThumb()
  90. {
  91. return BxDolTemplate::getInstance()->getImageUrl('account-thumb.png');
  92. }
  93. /**
  94. * Get profile icon
  95. */
  96. public function getIcon()
  97. {
  98. return BxDolTemplate::getInstance()->getImageUrl('account-icon.png');
  99. }
  100. /**
  101. * Get profile edit url
  102. */
  103. public function getEditUrl()
  104. {
  105. return '';
  106. }
  107. /**
  108. * Check if profile is active
  109. */
  110. public function isActive()
  111. {
  112. return true;
  113. }
  114. }
  115. /** @} */