BxDolStudioJson.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 DolphinStudio Dolphin Studio
  7. * @{
  8. */
  9. class BxDolStudioJson extends BxDol implements iBxDolSingleton {
  10. public function __construct() {
  11. if (isset($GLOBALS['bxDolClasses'][get_class($this)]))
  12. trigger_error ('Multiple instances are not allowed for the class: ' . get_class($this), E_USER_ERROR);
  13. parent::__construct ();
  14. }
  15. public function __clone() {
  16. if (isset($GLOBALS['bxDolClasses'][get_class($this)]))
  17. trigger_error('Clone is not allowed for the class: ' . get_class($this), E_USER_ERROR);
  18. }
  19. static function getInstance() {
  20. if (!isset($GLOBALS['bxDolClasses'][__CLASS__])) {
  21. $GLOBALS['bxDolClasses'][__CLASS__] = new BxDolStudioJson();
  22. }
  23. return $GLOBALS['bxDolClasses'][__CLASS__];
  24. }
  25. public function load($sUrl, $aParams = array()) {
  26. $sContent = bx_file_get_contents($sUrl, $aParams);
  27. if(empty($sContent))
  28. return false;
  29. //--- Uncomment to debug
  30. //echo $sContent; exit;
  31. $mixedResult = json_decode($sContent, true);
  32. if(is_null($mixedResult))
  33. return false;
  34. return $mixedResult;
  35. }
  36. }
  37. /** @} */