1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
wizard_site.php
См. документацию.
1<?
2
3define("BX_WIZARD_WELCOME_ID", "__welcome");
4define("BX_WIZARD_LICENSE_ID", "__license");
5define("BX_WIZARD_SELECT_SITE_ID", "__select_site");
6define("BX_WIZARD_SELECT_GROUP_ID", "__select_group");
7define("BX_WIZARD_SELECT_TEMPLATE_ID", "__select_template");
8define("BX_WIZARD_SELECT_SERVICE_ID", "__select_service");
9define("BX_WIZARD_SELECT_STRUCTURE_ID", "__select_structure");
10define("BX_WIZARD_START_INSTALL_ID", "__start_install");
11define("BX_WIZARD_INSTALL_SITE_ID", "__install_site");
12define("BX_WIZARD_INSTALL_TEMPLATE_ID", "__install_template");
13define("BX_WIZARD_INSTALL_SERVICE_ID", "__install_service");
14define("BX_WIZARD_INSTALL_STRUCTURE_ID", "__install_structure");
15define("BX_WIZARD_FINISH_ID", "__finish");
16define("BX_WIZARD_CANCEL_ID", "__install_cancel");
17
19{
20 var $name;
21 var $path;
22 var $wizard = null;
23
24 var $arSites = Array();
25 var $arTemplates = Array();
26 var $arTemplateGroups = Array();
27 var $arServices = Array();
28 var $arDescription = Array();
29 var $arStructure = Array();
30 var $arErrors = Array();
31
32 var $pathToScript = null;
33
34 var $siteID = null;
35 var $templateID = null;
36 var $groupID = null;
37 var $serviceID = Array();
38 var $structureID = null;
39
40 var $licenseExists = false;
41 var $siteExists = false;
42 var $groupExists = false;
43 var $templateExists = false;
44 var $serviceExists = false;
45 var $structureExists = false;
46
47 var $siteSelected = false;
48 var $templateSelected = false;
49 var $serviceSelected = false;
50 var $structureSelected = false;
51
52 var $__bInited = false;
53 var $__obLastStep = null;
54 var $__obFirstStep = null;
55
56 public function __construct($wizardName)
57 {
58 $this->name = $wizardName;
59
60 if (!CWizardUtil::CheckName($this->name))
61 {
62 $this->SetError(GetMessage("MAIN_WIZARD_ERROR_WRONG_WIZ_NAME"));
63 return;
64 }
65
66 $pathToWizard = CWizardUtil::MakeWizardPath($this->name);
67 $this->path = CWizardUtil::GetRepositoryPath().$pathToWizard;
68
69 if (!file_exists($_SERVER["DOCUMENT_ROOT"].$this->path) || !is_dir($_SERVER["DOCUMENT_ROOT"].$this->path))
70 {
71 $this->SetError(GetMessage("MAIN_WIZARD_ERROR_NOT_FOUND"));
72 return;
73 }
74
75 $this->__GetDescription();
76 $this->__CheckDepends();
78 }
79
80 function Install()
81 {
82 if ($this->__bInited)
83 return;
84
85 $this->__bInited = true;
86
87 if (!empty($this->arErrors))
88 {
89 /*Generate error step */
90 $this->__PackageError();
91 }
92 elseif ($this->pathToScript)
93 {
94 $package = $this;
95
96 if(isset($this->arDescription["PARENT"]) && $this->arDescription["PARENT"] == "wizard_sol")
97 {
98 $lang = LANGUAGE_ID;
99 $wizardPath = $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main";
100 $relativePath = "install/wizard_sol/wizard.php";
101
102 if ($lang != "en" && $lang != "ru")
103 {
104 if (file_exists(($fname = $wizardPath."/lang/".LangSubst($lang)."/".$relativePath)))
105 __IncludeLang($fname, false, true);
106 }
107
108 if (file_exists(($fname = $wizardPath."/lang/".$lang."/".$relativePath)))
109 __IncludeLang($fname, false, true);
110 }
111
112 $this->IncludeWizardLang("wizard.php");
113
114 include($this->pathToScript);
115
116 if (array_key_exists("STEPS", $this->arDescription) && is_array($this->arDescription["STEPS"]))
117 {
118 $wizardName = (array_key_exists("NAME", $this->arDescription) ? $this->arDescription["NAME"] : "");
119 $this->wizard = new CWizardBase($wizardName, $this);
120 $this->wizard->AddSteps($this->arDescription["STEPS"]);
121 $this->__SetTemplate();
122 $this->wizard->Display();
123 }
124 }
125 else
126 {
127 //Get description files
128 $this->__GetSites();
129 $this->__GetTemplates();
130 $this->__GetServices();
131 $this->__GetStructure();
132
133 //Generate system steps
134 $this->__Install();
135 }
136 }
137
138 function __Install()
139 {
140 //Create wizard
141 $wizardName = (array_key_exists("NAME", $this->arDescription) ? $this->arDescription["NAME"] : "");
142 $this->wizard = new CWizardBase($wizardName, $this);
143 $this->__SetTemplate();
144 $this->__InitVariables();
145
146 $wizard = $this->wizard;
147
148 //Welcome step
149 if ($this->__GetUserStep("welcome", $userWelcome))
150 $step = $userWelcome;
151 else
152 $step = new CPackageWelcome($this);
153
154 $wizard->AddStep($step, BX_WIZARD_WELCOME_ID);
155 $this->_SetNextStep($step, BX_WIZARD_WELCOME_ID, "select");
156 $this->__SetStepDescription($step, "WELCOME");
157 $step->SetCancelStep(BX_WIZARD_CANCEL_ID);
158 $lastStepID = $step->GetStepID();
159
160 //#NEW
161 if ($this->_InitSubStep("static", $this->arDescription["STEPS_SETTINGS"]["WELCOME"]) )
162 {
163 $lastStepID = $this->__obLastStep->GetStepID();
164 $this->_SetNextStep($this->__obLastStep, BX_WIZARD_WELCOME_ID, "select");
165 $this->__obFirstStep->SetPrevStep(BX_WIZARD_WELCOME_ID);
166 $step->SetNextStep($this->__obFirstStep->GetStepID());
167 }
168 //
169
170 //License step
171 if ($this->licenseExists)
172 {
173 $step = new CPackageLicense($this);
174 $wizard->AddStep($step, BX_WIZARD_LICENSE_ID);
175 $this->_SetNextStep($step, BX_WIZARD_LICENSE_ID, "select");
176 $this->__SetStepDescription($step, "LICENSE");
177 $step->SetPrevStep($lastStepID);
178 $lastStepID = $step->GetStepID();
179
180 //Add custom steps to wizard
181 if (/*$this->siteSelected &&*/ $this->_InitSubStep("static", $this->arDescription["STEPS_SETTINGS"]["LICENSE"]) )
182 {
183 $lastStepID = $this->__obLastStep->GetStepID();
184 $this->_SetNextStep($this->__obLastStep, BX_WIZARD_LICENSE_ID, "select");
185 $this->__obFirstStep->SetPrevStep(BX_WIZARD_LICENSE_ID);
186 $step->SetNextStep($this->__obFirstStep->GetStepID());
187 }
188 }
189
194
195 //Select site step
196 if ($this->siteExists)
197 {
198 $step = new CPackageSelectSite($this);
199 $wizard->AddStep($step, BX_WIZARD_SELECT_SITE_ID);
200 $this->_SetNextStep($step, BX_WIZARD_SELECT_SITE_ID, "select");
201 $this->__SetStepDescription($step, "SELECT_SITE");
202 $step->SetPrevStep($lastStepID);
203 $lastStepID = $step->GetStepID();
204
205 //Add custom steps to wizard
206 if ($this->siteSelected && $this->_InitSubStep("select", $this->arSites[$siteID]) )
207 {
208 $lastStepID = $this->__obLastStep->GetStepID();
209 $this->_SetNextStep($this->__obLastStep, BX_WIZARD_SELECT_SITE_ID, "select");
210 $this->__obFirstStep->SetPrevStep(BX_WIZARD_SELECT_SITE_ID);
211 $step->SetNextStep($this->__obFirstStep->GetStepID());
212 }
213 }
214
215 //Select group step
216 if ($this->groupExists && $this->templateExists)
217 {
218 $step = new CPackageSelectGroup($this);
219 $wizard->AddStep($step, BX_WIZARD_SELECT_GROUP_ID);
220 $this->_SetNextStep($step, BX_WIZARD_SELECT_GROUP_ID, "select");
221 $this->__SetStepDescription($step, "SELECT_GROUP");
222 $step->SetPrevStep($lastStepID);
223 $lastStepID = $step->GetStepID();
224 }
225
226 //Select template step
227 if ($this->templateExists)
228 {
229 $step = new CPackageSelectTemplate($this);
230 $wizard->AddStep($step, BX_WIZARD_SELECT_TEMPLATE_ID);
231 $this->_SetNextStep($step, BX_WIZARD_SELECT_TEMPLATE_ID, "select");
232 $this->__SetStepDescription($step, "SELECT_TEMPLATE");
233 $step->SetPrevStep($lastStepID);
234 $lastStepID = $step->GetStepID();
235
236 //Add custom steps to wizard
237 if ($this->templateSelected && $this->_InitSubStep("select", $this->arTemplates[$templateID]))
238 {
239 $lastStepID = $this->__obLastStep->GetStepID();
240 $this->_SetNextStep($this->__obLastStep, BX_WIZARD_SELECT_TEMPLATE_ID, "select");
241 $this->__obFirstStep->SetPrevStep(BX_WIZARD_SELECT_TEMPLATE_ID);
242 $step->SetNextStep($this->__obFirstStep->GetStepID());
243 }
244 }
245
246 //Select service step
247 if ($this->serviceExists)
248 {
249 $step = new CPackageSelectService($this);
250 $wizard->AddStep($step, BX_WIZARD_SELECT_SERVICE_ID);
251 $this->_SetNextStep($step, BX_WIZARD_SELECT_SERVICE_ID, "select");
252 //$step->SetNextStep("__start_install");
253 $step->SetPrevStep($lastStepID);
254 $this->__SetStepDescription($step, "SELECT_SERVICE");
255 $lastStepID = $step->GetStepID();
256
257 if ($this->serviceSelected)
258 {
259 foreach ($arServices as $service)
260 {
261 if (!array_key_exists($service, $this->arServices))
262 continue;
263
264 //Add custom steps to wizard
265 if ($this->_InitSubStep("select", $this->arServices[$service]))
266 {
267 $this->__obFirstStep->SetPrevStep($lastStepID);
268
269 //$this->__obLastStep->SetNextStep("__start_install");
270 $this->_SetNextStep($this->__obLastStep, BX_WIZARD_SELECT_SERVICE_ID, "select");
271 $lastStepID = $this->__obLastStep->GetStepID();
272
273 $step->SetNextStep($this->__obFirstStep->GetStepID());
274 $step = $this->__obLastStep;
275 }
276 }
277 }
278 }
279
280 //Select structure
281 if ($this->structureExists)
282 {
283 $step = new CPackageSelectStructure($this);
284 $wizard->AddStep($step, BX_WIZARD_SELECT_STRUCTURE_ID);
285 $this->_SetNextStep($step, BX_WIZARD_SELECT_STRUCTURE_ID, "select");
286 $this->__SetStepDescription($step, "SELECT_STRUCTURE");
287 $step->SetPrevStep($lastStepID);
288 $lastStepID = $step->GetStepID();
289
290 //#NEW
291 if ($this->_InitSubStep("select", $this->arStructure["SETTINGS"]))
292 {
293 $lastStepID = $this->__obLastStep->GetStepID();
294 $this->_SetNextStep($this->__obLastStep, BX_WIZARD_SELECT_STRUCTURE_ID, "select");
295 $this->__obFirstStep->SetPrevStep(BX_WIZARD_SELECT_STRUCTURE_ID);
296 $step->SetNextStep($this->__obFirstStep->GetStepID());
297 }
298 }
299
300 //Start installation step
301 $arSelected = Array(
302 "siteID" => ($this->siteSelected ? $siteID : null),
303 "templateID" => ($this->templateSelected ? $templateID : null),
304 "arServices" => ($this->serviceSelected ? $arServices : Array()),
305 );
306
307 if ($this->__GetUserStep("start_install", $userStartInstall))
308 $step = $userStartInstall;
309 else
310 $step = new CPackageStartInstall($this, $arSelected);
311
312 $wizard->AddStep($step, BX_WIZARD_START_INSTALL_ID);
313 $step->SetPrevStep($lastStepID);
314 $step->SetCancelStep(BX_WIZARD_CANCEL_ID);
315 $this->__SetStepDescription($step, "START_INSTALL");
316 $this->_SetNextStep($step, BX_WIZARD_START_INSTALL_ID, "install");
317
318 //#NEW
319 if ($this->_InitSubStep("static", $this->arDescription["STEPS_SETTINGS"]["START_INSTALL"]) )
320 {
321 $lastStepID = $this->__obLastStep->GetStepID();
322 $this->_SetNextStep($this->__obLastStep, BX_WIZARD_START_INSTALL_ID, "install");
323 $this->__obFirstStep->SetPrevStep(BX_WIZARD_START_INSTALL_ID);
324 $step->SetNextStep($this->__obFirstStep->GetStepID());
325 }
326 //
327
328 //Site installation step
329 if ($this->siteSelected)
330 {
331 $step = new CPackageInstallSite($this, $siteID);
332 $wizard->AddStep($step, BX_WIZARD_INSTALL_SITE_ID);
333 $this->_SetNextStep($step, BX_WIZARD_INSTALL_SITE_ID, "install");
334 $this->__SetStepDescription($step, "INSTALL_SITE");
335
336 if ($this->_InitSubStep("install", $this->arSites[$siteID]))
337 {
338 $this->_SetNextStep($this->__obLastStep, BX_WIZARD_INSTALL_SITE_ID, "install");
339 $step->SetNextStep($this->__obFirstStep->GetStepID());
340 }
341 }
342
343 //Template installation step
344 if ($this->templateSelected)
345 {
346 $step = new CPackageInstallTemplate($this, $templateID);
347 $wizard->AddStep($step, BX_WIZARD_INSTALL_TEMPLATE_ID);
348 $this->_SetNextStep($step, BX_WIZARD_INSTALL_TEMPLATE_ID, "install");
349 $this->__SetStepDescription($step, "INSTALL_TEMPLATE");
350
351 if ($this->_InitSubStep("install", $this->arTemplates[$templateID]))
352 {
353 $this->_SetNextStep($this->__obLastStep, BX_WIZARD_INSTALL_TEMPLATE_ID, "install");
354 $step->SetNextStep($this->__obFirstStep->GetStepID());
355 }
356 }
357
358 //Service installation step
359 if ($this->serviceSelected)
360 {
361 $obLastStep = null;
362 $number = "";
363 foreach ($arServices as $service)
364 {
365 if (!array_key_exists($service, $this->arServices))
366 continue;
367
368 if ($obLastStep !== null)
369 $obLastStep->SetNextStep(BX_WIZARD_INSTALL_SERVICE_ID.$number);
370
371 $step = new CPackageInstallService($this, $service);
372 $wizard->AddStep($step, BX_WIZARD_INSTALL_SERVICE_ID.$number);
373 $this->__SetStepDescription($step, "INSTALL_SERVICE");
374
375 if ($this->_InitSubStep("install", $this->arServices[$service]))
376 {
377 //$this->__obLastStep->SetNextStep("__finish");
378 $this->_SetNextStep($this->__obLastStep, BX_WIZARD_INSTALL_SERVICE_ID, "install");
379 $obLastStep = $this->__obLastStep;
380 $step->SetNextStep($this->__obFirstStep->GetStepID());
381 }
382 else
383 {
384 $obLastStep = $step;
385 //$step->SetNextStep("__finish");
386 $this->_SetNextStep($step, BX_WIZARD_INSTALL_SERVICE_ID, "install");
387 }
388
389 (int)$number++;
390 }
391 }
392
393 //Structure installation step
394 if ($this->structureSelected)
395 {
398 $this->_SetNextStep($step, BX_WIZARD_INSTALL_STRUCTURE_ID, "install");
399 $this->__SetStepDescription($step, "INSTALL_STRUCTURE");
400
401 //#NEW
402 if ($this->_InitSubStep("install", $this->arStructure["SETTINGS"]))
403 {
404 $this->_SetNextStep($this->__obLastStep, BX_WIZARD_INSTALL_STRUCTURE_ID, "install");
405 $step->SetNextStep($this->__obFirstStep->GetStepID());
406 }
407 }
408
409 //Finish step
410 $isUserStep = false;
411 if ($this->__GetUserStep("finish", $userFinish))
412 {
413 $step = $userFinish;
414 $isUserStep = true;
415 }
416 else
417 $step = new CPackageFinish($this);
418
419 $wizard->AddStep($step, BX_WIZARD_FINISH_ID);
420 $this->__SetStepDescription($step, "FINISH");
421
422 if (!$isUserStep)
423 $step->SetCancelStep(BX_WIZARD_FINISH_ID);
424
425 //#NEW
426 if ($this->_InitSubStep("end", $this->arDescription["STEPS_SETTINGS"]["FINISH"]) )
427 {
428 $this->__obFirstStep->SetPrevStep(BX_WIZARD_FINISH_ID);
429 $step->SetNextStep($this->__obFirstStep->GetStepID());
430 }
431
432 //Cancel step
433 $isUserStep = false;
434 if ($this->__GetUserStep("cancel", $userCancel))
435 {
436 $isUserStep = true;
437 $step = $userCancel;
438 }
439 else
440 $step = new CPackageCancel($this);
441
442 $wizard->AddStep($step, BX_WIZARD_CANCEL_ID);
443 $this->__SetStepDescription($step, "CANCEL");
444
445 if (!$isUserStep)
446 $step->SetCancelStep(BX_WIZARD_CANCEL_ID);
447
448 //#NEW
449 if ($this->_InitSubStep("end", $this->arDescription["STEPS_SETTINGS"]["CANCEL"]) )
450 {
451 $this->__obFirstStep->SetPrevStep(BX_WIZARD_CANCEL_ID);
452 $step->SetNextStep($this->__obFirstStep->GetStepID());
453 }
454
455 $wizard->Display();
456 }
457
458 function __SetTemplate()
459 {
460 if (!array_key_exists("TEMPLATES", $this->arDescription) || !is_array($this->arDescription["TEMPLATES"]))
461 return;
462
463 foreach ($this->arDescription["TEMPLATES"] as $arTemplate)
464 {
465 if($arTemplate["SCRIPT"]=="wizard_sol")
466 {
467 $lang = LANGUAGE_ID;
468 $wizardPath = $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main";
469 $relativePath = "install/wizard_sol/template.php";
470
471 if ($lang != "en" && $lang != "ru")
472 {
473 if (file_exists(($fname = $wizardPath."/lang/".LangSubst($lang)."/".$relativePath)))
474 __IncludeLang($fname, false, true);
475 }
476
477 if (file_exists(($fname = $wizardPath."/lang/".$lang."/".$relativePath)))
478 __IncludeLang($fname, false, true);
479
480 include_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/install/wizard_sol/template.php");
481
482 $stepID = ($arTemplate["STEP"] ?? null);
483 $this->wizard->SetTemplate(new WizardTemplate, $stepID);
484 $this->wizard->DisableAdminTemplate();
485 }
486 else
487 {
488 if (!isset($arTemplate["SCRIPT"]) || !isset($arTemplate["CLASS"]))
489 continue;
490
491 $pathToFile = $_SERVER["DOCUMENT_ROOT"].$this->path."/".$arTemplate["SCRIPT"];
492
493 if (!is_file($pathToFile))
494 continue;
495
496 $this->IncludeWizardLang($arTemplate["SCRIPT"]);
497
498 include_once($pathToFile);
499
500 if (!class_exists($arTemplate["CLASS"]))
501 continue;
502
503 $stepID = ($arTemplate["STEP"] ?? null);
504 $this->wizard->SetTemplate(new $arTemplate["CLASS"], $stepID);
505 $this->wizard->DisableAdminTemplate();
506 }
507 }
508
509 }
510
512 {
513 $this->licenseExists = ($this->__GetLicensePath() !== false);
514 $this->siteExists = (!empty($this->arSites));
515 $this->groupExists = (!empty($this->arTemplateGroups));
516 $this->templateExists = (!empty($this->arTemplates));
517 $this->serviceExists = (!empty($this->arServices));
518 $this->structureExists = (!empty($this->arStructure));
519
521
522 $this->siteID = $wizard->GetVar("__siteID");
523 $this->templateID = $wizard->GetVar("__templateID");
524 $this->groupID = $wizard->GetVar("__groupID");
525 $this->serviceID = $wizard->GetVar("__serviceID");
526 $this->structureID = $wizard->GetVar("__structureID");
527
528 $this->siteSelected = ($this->siteExists && $this->siteID !== null && array_key_exists($this->siteID, $this->arSites));
529 $this->templateSelected = ($this->templateExists && $this->templateID !== null && array_key_exists($this->templateID, $this->arTemplates));
530 $this->serviceSelected = ($this->serviceExists && is_array($this->serviceID));
531 $this->structureSelected = ($this->structureExists && $this->structureID <> '');
532 }
533
534 function _SetNextStep($obStep, $currentStep, $stepType = "select")
535 {
536 if ($stepType == "select")
537 $arWizardStep = Array(
538 BX_WIZARD_WELCOME_ID => true,
539 BX_WIZARD_LICENSE_ID => $this->licenseExists,
540 BX_WIZARD_SELECT_SITE_ID => $this->siteExists,
541 BX_WIZARD_SELECT_GROUP_ID => ($this->groupExists && $this->templateExists),
542 BX_WIZARD_SELECT_TEMPLATE_ID => $this->templateExists,
543 BX_WIZARD_SELECT_SERVICE_ID => $this->serviceExists,
544 BX_WIZARD_SELECT_STRUCTURE_ID => $this->structureExists,
546 );
547
548 else
549 $arWizardStep = Array(
551 BX_WIZARD_INSTALL_SITE_ID => $this->siteSelected,
552 BX_WIZARD_INSTALL_TEMPLATE_ID => $this->templateSelected,
553 BX_WIZARD_INSTALL_SERVICE_ID => $this->serviceSelected,
554 BX_WIZARD_INSTALL_STRUCTURE_ID => $this->structureSelected,
555 BX_WIZARD_FINISH_ID => true,
556 );
557
558 $nextStepID = null;
559 $foundCurrent = false;
560 foreach ($arWizardStep as $stepID => $success)
561 {
562 if ($foundCurrent && $success)
563 {
564 $nextStepID = $stepID;
565 break;
566 }
567
568 if ($currentStep == $stepID)
569 {
570 $foundCurrent = true;
571 continue;
572 }
573 }
574 $obStep->SetNextStep($nextStepID);
575 }
576
577 function _InitSubStep($stepType, &$arInstallation, $bInitStep = true)
578 {
579 if (!is_array($arInstallation))
580 return false;
581
582 if ($stepType == "install" || $stepType == "select")
583 {
584 $stepTypeKey = mb_strtoupper($stepType."_steps");
585 if (!array_key_exists($stepTypeKey, $arInstallation))
586 return false;
587
588 $arSteps =& $arInstallation[$stepTypeKey];
589 }
590 else
591 {
592 $arSteps =& $arInstallation;
593 }
594
595 if (!array_key_exists("SCRIPT", $arSteps) || !array_key_exists("STEPS", $arSteps))
596 return false;
597
598 $instScript = $_SERVER["DOCUMENT_ROOT"].$this->path."/".$arSteps["SCRIPT"];
599 if (!is_file($instScript))
600 return false;
601
602 $package = $this;
603 $this->IncludeWizardLang($arSteps["SCRIPT"]);
604 include_once($instScript);
605
606 $stepNumber = 1;
607 $stepCount = count($arSteps["STEPS"]);
608 $firstStepExists = false;
609 $lastStepExists = false;
610
611 foreach ($arSteps["STEPS"] as $stepID => $stepClass)
612 {
613 if (!class_exists($stepClass))
614 continue;
615
616 if ($bInitStep)
617 {
618 $subStep = new $stepClass;
619 $this->wizard->AddStep($subStep, $stepID);
620 }
621 else
622 {
623 if (!array_key_exists($stepID, $this->wizard->wizardSteps))
624 continue;
625 $subStep = $this->wizard->wizardSteps[$stepID];
626 }
627
628 if ($stepType == "select")
629 {
630 $subStep->SetCancelStep(BX_WIZARD_CANCEL_ID);
631 }
632 elseif ($stepType == "install")
633 {
634 $subStep->SetAutoSubmit();
635 $subStep->SetCancelStep(null);
636 $subStep->SetPrevStep(null);
637 }
638 elseif ($stepType == "static")
639 {
640 $subStep->SetCancelStep(BX_WIZARD_CANCEL_ID);
641 }
642
643 //First step
644 if ($stepNumber == 1)
645 {
646 if ($stepType == "install")
647 $subStep->SetPrevStep(null); //hide previous button
648 $this->__obFirstStep = $subStep;
649 $firstStepExists = true;
650 }
651
652 //Last step
653 if ($stepNumber == $stepCount)
654 {
655 $this->__obLastStep = $subStep;
656 $lastStepExists = true;
657 }
658
659 $stepNumber++;
660 }
661
662 return ($firstStepExists && $lastStepExists);
663 }
664
665 function __GetUserStep($stepName, &$step)
666 {
667 $stepName = mb_strtoupper($stepName);
668
669 if (!array_key_exists("STEPS_SETTINGS", $this->arDescription) || !array_key_exists($stepName, $this->arDescription["STEPS_SETTINGS"]))
670 return false;
671
672 if (!isset($this->arDescription["STEPS_SETTINGS"][$stepName]["SCRIPT"]) || !isset($this->arDescription["STEPS_SETTINGS"][$stepName]["CLASS"]))
673 return false;
674
675 $scriptPath = $this->arDescription["STEPS_SETTINGS"][$stepName]["SCRIPT"];
676 $stepClass = $this->arDescription["STEPS_SETTINGS"][$stepName]["CLASS"];
677
678 $pathToFile = $_SERVER["DOCUMENT_ROOT"].$this->path."/".$scriptPath;
679 if (!is_file($pathToFile))
680 return false;
681
682 $this->IncludeWizardLang($scriptPath);
683 include_once($pathToFile);
684
685 if (!class_exists($stepClass))
686 return false;
687
688 $step = new $stepClass;
689
690 if (!is_subclass_of($step, "CWizardStep"))
691 return false;
692
693 return true;
694 }
695
696 function __SetStepDescription($obStep, $stepName)
697 {
698 if (!array_key_exists("STEPS_SETTINGS", $this->arDescription) || !array_key_exists($stepName, $this->arDescription["STEPS_SETTINGS"]))
699 return;
700
701 if (isset($this->arDescription["STEPS_SETTINGS"][$stepName]["TITLE"]))
702 $obStep->SetTitle($this->arDescription["STEPS_SETTINGS"][$stepName]["TITLE"]);
703
704 if (isset($this->arDescription["STEPS_SETTINGS"][$stepName]["SUBTITLE"]))
705 $obStep->SetSubTitle($this->arDescription["STEPS_SETTINGS"][$stepName]["SUBTITLE"]);
706
707 if (isset($this->arDescription["STEPS_SETTINGS"][$stepName]["CONTENT"]))
708 $obStep->content .= $this->arDescription["STEPS_SETTINGS"][$stepName]["CONTENT"];
709 }
710
712 {
713 $path = false;
714
715 if (is_file($_SERVER["DOCUMENT_ROOT"].$this->path."/license.php"))
716 $path = $this->path."/license.php";
717
718 if (is_file($_SERVER["DOCUMENT_ROOT"].$this->path."/license_".LANGUAGE_ID.".php"))
719 $path = $this->path."/license_".LANGUAGE_ID.".php";
720
721 return $path;
722 }
723
724 function __PackageError()
725 {
726 echo '<span style="color:red;">';
727 foreach ($this->arErrors as $arError)
728 echo $arError[0]."<br />";
729 echo "</span>";
730 }
731
733 {
734 $descFile = $_SERVER["DOCUMENT_ROOT"].$this->path."/.description.php";
735
736 if (!is_file($descFile))
737 return false;
738
739 $this->IncludeWizardLang(".description.php");
740
741 $arWizardDescription = Array();
742 include($descFile);
743
744 $this->arDescription = $arWizardDescription;
745
746 return true;
747 }
748
749 function __CheckDepends()
750 {
751 $success = true;
752 if (array_key_exists("DEPENDENCIES", $this->arDescription) && is_array($this->arDescription["DEPENDENCIES"]))
753 {
754 $arModules = CWizardUtil::GetModules();
755
756 foreach ($this->arDescription["DEPENDENCIES"] as $module => $version)
757 {
758 if (!array_key_exists($module, $arModules))
759 {
760 $this->SetError(
761 str_replace("#MODULE#", htmlspecialcharsbx($module), GetMessage("MAIN_WIZARD_ERROR_MODULE_REQUIRED"))
762 );
763 $success = false;
764 }
765 elseif (!$arModules[$module]["IsInstalled"])
766 {
767 $this->SetError(
768 str_replace("#MODULE#", $arModules[$module]["MODULE_NAME"], GetMessage("MAIN_WIZARD_ERROR_MODULE_REQUIRED"))
769 );
770 $success = false;
771 }
772 elseif (!CheckVersion($arModules[$module]["MODULE_VERSION"], $version))
773 {
774 $this->SetError(
775 str_replace(Array("#MODULE#", "#VERSION#"),
776 Array($arModules[$module]["MODULE_NAME"], htmlspecialcharsbx($version)),
777 GetMessage("MAIN_WIZARD_ERROR_MODULE_REQUIRED2"))
778 );
779 $success = false;
780 }
781 }
782 }
783
784 return $success;
785 }
786
787 function __GetSites()
788 {
789 $siteFile = $_SERVER["DOCUMENT_ROOT"].$this->path."/.sites.php";
790 if (!is_file($siteFile))
791 return false;
792
793 $this->IncludeWizardLang(".sites.php");
794
795 $arWizardSites = Array();
796 include($siteFile);
797 $this->arSites = $arWizardSites;
798 }
799
801 {
802 $templatesPath = $this->path."/templates";
803 if (file_exists($_SERVER["DOCUMENT_ROOT"].$templatesPath."/".LANGUAGE_ID))
804 $templatesPath .= "/".LANGUAGE_ID;
805 return $templatesPath;
806 }
807
808 function __GetTemplates()
809 {
810 $settingFile = $_SERVER["DOCUMENT_ROOT"].$this->path."/.templates.php";
811 $arWizardTemplates = Array();
812 if (is_file($settingFile))
813 {
814 $this->IncludeWizardLang(".templates.php");
815 include($settingFile);
816 }
817
818 $relativePath = $this->__GetTemplatesPath();
819 $absolutePath = $_SERVER["DOCUMENT_ROOT"].$relativePath;
820 $absolutePath = str_replace("\\", "/", $absolutePath);
821
822 if ($handle = @opendir($absolutePath))
823 {
824 while(($dirName = @readdir($handle)) !== false)
825 {
826 if ($dirName == "." || $dirName == ".." || !is_dir($absolutePath."/".$dirName))
827 continue;
828
829 $arTemplate = Array(
830 "DESCRIPTION"=>"",
831 "NAME" => $dirName,
832 );
833
834 if (file_exists($absolutePath."/".$dirName."/description.php"))
835 {
836 if (LANGUAGE_ID != "en" && LANGUAGE_ID != "ru")
837 {
838 if (file_exists(($fname = $absolutePath."/".$dirName."/lang/".LangSubst(LANGUAGE_ID)."/description.php")))
839 __IncludeLang($fname, false, true);
840 }
841
842 if (file_exists(($fname = $absolutePath."/".$dirName."/lang/".LANGUAGE_ID."/description.php")))
843 __IncludeLang($fname, false, true);
844
845 include($absolutePath."/".$dirName."/description.php");
846 }
847
848 $arTemplate["ID"] = $dirName;
849 $arTemplate["PATH"] = $this->path."/".$dirName;
850 $arTemplate["SITE_ID"] = "";
851 $arTemplate["SORT"] = 0;
852 $arTemplate["GROUP_ID"] = "";
853
854 if (file_exists($absolutePath."/".$dirName."/screen.gif"))
855 $arTemplate["SCREENSHOT"] = $relativePath."/".$dirName."/screen.gif";
856 else
857 $arTemplate["SCREENSHOT"] = false;
858
859 if (file_exists($absolutePath."/".$dirName."/preview.gif"))
860 $arTemplate["PREVIEW"] = $relativePath."/".$dirName."/preview.gif";
861 else
862 $arTemplate["PREVIEW"] = false;
863
864 if (array_key_exists("TEMPLATES", $arWizardTemplates) && array_key_exists($dirName, $arWizardTemplates["TEMPLATES"]))
865 $arTemplate = array_merge($arTemplate, $arWizardTemplates["TEMPLATES"][$dirName]);
866
867 $this->arTemplates[$arTemplate["ID"]] = $arTemplate;
868 }
869 closedir($handle);
870 }
871
872 uasort(
873 $this->arTemplates,
874 function ($a, $b) {
875 return strcmp($a["SORT"], $b["SORT"]);
876 }
877 );
878
879 if (array_key_exists("GROUPS", $arWizardTemplates) && is_array($arWizardTemplates["GROUPS"]))
880 $this->arTemplateGroups = $arWizardTemplates["GROUPS"];
881 }
882
884 {
885 $instScript = $_SERVER["DOCUMENT_ROOT"].$this->path."/wizard.php";
886
887 if (!is_file($instScript))
888 return false;
889
890 $this->pathToScript = $instScript;
891 return true;
892 }
893
894 function __GetServices()
895 {
896 $serviceFile = $_SERVER["DOCUMENT_ROOT"].$this->path."/.services.php";
897 if (!is_file($serviceFile))
898 return false;
899
900 $this->IncludeWizardLang(".services.php");
901
902 $arWizardServices = Array();
903 include($serviceFile);
904 $this->arServices = $arWizardServices;
905 }
906
907 function __GetStructure()
908 {
909 $structureFile = $_SERVER["DOCUMENT_ROOT"].$this->path."/.structure.php";
910 if (!is_file($structureFile))
911 return false;
912
913 $this->IncludeWizardLang(".structure.php");
914
915 $arWizardStructure = Array();
916 include($structureFile);
917 $this->arStructure = $arWizardStructure;
918 }
919
921 {
922 if (!array_key_exists($siteID, $this->arSites))
923 return;
924
925 //If the main module was not included
926 require_once($_SERVER['DOCUMENT_ROOT']."/bitrix/modules/main/include.php");
927
928 //Copy files
929 $this->__MoveDirFiles($this->arSites[$siteID]);
930 }
931
933 {
934 if (!array_key_exists($templateID, $this->arTemplates))
935 return;
936
937 //Copy template
938 $canCopyTemplate = !(
939 file_exists($_SERVER["DOCUMENT_ROOT"].BX_PERSONAL_ROOT."/templates/".$templateID) &&
940 isset($this->arTemplates[$templateID]["REWRITE"]) && $this->arTemplates[$templateID]["REWRITE"] == "N"
941 );
942
943 //If the main module was not included
944 require_once($_SERVER['DOCUMENT_ROOT']."/bitrix/modules/main/include.php");
945
946 if ($canCopyTemplate)
947 {
949 $_SERVER["DOCUMENT_ROOT"].$this->__GetTemplatesPath()."/".$templateID,
950 $_SERVER["DOCUMENT_ROOT"].BX_PERSONAL_ROOT."/templates/".$templateID,
951 $rewrite = true,
952 $recursive = true
953 );
954 }
955
956 //Attach template to default site
957 $obSite = CSite::GetList("def", "desc", Array("ACTIVE" => "Y"));
958 if ($arSite = $obSite->Fetch())
959 {
960 $arTemplates = Array();
961 $found = false;
962 $obTemplate = CSite::GetTemplateList($arSite["LID"]);
963 while($arTemplate = $obTemplate->Fetch())
964 {
965 if(!$found && trim($arTemplate["CONDITION"]) == '')
966 {
967 $arTemplate["TEMPLATE"] = $templateID;
968 $found = true;
969 }
971 }
972
973 if (!$found)
974 $arTemplates[]= Array("CONDITION" => "", "SORT" => 150, "TEMPLATE" => $templateID);
975
976 $arFields = Array(
977 "TEMPLATE" => $arTemplates,
978 "NAME" => $arSite["NAME"],
979 );
980
981 $obSite = new CSite();
982 $obSite->Update($arSite["LID"], $arFields);
983 }
984
985 //Copy files
986 $this->__MoveDirFiles($this->arTemplates[$templateID]);
987 }
988
990 {
991 if (!array_key_exists($serviceID, $this->arServices))
992 return;
993
994 //If the main module was not included
995 require_once($_SERVER['DOCUMENT_ROOT']."/bitrix/modules/main/include.php");
996
997 //Copy files
998 $this->__MoveDirFiles($this->arServices[$serviceID]);
999 }
1000
1002 {
1003 global $APPLICATION;
1004
1005 if ($this->structureID == '')
1006 return;
1007
1008 $arStructure = $this->GetStructure(
1009 Array(
1010 "SERVICE_ID" => $this->serviceID,
1011 "SITE_ID" => $this->siteID
1012 )
1013 );
1014
1015 //If the main module was not included
1016 require_once($_SERVER['DOCUMENT_ROOT']."/bitrix/modules/main/include.php");
1017
1018 $arStructure = $this->__GetNewStructure($this->structureID, $arStructure);
1019
1020 function __CreateMenuItem($arPage)
1021 {
1022 return "\n".
1023 " Array(\n".
1024 " \"".$arPage["NAME"]."\", \n".
1025 " \"".$arPage["LINK"]."\", \n".
1026 " Array(), \n".
1027 " Array(), \n".
1028 " \"\"\n".
1029 " ),";
1030 }
1031
1032 function __GetFileName($fileName, $postFix)
1033 {
1034 if ($postFix == "")
1035 return $fileName;
1036
1037 $position = mb_strrpos($fileName, ".");
1038
1039 if ($position !== false)
1040 $fileName = mb_substr($fileName, 0, $position).$postFix.mb_substr($fileName, $position);
1041
1042 return $fileName;
1043 }
1044
1045 $rootMenuType = (isset($this->arStructure["SETTINGS"]) && isset($this->arStructure["SETTINGS"]["ROOT_MENU_TYPE"])
1046 ? $this->arStructure["SETTINGS"]["ROOT_MENU_TYPE"]
1047 : "top"
1048 );
1049 $childMenuType = (isset($this->arStructure["SETTINGS"]) && isset($this->arStructure["SETTINGS"]["CHILD_MENU_TYPE"])
1050 ? $this->arStructure["SETTINGS"]["CHILD_MENU_TYPE"]
1051 : "left"
1052 );
1053
1054 $strRootMenu = "";
1055 $arFileToMove = Array();
1056 $arPageCnt = Array();
1057 foreach ($arStructure as $rootPageID => $arPage)
1058 {
1059 //Item type "service"
1060 if (isset($arPage["TYPE"]) && mb_strtoupper($arPage["TYPE"]) == "SERVICE")
1061 {
1062 $strRootMenu .= __CreateMenuItem($arPage);
1063 }
1064 else
1065 {
1066 if (isset($arPage["CHILD"]) && is_array($arPage["CHILD"]) && !empty($arPage["CHILD"]))
1067 {
1068 $strLeftMenu = "";
1069
1070 if ( ($position = mb_strrpos($rootPageID, "-")) !== false)
1071 $rootPageID = mb_substr($rootPageID, $position + 1, mb_strlen($rootPageID));
1072
1073 //Root item
1074 $arFileToMove[] = Array(
1075 $_SERVER["DOCUMENT_ROOT"].$this->path."/".$arPage["FILE"],
1076 $_SERVER["DOCUMENT_ROOT"]."/".$rootPageID."/index.php"
1077 );
1078 $arPage["LINK"] = "/".$rootPageID."/";
1079 $strRootMenu .= __CreateMenuItem($arPage);
1080
1081 //Child items
1082 $arSubPageCnt = Array();
1083 foreach ($arPage["CHILD"] as $subPageID => $arSubPage)
1084 {
1085 $fileName = basename($arSubPage["FILE"]);
1086
1087 if (array_key_exists($fileName, $arSubPageCnt))
1088 (int)$arSubPageCnt[$fileName]++;
1089 else
1090 $arSubPageCnt[$fileName] = "";
1091
1092 $fileName = __GetFileName($fileName, $arSubPageCnt[$fileName]);
1093
1094 $arFileToMove[] = Array(
1095 $_SERVER["DOCUMENT_ROOT"].$this->path."/".$arSubPage["FILE"],
1096 $_SERVER["DOCUMENT_ROOT"]."/".$rootPageID."/".$fileName
1097 );
1098
1099 $arSubPage["LINK"] = "/".$rootPageID."/".$fileName;
1100 $strLeftMenu .= __CreateMenuItem($arSubPage);
1101 }
1102
1103 if ($strLeftMenu <> '')
1104 {
1105 $strSectionName = "\$sSectionName = \"".$arPage["NAME"]."\";\n";
1106 $APPLICATION->SaveFileContent($_SERVER["DOCUMENT_ROOT"]."/".$rootPageID."/.section.php", "<"."?\n".$strSectionName."?".">");
1107
1108 $strLeftMenu = "\$aMenuLinks = Array(".$strLeftMenu."\n);";
1109 $APPLICATION->SaveFileContent($_SERVER["DOCUMENT_ROOT"]."/".$rootPageID."/.".$childMenuType.".menu.php", "<"."?\n".$strLeftMenu."\n?".">");
1110 }
1111 }
1112 else
1113 {
1114 $fileName = basename($arPage["FILE"]);
1115
1116 if (array_key_exists($fileName, $arPageCnt))
1117 (int)$arPageCnt[$fileName]++;
1118 else
1119 $arPageCnt[$fileName] = "";
1120
1121 $fileName = __GetFileName($fileName, $arPageCnt[$fileName]);
1122
1123 $arFileToMove[] = Array(
1124 $_SERVER["DOCUMENT_ROOT"].$this->path."/".$arPage["FILE"],
1125 $_SERVER["DOCUMENT_ROOT"]."/".$fileName,
1126 );
1127
1128 $arPage["LINK"] = "/".$fileName;
1129 $strRootMenu .= __CreateMenuItem($arPage);
1130 }
1131 }
1132 }
1133
1134 //Save top menu
1135 if ($strRootMenu <> '')
1136 {
1137 $strRootMenu = "\$aMenuLinks = Array(".$strRootMenu."\n);";
1138 $APPLICATION->SaveFileContent($_SERVER["DOCUMENT_ROOT"]."/.".$rootMenuType.".menu.php", "<"."?\n".$strRootMenu."\n?".">");
1139 }
1140
1141 //Copy files for menu items
1142 foreach ($arFileToMove as $arFile)
1143 CopyDirFiles($arFile[0], $arFile[1]);
1144 }
1145
1146
1148 {
1149 $arPageIDs = explode("-", $pageID);
1150 $arResult = Array();
1151
1152 if (!isset($arPageIDs[0]) || !array_key_exists($arPageIDs[0], $arStructure))
1153 return Array();
1154
1155 $arResult = $arStructure[$arPageIDs[0]] + Array("ID" => $pageID);
1156
1157 if (isset($arPageIDs[1]))
1158 {
1159 if (!array_key_exists($arPageIDs[1], $arStructure[$arPageIDs[0]]["CHILD"]))
1160 return Array();
1161
1162 $arResult = $arStructure[$arPageIDs[0]]["CHILD"][$arPageIDs[1]] + Array("ID" => $pageID);
1163 }
1164
1165 unset($arResult["CHILD"]);
1166 return $arResult;
1167 }
1168
1170 {
1171 $arNewStructure = Array();
1172 $rootPageCnt = Array();
1173 $childNumber = "";
1174
1175 $arPages = explode(";", $structureID);
1176 foreach ($arPages as $page)
1177 {
1178 //Format: Item ID: Root ID
1179 if ($page == '')
1180 continue;
1181
1182 $pageID = $page;
1183 $rootID = false;
1184
1185 if ( ($position = mb_strpos($page, ":")) !== false)
1186 list($pageID, $rootID) = explode(":", $pageID);
1187
1188 $arPageProp = $this->__GetPageProperties($pageID, $arStructure);
1189 if (empty($arPageProp))
1190 continue;
1191
1192 if ($rootID == '')
1193 {
1194 if (array_key_exists($pageID, $arNewStructure))
1195 {
1196 $rootPageCnt[$pageID]++; //(int)$rootNumber++;
1197 $arNewStructure[$pageID.$rootPageCnt[$pageID]] = $arPageProp + Array("CHILD" => Array());
1198 }
1199 else
1200 {
1201 $arNewStructure[$pageID] = $arPageProp + Array("CHILD" => Array());
1202 $rootPageCnt[$pageID] = "";
1203 }
1204 }
1205 else
1206 {
1207 //Create child
1208 if (isset($rootPageCnt[$rootID]) && array_key_exists($rootID.$rootPageCnt[$rootID], $arNewStructure))
1209 {
1210 if (array_key_exists($pageID, $arNewStructure[$rootID.$rootPageCnt[$rootID]]["CHILD"]))
1211 {
1212 (int)$childNumber++;
1213 $arNewStructure[$rootID.$rootPageCnt[$rootID]]["CHILD"][$pageID.$childNumber] = $arPageProp;
1214 }
1215 else
1216 $arNewStructure[$rootID.$rootPageCnt[$rootID]]["CHILD"][$pageID] = $arPageProp;
1217 }
1218 else
1219 {
1220 if (array_key_exists($pageID, $arNewStructure[$rootID]["CHILD"]))
1221 {
1222 (int)$childNumber++;
1223 $arNewStructure[$rootID]["CHILD"][$pageID.$childNumber] = $arPageProp;
1224 }
1225 else
1226 $arNewStructure[$rootID]["CHILD"][$pageID] = $arPageProp;
1227 }
1228 }
1229 }
1230
1231 $arAddService = Array();
1232 foreach ($arStructure as $pageID => $arPage)
1233 {
1234 if (isset($arPage["TYPE"]) && $arPage["TYPE"] == "SERVICE" && !array_key_exists($pageID, $arNewStructure))
1235 $arAddService[$pageID] = $arPage;
1236 }
1237
1238 return $arNewStructure + $arAddService;
1239 }
1240
1241
1242
1244 {
1245 if (!is_array($arFiles) || !array_key_exists("FILES", $arFiles))
1246 return;
1247
1248 foreach ($arFiles["FILES"] as $arFile)
1249 {
1250 //Delete
1251 if (array_key_exists("DELETE", $arFile) && $arFile["DELETE"] <> '')
1252 {
1253 if ($arFile["DELETE"] == "/" || $arFile["DELETE"] == "/bitrix" || $arFile["DELETE"] == "/bitrix/")
1254 continue;
1255
1256 DeleteDirFilesEx($arFile["DELETE"]);
1257 continue;
1258 }
1259
1260 //Copy
1261 if (!array_key_exists("FROM", $arFile) && !array_key_exists("TO", $arFile))
1262 continue;
1263
1264 $rewrite = (array_key_exists("REWRITE", $arFile) && $arFile["REWRITE"] == "N" ? false : true);
1265 $recursive = (array_key_exists("RECURSIVE", $arFile) && $arFile["RECURSIVE"] == "N" ? false : true);
1266
1267 $arFile["TO"] = Rel2Abs("/", $arFile["TO"]);
1268
1270 $_SERVER["DOCUMENT_ROOT"].$this->path."/".$arFile["FROM"],
1271 $_SERVER["DOCUMENT_ROOT"].$arFile["TO"],
1272 $rewrite,
1273 $recursive
1274 );
1275 }
1276 }
1277
1278 /* Public methods */
1279
1280 function GetID()
1281 {
1282 return $this->name;
1283 }
1284
1285 function GetPath()
1286 {
1287 return $this->path;
1288 }
1289
1290
1291 function SetError($strError, $id = false)
1292 {
1293 $this->arErrors[] = Array($strError, $id);
1294 }
1295
1296 function GetErrors()
1297 {
1298 return $this->arErrors;
1299 }
1300
1301 /* Public site builder methods*/
1302
1304 {
1305 return $this->templateID;
1306 }
1307
1309 {
1310 return $this->groupID;
1311 }
1312
1313 function GetSiteID()
1314 {
1315 return $this->siteID;
1316 }
1317
1319 {
1320 return $this->serviceID;
1321 }
1322
1324 {
1325 return $this->arDescription;
1326 }
1327
1328
1329 function GetTemplateGroups($arFilter = Array())
1330 {
1331 $arResult = Array();
1332 $siteID = (array_key_exists("SITE_ID", $arFilter) ? $arFilter["SITE_ID"] : null);
1333
1334 if (empty($arFilter) || $siteID == null)
1336
1337 foreach ($this->arTemplateGroups as $groupID => $arGroup)
1338 {
1339 if (is_array($arGroup["SITE_ID"]) && in_array($siteID, $arGroup["SITE_ID"]))
1340 $arResult[$groupID] = $arGroup;
1341 elseif ($arGroup["SITE_ID"] === $siteID)
1342 $arResult[$groupID] = $arGroup;
1343 }
1344
1345 return $arResult;
1346 }
1347
1348 function GetTemplates($arFilter = Array())
1349 {
1350 $arResult = Array();
1351 $siteID = (array_key_exists("SITE_ID", $arFilter) ? $arFilter["SITE_ID"] : null);
1352 $groupID = (array_key_exists("GROUP_ID", $arFilter) ? $arFilter["GROUP_ID"] : null);
1353
1354 if (empty($arFilter) || ($siteID == null && $groupID == null))
1355 return $this->arTemplates;
1356
1357 foreach ($this->arTemplates as $arTemplate)
1358 {
1359 if (is_array($arTemplate["SITE_ID"]) && in_array($siteID, $arTemplate["SITE_ID"]))
1361 elseif ($arTemplate["SITE_ID"] === $siteID)
1363 elseif (is_array($arTemplate["GROUP_ID"]) && in_array($groupID, $arTemplate["GROUP_ID"]))
1365 elseif ($arTemplate["GROUP_ID"] === $groupID)
1367 }
1368
1369 return $arResult;
1370 }
1371
1372
1373 function GetServices($arFilter = Array())
1374 {
1375 $siteID = (array_key_exists("SITE_ID", $arFilter) ? $arFilter["SITE_ID"] : null);
1376
1377 if (empty($arFilter) || $siteID == null)
1378 return $this->arServices;
1379
1380 $arResult = Array();
1381 foreach ($this->arServices as $serviceID => $arService)
1382 {
1383 if (!array_key_exists("SITE_ID",$arService))
1384 continue;
1385
1386 if (is_array($arService["SITE_ID"]) && in_array($siteID, $arService["SITE_ID"]))
1387 $arResult[$serviceID] = $arService;
1388 elseif ($arService["SITE_ID"] == $siteID)
1389 $arResult[$serviceID] = $arService;
1390 }
1391
1392 return $arResult;
1393 }
1394
1395
1396 function GetStructure($arFilter = Array())
1397 {
1398 $arResult = Array();
1399
1400 if (!isset($this->arStructure["STRUCTURE"]) || !is_array($this->arStructure["STRUCTURE"]))
1401 return $arResult;
1402
1403 $serviceID = (array_key_exists("SERVICE_ID", $arFilter) ? $arFilter["SERVICE_ID"] : null);
1404 $siteID = (array_key_exists("SITE_ID", $arFilter) ? $arFilter["SITE_ID"] : null);
1405
1406 if (empty($arFilter) || ($serviceID == null && $siteID == null))
1407 return $this->arStructure["STRUCTURE"];
1408
1409 if (!is_array($serviceID) && $serviceID !== null)
1410 $serviceID = Array($serviceID);
1411
1412 if (!is_array($siteID) && $siteID !== null)
1413 $siteID = Array($siteID);
1414
1415 foreach ($this->arStructure["STRUCTURE"] as $pageID => $arPage)
1416 {
1417 if (array_key_exists("SERVICE_ID",$arPage) && $serviceID !== null)
1418 {
1419 $result = array_intersect(!is_array($arPage["SERVICE_ID"]) ? Array($arPage["SERVICE_ID"]) : $arPage["SERVICE_ID"], $serviceID);
1420 if (!empty($result))
1421 {
1422 $arResult[$pageID] = $arPage;
1423 continue;
1424 }
1425 }
1426
1427 if (array_key_exists("SITE_ID",$arPage) && $siteID !== null)
1428 {
1429 $result = array_intersect(!is_array($arPage["SITE_ID"]) ? Array($arPage["SITE_ID"]) : $arPage["SITE_ID"], $siteID);
1430 if (!empty($result))
1431 {
1432 $arResult[$pageID] = $arPage;
1433 continue;
1434 }
1435 }
1436 }
1437
1438 return $arResult;
1439 }
1440
1441 function IncludeWizardLang($relativePath = "", $lang = false)
1442 {
1443 if ($lang === false)
1444 $lang = LANGUAGE_ID;
1445
1446 $wizardPath = $_SERVER["DOCUMENT_ROOT"].$this->path;
1447
1448 if ($lang != "en" && $lang != "ru")
1449 {
1450 $subst_lang = LangSubst($lang);
1451 $fname = $wizardPath."/lang/".$subst_lang."/".$relativePath;
1452 $fname = \Bitrix\Main\Localization\Translation::convertLangPath($fname, $subst_lang);
1453 if (file_exists($fname))
1454 {
1455 __IncludeLang($fname, false, true);
1456 }
1457 }
1458
1459 $fname = $wizardPath."/lang/".$lang."/".$relativePath;
1461 if (file_exists($fname))
1462 {
1463 __IncludeLang($fname, false, true);
1464 }
1465 }
1466
1467}
1468
1469?>
global $APPLICATION
Определения include.php:80
$arResult
Определения generate_coupon.php:16
static convertLangPath($langFile, $language)
Определения translation.php:267
Определения wizard.php:11
Определения wizard_site.php:19
__GetLicensePath()
Определения wizard_site.php:711
$structureExists
Определения wizard_site.php:45
__CheckDepends()
Определения wizard_site.php:749
$arTemplateGroups
Определения wizard_site.php:26
GetTemplateGroups($arFilter=Array())
Определения wizard_site.php:1329
$path
Определения wizard_site.php:21
$templateSelected
Определения wizard_site.php:48
__GetNewStructure($structureID, &$arStructure)
Определения wizard_site.php:1169
GetSiteGroupID()
Определения wizard_site.php:1308
GetPath()
Определения wizard_site.php:1285
__InstallTemplate($templateID)
Определения wizard_site.php:932
$wizard
Определения wizard_site.php:22
GetSiteTemplateID()
Определения wizard_site.php:1303
__GetTemplatesPath()
Определения wizard_site.php:800
$arErrors
Определения wizard_site.php:30
$structureID
Определения wizard_site.php:38
$__obLastStep
Определения wizard_site.php:53
$arServices
Определения wizard_site.php:27
$siteSelected
Определения wizard_site.php:47
$groupID
Определения wizard_site.php:36
_SetNextStep($obStep, $currentStep, $stepType="select")
Определения wizard_site.php:534
__GetTemplates()
Определения wizard_site.php:808
__GetSites()
Определения wizard_site.php:787
__GetDescription()
Определения wizard_site.php:732
$templateExists
Определения wizard_site.php:43
$arSites
Определения wizard_site.php:24
SetError($strError, $id=false)
Определения wizard_site.php:1291
$siteID
Определения wizard_site.php:34
GetErrors()
Определения wizard_site.php:1296
__InitVariables()
Определения wizard_site.php:511
__MoveDirFiles(&$arFiles)
Определения wizard_site.php:1243
$groupExists
Определения wizard_site.php:42
$templateID
Определения wizard_site.php:35
__GetPageProperties($pageID, &$arStructure)
Определения wizard_site.php:1147
$__obFirstStep
Определения wizard_site.php:54
GetStructure($arFilter=Array())
Определения wizard_site.php:1396
GetSiteID()
Определения wizard_site.php:1313
$arStructure
Определения wizard_site.php:29
__InstallStructure()
Определения wizard_site.php:1001
GetSiteServiceID()
Определения wizard_site.php:1318
__construct($wizardName)
Определения wizard_site.php:56
$siteExists
Определения wizard_site.php:41
$pathToScript
Определения wizard_site.php:32
__GetStructure()
Определения wizard_site.php:907
_InitSubStep($stepType, &$arInstallation, $bInitStep=true)
Определения wizard_site.php:577
$name
Определения wizard_site.php:20
__SetTemplate()
Определения wizard_site.php:458
__PackageError()
Определения wizard_site.php:724
__GetInstallationScript()
Определения wizard_site.php:883
$licenseExists
Определения wizard_site.php:40
__GetUserStep($stepName, &$step)
Определения wizard_site.php:665
GetTemplates($arFilter=Array())
Определения wizard_site.php:1348
$structureSelected
Определения wizard_site.php:50
Install()
Определения wizard_site.php:80
$serviceExists
Определения wizard_site.php:44
__InstallService($serviceID)
Определения wizard_site.php:989
GetID()
Определения wizard_site.php:1280
IncludeWizardLang($relativePath="", $lang=false)
Определения wizard_site.php:1441
GetServices($arFilter=Array())
Определения wizard_site.php:1373
$arTemplates
Определения wizard_site.php:25
__SetStepDescription($obStep, $stepName)
Определения wizard_site.php:696
$arDescription
Определения wizard_site.php:28
$__bInited
Определения wizard_site.php:52
GetDescription()
Определения wizard_site.php:1323
$serviceID
Определения wizard_site.php:37
__GetServices()
Определения wizard_site.php:894
__Install()
Определения wizard_site.php:138
$serviceSelected
Определения wizard_site.php:49
__InstallSite($siteID)
Определения wizard_site.php:920
static CheckName($wizardName)
Определения wizard_util.php:17
static GetRepositoryPath()
Определения wizard_util.php:4
static MakeWizardPath($wizardName)
Определения wizard_util.php:9
static GetModules()
Определения wizard_util.php:346
$arTemplate
Определения component_props.php:26
$arFields
Определения dblapprove.php:5
$absolutePath
Определения folder_edit.php:53
$handle
Определения include.php:55
$result
Определения get_property_values.php:14
$strError
Определения options_user_settings.php:4
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
$success
Определения mail_entry.php:69
if(!defined('SITE_ID')) $lang
Определения include.php:91
CheckVersion($version1, $version2)
Определения tools.php:5319
LangSubst($lang)
Определения tools.php:3854
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
DeleteDirFilesEx($path, $root=null)
Определения tools.php:2823
Rel2Abs($curdir, $relpath)
Определения tools.php:3297
CopyDirFiles($path_from, $path_to, $ReWrite=true, $Recursive=false, $bDeleteAfterCopy=false, $strExclude="")
Определения tools.php:2732
GetMessage($name, $aReplace=null)
Определения tools.php:3397
__IncludeLang($path, $bReturnArray=false, $bFileChecked=false)
Определения tools.php:3477
$service
Определения payment.php:18
$arFiles
Определения options.php:60
return false
Определения prolog_main_admin.php:185
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$fileName
Определения quickway.php:305
$page
Определения order_form.php:33
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
else $a
Определения template.php:137
path
Определения template_copy.php:201
$arFilter
Определения user_search.php:106
const BX_WIZARD_INSTALL_STRUCTURE_ID
Определения wizard_site.php:14
const BX_WIZARD_LICENSE_ID
Определения wizard_site.php:4
const BX_WIZARD_INSTALL_TEMPLATE_ID
Определения wizard_site.php:12
const BX_WIZARD_SELECT_GROUP_ID
Определения wizard_site.php:6
const BX_WIZARD_SELECT_SERVICE_ID
Определения wizard_site.php:8
const BX_WIZARD_SELECT_TEMPLATE_ID
Определения wizard_site.php:7
const BX_WIZARD_FINISH_ID
Определения wizard_site.php:15
const BX_WIZARD_SELECT_STRUCTURE_ID
Определения wizard_site.php:9
const BX_WIZARD_WELCOME_ID
Определения wizard_site.php:3
const BX_WIZARD_START_INSTALL_ID
Определения wizard_site.php:10
const BX_WIZARD_SELECT_SITE_ID
Определения wizard_site.php:5
const BX_WIZARD_INSTALL_SERVICE_ID
Определения wizard_site.php:13
const BX_WIZARD_INSTALL_SITE_ID
Определения wizard_site.php:11
const BX_WIZARD_CANCEL_ID
Определения wizard_site.php:16