BxDolObject.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php defined('BX_DOL') or defined('BX_DOL_INSTALL') 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. * Base class for all Dolphin Object classes.
  11. * Child classes usually represents high level programming constructions to generate ready 'objects' functionality, like Comments, Votings, Forms.
  12. */
  13. class BxDolObject extends BxDol {
  14. protected $_iId = 0; ///< item id the action to be performed with
  15. protected $_sSystem = ''; ///< current system name
  16. protected $_aSystem = array(); ///< current system array
  17. protected $_oQuery = null;
  18. public function __construct($sSystem, $iId, $iInit = 1) {
  19. parent::__construct();
  20. $this->_aSystems = $this->getSystems();
  21. if(!isset($this->_aSystems[$sSystem]))
  22. return;
  23. $this->_sSystem = $sSystem;
  24. $this->_aSystem = $this->_aSystems[$sSystem];
  25. if(!$this->isEnabled())
  26. return;
  27. if($iInit)
  28. $this->init($iId);
  29. }
  30. public function init($iId)
  31. {
  32. if(!$this->isEnabled())
  33. return false;
  34. if(empty($this->_iId) && $iId)
  35. $this->setId($iId);
  36. return true;
  37. }
  38. public function getSystemId()
  39. {
  40. return $this->_aSystem['id'];
  41. }
  42. public function getSystemName()
  43. {
  44. return $this->_sSystem;
  45. }
  46. public function getSystemInfo()
  47. {
  48. return $this->_aSystem;
  49. }
  50. public function getId()
  51. {
  52. return $this->_iId;
  53. }
  54. public function setId($iId)
  55. {
  56. if($iId == $this->getId())
  57. return;
  58. $this->_iId = $iId;
  59. }
  60. public function isEnabled ()
  61. {
  62. return $this->_aSystem && (int)$this->_aSystem['is_on'] == 1;
  63. }
  64. }
  65. /** @} */