BxDolProfileUndefined.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 TridentCore Trident 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. * $oProfile = BxDolProfile::getInstance($iId);
  16. * if (!$oProfile)
  17. * $oProfile = BxDolProfileUndefined::getInstance();
  18. * @endcode
  19. */
  20. class BxDolProfileUndefined extends BxDol implements iBxDolSingleton, iBxDolProfile
  21. {
  22. /**
  23. * Constructor
  24. */
  25. protected function __construct ()
  26. {
  27. parent::__construct();
  28. }
  29. /**
  30. * Prevent cloning the instance
  31. */
  32. public function __clone()
  33. {
  34. $sClass = get_class($this);
  35. if (isset($GLOBALS['bxDolClasses'][$sClass]))
  36. trigger_error('Clone is not allowed for the class: ' . get_class($this), E_USER_ERROR);
  37. }
  38. /**
  39. * Get singleton instance of the class
  40. */
  41. public static function getInstance()
  42. {
  43. $sClass = __CLASS__;
  44. if(!isset($GLOBALS['bxDolClasses'][$sClass]))
  45. $GLOBALS['bxDolClasses'][$sClass] = new $sClass();
  46. return $GLOBALS['bxDolClasses'][$sClass];
  47. }
  48. /**
  49. * Get profile id
  50. */
  51. public function id()
  52. {
  53. return 0;
  54. }
  55. /**
  56. * Get profile display name
  57. */
  58. public function getDisplayName()
  59. {
  60. return _t('_uknown');
  61. }
  62. /**
  63. * Get profile url
  64. */
  65. public function getUrl()
  66. {
  67. return 'javascript:void(0);';
  68. }
  69. /**
  70. * Get profile unit
  71. */
  72. public function getUnit()
  73. {
  74. return '<div>' . $this->getDisplayName() . '</div>';
  75. }
  76. /**
  77. * Get profile avatar
  78. */
  79. public function getAvatar()
  80. {
  81. return BxDolTemplate::getInstance()->getImageUrl('account-avatar.png');
  82. }
  83. /**
  84. * Get profile thumb
  85. */
  86. public function getThumb()
  87. {
  88. return BxDolTemplate::getInstance()->getImageUrl('account-thumb.png');
  89. }
  90. /**
  91. * Get profile icon
  92. */
  93. public function getIcon()
  94. {
  95. return BxDolTemplate::getInstance()->getImageUrl('account-icon.png');
  96. }
  97. /**
  98. * Get profile edit url
  99. */
  100. public function getEditUrl()
  101. {
  102. return '';
  103. }
  104. /**
  105. * Check if profile is active
  106. */
  107. public function isActive()
  108. {
  109. return true;
  110. }
  111. }
  112. /** @} */