BxDolStudioJson.php 1.4 KB

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