BxDolObject.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 TridentCore Trident Core
  7. * @{
  8. */
  9. /**
  10. * Base class for all "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. {
  15. protected $_iId = 0; ///< item id the action to be performed with
  16. protected $_sSystem = ''; ///< current system name
  17. protected $_aSystem = array(); ///< current system array
  18. protected $_oQuery = null;
  19. public function __construct($sSystem, $iId, $iInit = 1)
  20. {
  21. parent::__construct();
  22. $aSystems = $this->getSystems();
  23. if(!isset($aSystems[$sSystem]))
  24. return;
  25. $this->_sSystem = $sSystem;
  26. $this->_aSystem = $aSystems[$sSystem];
  27. if(!$this->isEnabled())
  28. return;
  29. if($iInit)
  30. $this->init($iId);
  31. }
  32. public function init($iId)
  33. {
  34. if(!$this->isEnabled())
  35. return false;
  36. if(empty($this->_iId) && $iId)
  37. $this->setId($iId);
  38. return true;
  39. }
  40. public function getSystemId()
  41. {
  42. return $this->_aSystem['id'];
  43. }
  44. public function getSystemName()
  45. {
  46. return $this->_sSystem;
  47. }
  48. public function getSystemInfo()
  49. {
  50. return $this->_aSystem;
  51. }
  52. public function getId()
  53. {
  54. return $this->_iId;
  55. }
  56. public function setId($iId)
  57. {
  58. if($iId == $this->getId())
  59. return;
  60. $this->_iId = $iId;
  61. }
  62. public function isEnabled ()
  63. {
  64. return $this->_aSystem && (int)$this->_aSystem['is_on'] == 1;
  65. }
  66. }
  67. /** @} */