PageRenderTime 47ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/bitrix/modules/bizproc/install/components/bitrix/bizproc.wizards/component.php

https://github.com/alexs13/site
PHP | 157 lines | 130 code | 27 blank | 0 comment | 29 complexity | bcddd0547965d2db0c99cee444c3441e MD5 | raw file
  1. <?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
  2. if (!CModule::IncludeModule("bizproc"))
  3. {
  4. ShowError(GetMessage("BPWC_NO_BP_MODULE"));
  5. return;
  6. }
  7. if (!CModule::IncludeModule("iblock"))
  8. {
  9. ShowError(GetMessage("BPWC_NO_IB_MODULE"));
  10. return;
  11. }
  12. $arParams["IBLOCK_TYPE"] = trim($arParams["IBLOCK_TYPE"]);
  13. if (strlen($arParams["IBLOCK_TYPE"]) <= 0)
  14. {
  15. ShowError(GetMessage("BPWC_WC_EMPTY_TYPE"));
  16. return;
  17. }
  18. $arParams['NAME_TEMPLATE'] = empty($arParams['NAME_TEMPLATE']) ? COption::GetOptionString("bizproc", "name_template", CSite::GetNameFormat(false), SITE_ID) : str_replace(array("#NOBR#","#/NOBR#"), array("",""), $arParams["NAME_TEMPLATE"]);
  19. $arDefaultUrlTemplates404 = array(
  20. "index" => "index.php",
  21. "new" => "new.php",
  22. "list" => "#block_id#/",
  23. "view" => "#block_id#/view-#bp_id#.php",
  24. "start" => "#block_id#/start.php",
  25. "edit" => "#block_id#/edit.php",
  26. "task" => "#block_id#/task-#task_id#.php",
  27. "bp" => "#block_id#/bp.php",
  28. "setvar" => "#block_id#/setvar.php",
  29. "log" => "#block_id#/log-#bp_id#.php",
  30. );
  31. $arDefaultUrlTemplatesN404 = array(
  32. "index" => "page=index",
  33. "new" => "page=new",
  34. "list" => "page=list&block_id=#block_id#",
  35. "view" => "page=view&block_id=#block_id#&bp_id=#bp_id#",
  36. "start" => "page=start&block_id=#block_id#",
  37. "edit" => "page=edit&block_id=#block_id#",
  38. "task" => "page=task&task_id=#task_id#&block_id=#block_id#",
  39. "bp" => "page=bp&block_id=#block_id#",
  40. "setvar" => "page=setvar&block_id=#block_id#",
  41. "log" => "page=log&block_id=#block_id#&bp_id=#bp_id#",
  42. );
  43. $arDefaultVariableAliases404 = array();
  44. $arDefaultVariableAliases = array();
  45. $componentPage = "";
  46. $arComponentVariables = array("page", "task_id", "block_id", "bp_id", "sessid", "saveajax", "export_template", "import_template");
  47. if ($_REQUEST["auth"]=="Y" && $USER->IsAuthorized())
  48. LocalRedirect($APPLICATION->GetCurPageParam("", array("login", "logout", "register", "forgot_password", "change_password", "backurl", "auth")));
  49. if ($arParams["SEF_MODE"] == "Y")
  50. {
  51. $arVariables = array();
  52. $arUrlTemplates = CComponentEngine::MakeComponentUrlTemplates($arDefaultUrlTemplates404, $arParams["SEF_URL_TEMPLATES"]);
  53. $arVariableAliases = CComponentEngine::MakeComponentVariableAliases($arDefaultVariableAliases404, $arParams["VARIABLE_ALIASES"]);
  54. $componentPage = CComponentEngine::ParseComponentPath($arParams["SEF_FOLDER"], $arUrlTemplates, $arVariables);
  55. if (array_key_exists($arVariables["page"], $arDefaultUrlTemplates404))
  56. $componentPage = $arVariables["page"];
  57. if (empty($componentPage) || (!array_key_exists($componentPage, $arDefaultUrlTemplates404)))
  58. $componentPage = "index";
  59. CComponentEngine::InitComponentVariables($componentPage, $arComponentVariables, $arVariableAliases, $arVariables);
  60. foreach ($arUrlTemplates as $url => $value)
  61. $arResult["PATH_TO_".strtoupper($url)] = $arParams["SEF_FOLDER"].$value;
  62. }
  63. else
  64. {
  65. $arVariables = array();
  66. $arVariableAliases = CComponentEngine::MakeComponentVariableAliases($arDefaultVariableAliases, $arParams["VARIABLE_ALIASES"]);
  67. CComponentEngine::InitComponentVariables(false, $arComponentVariables, $arVariableAliases, $arVariables);
  68. if (array_key_exists($arVariables["page"], $arDefaultUrlTemplates404))
  69. $componentPage = $arVariables["page"];
  70. if (empty($componentPage) || (!array_key_exists($componentPage, $arDefaultUrlTemplates404)))
  71. $componentPage = "index";
  72. foreach ($arDefaultUrlTemplatesN404 as $url => $value)
  73. $arResult["PATH_TO_".strtoupper($url)] = $GLOBALS["APPLICATION"]->GetCurPageParam($value, $arComponentVariables);
  74. }
  75. if ($_REQUEST["auth"] == "Y")
  76. $componentPage = "auth";
  77. if ($arParams["SKIP_BLOCK"] == "Y" && $componentPage == "index")
  78. {
  79. $componentPage = "list";
  80. $dbBlockList = CIBlock::GetList(
  81. array("SORT" => "ASC", "NAME" => "ASC"),
  82. array("ACTIVE" => "Y", "SITE_ID" => SITE_ID, "TYPE" => $arParams["IBLOCK_TYPE"])
  83. );
  84. while ($arBlock = $dbBlockList->Fetch())
  85. $arResult["VARIABLES"]["block_id"] = $arBlock["ID"];
  86. }
  87. $arResult = array_merge(
  88. array(
  89. "SEF_MODE" => $arParams["SEF_MODE"],
  90. "SEF_FOLDER" => $arParams["SEF_FOLDER"],
  91. "VARIABLES" => $arVariables,
  92. "ALIASES" => $arParams["SEF_MODE"] == "Y"? array(): $arVariableAliases,
  93. "SET_TITLE" => $arParams["SET_TITLE"],
  94. "SET_NAV_CHAIN" => $arParams["SET_NAV_CHAIN"],
  95. "ADMIN_ACCESS" => $arParams["ADMIN_ACCESS"],
  96. "COMPONENT_TEMPLATES" => array(),
  97. ),
  98. $arResult
  99. );
  100. if (isset($arResult["VARIABLES"]["block_id"]))
  101. {
  102. global $CACHE_MANAGER;
  103. if ($CACHE_MANAGER->Read(86400, "component_bizproc_wizards_templates"))
  104. {
  105. $arComponentTemplates = $CACHE_MANAGER->Get("component_bizproc_wizards_templates");
  106. }
  107. else
  108. {
  109. $arComponentTemplates = array();
  110. $dbIBlock = CIBlock::GetList(
  111. array(),
  112. array("TYPE" => $arParams["IBLOCK_TYPE"], "ACTIVE" => "Y", "CHECK_PERMISSIONS" => "N")
  113. );
  114. while ($arIBlock = $dbIBlock->Fetch())
  115. {
  116. if (strlen($arIBlock["DESCRIPTION"]) > 0 && substr($arIBlock["DESCRIPTION"], 0, strlen("v2:")) == "v2:")
  117. {
  118. $v1 = @unserialize(substr($arIBlock["DESCRIPTION"], 3));
  119. if (is_array($v1))
  120. $arComponentTemplates[$arIBlock["ID"]] = $v1["COMPONENT_TEMPLATES"];
  121. }
  122. }
  123. $CACHE_MANAGER->Set("component_bizproc_wizards_templates", $arComponentTemplates);
  124. }
  125. $arResult["COMPONENT_TEMPLATES"] = (array_key_exists($arResult["VARIABLES"]["block_id"], $arComponentTemplates) ? $arComponentTemplates[$arResult["VARIABLES"]["block_id"]] : array());
  126. }
  127. $arParams["ERROR_MESSAGE"] = "";
  128. $arParams["NOTE_MESSAGE"] = "";
  129. $this->IncludeComponentTemplate($componentPage);
  130. ?>