GetVars
Описание и параметры
void GetVars( bool useDefault = false );
Метод возвращает массив значений всех переменных мастера. Если параметр useDefault установлен в значение true, то переменные, значения для которых не установлены, будут иметь значения по умолчанию.
Параметры функции
| Параметр | Описание |
|---|---|
| useDefault | Устанавливать значения по умолчанию. Необязательный параметр, по умолчанию равен false. |
Смотрите также
Примеры использования
<?
if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
class Step1 extends CWizardStep
{
function InitStep()
{
//Настройки шага
$this->SetTitle("Множественный checkbox");
$this->SetNextStep("step2");
$this->SetStepID("step1");
$this->SetCancelStep("final");
$this->SetFinishStep("step4");
//Получаем ссылку на объект мастера
$wizard = &$this->GetWizard();
//Устанавливаем для переменной vote[car] значение по умолчанию
$wizard->SetDefaultVar("vote[car]", "reno");
//Устанавливаем значения по умолчанию нескольким переменным
$wizard->SetDefaultVars(
Array(
"vote[country]" => Array("poland", "lietva"),
"subject" => "history",
)
);
}
function ShowStep()
{
$wizard = &$this->GetWizard();
$this->content = "В каких странах вы были?<br />";
$this->content .= $this->ShowCheckboxField("vote[country][]", "russia")." Россия<br />";
$this->content .= $this->ShowCheckboxField("vote[country][]", "usa")." США<br />";
$this->content .= $this->ShowCheckboxField("vote[country][]", "poland")." Польша<br />";
$this->content .= $this->ShowCheckboxField("vote[country][]", "lietva")." Литва<br />";
$this->content .= "<br />Ваши любимые марки авто?<br />";
$this->content .= $this->ShowCheckboxField("vote[car][]", "bmw")." BMW<br />";
$this->content .= $this->ShowCheckboxField("vote[car][]", "hyundai")." Hyundai<br />";
$this->content .= $this->ShowCheckboxField("vote[car][]", "vaz")." Ваз<br />";
$this->content .= $this->ShowCheckboxField("vote[car][]", "reno")." Рено<br />";
$this->content .= "<br />Какие науки Вас интересуют?<br />";
$this->content .= $this->ShowCheckboxField("subject[]", "math")." Математика<br />";
$this->content .= $this->ShowCheckboxField("subject[]", "history")." История<br />";
$this->content .= $this->ShowCheckboxField("subject[]", "programming")." Программирование<br />";
$this->content .= $this->ShowCheckboxField("subject[]", "physics")." Физика<br />";
//Устанавливаем переменную myVar.
//Значение будет доступно на следующем шаге
$wizard->SetVar("myVar", Array("AAA", "BBB", "CCC"));
}
}
class Step2 extends CWizardStep
{
function InitStep()
{
//Настройки шага
$this->SetTitle("Шаг отладки");
$this->SetSubTitle("Смотрим переменные");
$this->SetPrevStep("step1");
$this->SetNextStep("step3");
$this->SetStepID("step2");
$this->SetCancelStep("final");
$this->SetFinishStep("step4");
}
function ShowStep()
{
$wizard = &$this->GetWizard();
$this->content .= "Переменная vote[car]: ".print_r($wizard->GetVar("vote[car]"), true)."<br />";
$this->content .= "Значение по умолчанию для vote[car]: ".print_r($wizard->GetDefaultVar("vote[car]"), true)."<br />";
$this->content .= "Значение всех переменных мастера:";
$this->content .= "<pre>".print_r($wizard->GetVars(), true)."</pre>";
}
}
class Step3 extends CWizardStep
{
function InitStep()
{
$this->SetPrevStep("step2");
$this->SetNextStep("step4");
$this->SetStepID("step3");
$this->SetCancelStep("final");
$this->SetFinishStep("step4");
$this->SetTitle("Множественный select с дефолтными значениями");
$wizard = &$this->GetWizard();
$wizard->SetDefaultVars(
Array(
"operation[os]" => Array("windows"),
"mathematics[twoandwo]" => Array("four", "twotwo"),
)
);
}
function ShowStep()
{
$wizard = &$this->GetWizard();
//Уничтожаем переменную myVar
$wizard->UnSetVar("myVar");
$this->content = "Какая ОС стоит на вашем рабочем компьютере?<br />";
$this->content .= $this->ShowSelectField(
"operation[os][]",
Array(
"linux" => "Linux",
"windows" => "Windows",
"freebsd" => "FreeBSD",
"macos" => "MacOS",
"dos" => "MS DOS",
),
Array("multiple" => "multiple")
);
$this->content .= "<br /><br />Сколько будет 2+2?<br />";
$this->content .= $this->ShowSelectField(
"mathematics[twoandwo][]",
Array(
"four" => "Четыре",
"five" => "Пять",
"twotwo" => "Двадцать два",
"two_plus_two" => "Два плюс Два",
),
Array("multiple" => "multiple")
);
}
}
class Step4 extends CWizardStep
{
function InitStep()
{
$this->SetPrevStep("step3");
$this->SetStepID("step4");
$this->SetTitle("Шаг отладки");
$this->SetSubTitle("Смотрим переменные");
$this->SetCancelStep("final");
}
function ShowStep()
{
$wizard = &$this->GetWizard();
$this->content .= "Переменные мастера с учётом дефолтных значений:";
$this->content .= "<pre>".print_r($wizard->GetVars($useDefault = true), true)."</pre>";
}
}
class FinalStep extends CWizardStep
{
function InitStep()
{
$this->SetStepID("final");
$this->SetTitle("Финиш");
$this->SetCancelStep("final");
}
function ShowStep()
{
$this->content = "Последний шаг";
}
}
?>
Описание классов в файле .description.php
<?
if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
$arWizardDescription = Array(
"NAME" => "Дефотные значения",
"STEPS" => Array("Step1", "Step15", "Step2", "Step3", "Step4", "Step5", "FinalStep"),
);
?>
© «Битрикс», 2001-2025, «1С-Битрикс», 2025