BxDolProfileUndefined.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. * Constructor
  26. */
  27. protected function __construct () {
  28. parent::__construct();
  29. }
  30. /**
  31. * Prevent cloning the instance
  32. */
  33. public function __clone() {
  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. $sClass = __CLASS__;
  43. if(!isset($GLOBALS['bxDolClasses'][$sClass]))
  44. $GLOBALS['bxDolClasses'][$sClass] = new $sClass();
  45. return $GLOBALS['bxDolClasses'][$sClass];
  46. }
  47. /**
  48. * Get profile id
  49. */
  50. public function id() {
  51. return 0;
  52. }
  53. /**
  54. * Get profile display name
  55. */
  56. public function getDisplayName() {
  57. return _t('_uknown');
  58. }
  59. /**
  60. * Get profile url
  61. */
  62. public function getUrl() {
  63. return 'javascript:void(0);';
  64. }
  65. /**
  66. * Get profile unit
  67. */
  68. public function getUnit() {
  69. return '<div>' . $this->getDisplayName() . '</div>';
  70. }
  71. /**
  72. * Get profile avatar
  73. */
  74. public function getAvatar() {
  75. return BxDolTemplate::getInstance()->getImageUrl('account-avatar.png');
  76. }
  77. /**
  78. * Get profile thumb
  79. */
  80. public function getThumb() {
  81. return BxDolTemplate::getInstance()->getImageUrl('account-thumb.png');
  82. }
  83. /**
  84. * Get profile icon
  85. */
  86. public function getIcon() {
  87. return BxDolTemplate::getInstance()->getImageUrl('account-icon.png');
  88. }
  89. /**
  90. * Get profile edit url
  91. */
  92. public function getEditUrl() {
  93. return '';
  94. }
  95. /**
  96. * Check if profile is active
  97. */
  98. public function isActive() {
  99. return true;
  100. }
  101. }
  102. /** @} */