zin.class.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /**
  3. * The zin class file of zin of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2023 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
  6. * @author Hao Sun <sunhao@easycorp.ltd>
  7. * @package zin
  8. * @version $Id
  9. * @link https://www.zentao.net
  10. */
  11. namespace zin;
  12. require_once dirname(__DIR__) . DS . 'utils' . DS . 'deep.func.php';
  13. class zin
  14. {
  15. /**
  16. * @var mixed[]
  17. */
  18. public static $globalRenderList = array();
  19. /**
  20. * @var bool
  21. */
  22. public static $enabledGlobalRender = true;
  23. /**
  24. * @var mixed[]
  25. */
  26. public static $data = array();
  27. /**
  28. * @var bool
  29. */
  30. public static $rendered = false;
  31. /**
  32. * @var bool
  33. */
  34. public static $rawContentCalled = false;
  35. /**
  36. * @param mixed $defaultValue
  37. * @return mixed
  38. * @param string $namePath
  39. */
  40. public static function getData($namePath, $defaultValue = null)
  41. {
  42. return \zin\utils\deepGet(static::$data, $namePath, $defaultValue);
  43. }
  44. /**
  45. * @param mixed $value
  46. * @param string $namePath
  47. */
  48. public static function setData($namePath, $value)
  49. {
  50. \zin\utils\deepSet(static::$data, $namePath, $value);
  51. }
  52. public static function enableGlobalRender()
  53. {
  54. static::$enabledGlobalRender = true;
  55. }
  56. public static function disableGlobalRender()
  57. {
  58. static::$enabledGlobalRender = false;
  59. }
  60. public static function renderInGlobal()
  61. {
  62. if(!static::$enabledGlobalRender) return false;
  63. static::$globalRenderList = array_merge(static::$globalRenderList, func_get_args());
  64. return true;
  65. }
  66. /**
  67. * @param bool $clear
  68. */
  69. public static function getGlobalRenderList($clear = true)
  70. {
  71. $globalItems = array();
  72. foreach(static::$globalRenderList as $item)
  73. {
  74. if(is_object($item))
  75. {
  76. if((isset($item->parent) && $item->parent) || ($item instanceof node && ($item->type() === 'wg' || $item->type() === 'item')))
  77. continue;
  78. }
  79. $globalItems[] = $item;
  80. }
  81. /* Clear globalRenderList. */
  82. if($clear) static::$globalRenderList = array();
  83. return $globalItems;
  84. }
  85. }