BxDolProfileUndefined.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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 BxDolTemplate::getInstance()->parseHtmlByName('profile_unit.html', array(
  75. 'thumb_url' => $this->getThumb(),
  76. 'title' => $this->getDisplayName()
  77. ));
  78. }
  79. /**
  80. * Get picture url
  81. */
  82. public function getPicture()
  83. {
  84. return BxDolTemplate::getInstance()->getImageUrl('account-picture.png');
  85. }
  86. /**
  87. * Get profile avatar
  88. */
  89. public function getAvatar()
  90. {
  91. return BxDolTemplate::getInstance()->getImageUrl('account-avatar.png');
  92. }
  93. /**
  94. * Get profile thumb
  95. */
  96. public function getThumb()
  97. {
  98. return BxDolTemplate::getInstance()->getImageUrl('account-thumb.png');
  99. }
  100. /**
  101. * Get profile icon
  102. */
  103. public function getIcon()
  104. {
  105. return BxDolTemplate::getInstance()->getImageUrl('account-icon.png');
  106. }
  107. /**
  108. * Get module icon
  109. */
  110. public function getIconModule($iProfileId = 0)
  111. {
  112. return 'user';
  113. }
  114. /**
  115. * Get profile edit url
  116. */
  117. public function getEditUrl()
  118. {
  119. return '';
  120. }
  121. /**
  122. * Check if profile is active
  123. */
  124. public function isActive()
  125. {
  126. return true;
  127. }
  128. }
  129. /** @} */