BxDolObject.php 1.8 KB

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