BxDolStudioJson.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  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. defined('BX_DOL') or die('hack attempt');
  10. class BxDolStudioJson {
  11. public function __construct() {
  12. if(isset($GLOBALS['bxDolClasses'][get_class($this)]))
  13. trigger_error ('Multiple instances are not allowed for the class: ' . get_class($this), E_USER_ERROR);
  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. /** @} */