public function display($vars) { $disp = new Display(); if (!$vars || is_array($vars) && !count($vars)) { $vars = array('dumb', 'dumber'); } $disp->setFilter($vars, '$$'); if (Application::formPosted()) { $params = Application::post(); } else { $params = ''; } $disp->setValue('form_name', $this->name); $disp->setValue('form_action', Display::current()->hrefString($this->handler)); foreach ($this->inputs as $inp) { if (!$this->clear) { $name = $inp->name(); if ($inp->valueOverride()) { $value = $inp->value(); } else { if ($params) { $value = Form::getValueFromArray($name, $params); } else { $value = $inp->value(); } } } else { $value = ''; } if ($inp->allowsOptions()) { if ($value === '' && !$this->clear) { $value = $inp->selected; } $inp->setSelected($value); $options = $inp->generateInputObjects(); $disp->setValue($inp->name() . '_options', $options); } else { if ($inp->getClass() == 'FileInput' || $inp->getClass() == 'ImageInput') { $disp->setValue($inp->name() . '_existing_file', $inp->value()); } else { if ($inp->getClass() == 'DateInput') { if ($params && $value !== '') { $day = ArrayUtility::getArrayValue($value, 'day'); $month = ArrayUtility::getArrayValue($value, 'month'); $year = ArrayUtility::getArrayValue($value, 'year'); } else { if ($value !== '') { //$inp->setValue($value); $day = $inp->day(); $month = $inp->month(); $year = $inp->year(); } else { if (!$this->clear) { $day = $inp->day(); $month = $inp->month(); $year = $inp->year(); } else { $year = ''; $month = ''; $day = ''; } } } $disp->setValue($inp->name() . '_year_value', $year); $disp->setValue($inp->name() . '_month_value', $month); $disp->setValue($inp->name() . '_day_value', $day); } else { if ($value === '' && !is_numeric($value) && !$this->clear || $inp instanceof HiddenInput && !$this->clear) { $value = $inp->value(); } $disp->setValue($inp->name() . '_value', $value); } } } } $new_path = ''; if (is_array($vars) && count($vars)) { $path = Application::CACHE . Form::cachePath($this->initPath()) . '.t'; $new_path = Application::CACHE . 'dead-' . time() . '-' . Form::cachePath($this->initPath()) . '.t'; $data = file_get_contents($path); foreach ($vars as $name => $value) { $data = str_replace('$$' . strtoupper(str_replace('-', '_', $name)) . '$$', $value, $data); } $data = preg_replace('/\\$\\$[A-Z_]*\\$\\$/', '', $data); @unlink($new_path); file_put_contents($new_path, $data); chmod($new_path, 0664); $path = $new_path; } else { $path = Application::CACHE . Form::cachePath($this->initPath()) . '.t'; } foreach ($this->widgets() as $widg) { $widg->registerJavascript($disp); } $disp->displayPage($path); if ($new_path) { unlink($new_path); } }