function DrawEditorForm($name = '', $url = '.?', $init = true, $title = 'Сохранить') { $n = count($this->fields); ?> <script language="JavaScript" type="text/javascript"> function <?php echo $name; ?> _check (frm) { <?php for ($i = 0; $i < $n; $i++) { $f = $this->fields[$i]; if ($f->GetInvisibility()) { continue; } if ($f->GetImportancy()) { ?> if (!<?php echo $f->BuildCheckImportancy($name); ?> ) { alert ('Пропущено обязательное поле "<?php echo $f->GetTitle(); ?> "'); return false}; <?php } } ?> submit (frm); } </script> <form action="<?php echo $url; ?> &action=save" method="POST" name="<?php echo $name; ?> " onsubmit="<?php echo $name; ?> _check (this); return false;" enctype="multipart/form-data"> <?php $printed = false; for ($i = 0; $i < $n; $i++) { if ($this->fields[$i]->GetInvisibility()) { continue; } if ($printed) { print '<div id="hr"></div>'; } print '<b>' . $this->fields[$i]->GetTitle() . '</b>'; print $this->fields[$i]->DrawEditorForm($name, $init) . "\n"; $printed = true; } ?> <script language="JavaScript" type="text/javascript"> function submit (frm) { <?php $tmp = handler_get_list('editor_form'); $arr = $tmp['onsubmit']; for ($i = 0; $i < count($arr); $i++) { ?> <?php echo handler_build_callback($arr[$i]); ?> <?php } ?> frm.submit (); } </script> <div class="formPast"><button class="submitBtn block" type="submit"><?php echo $title; ?> </button></div> </form> <?php }
function Problem_GenerateEditorForm($data = array(), $act = 'create', $backlink = '') { global $INFORMATICS_ProblemSettingsFields, $pageid, $id, $promtadd; $fields = $INFORMATICS_ProblemSettingsFields; $action = prepare_arg('.?page=prbmanager&action=' . $act . ($id != '' ? '&id=' . $id : '') . '&' . ($pageid != '' ? 'pageid=' . $pageid : '') . ($promtadd != '' ? '&promtadd=' . $promtadd : '') . ($backlink != '' ? '&redirect=' . urlencode($backlink) : '')); $desc = $data['desc']; if ($desc == '') { $tpl = manage_template_by_name('Олимпиады / Informatics / Заготовка условия задачи'); $desc = $tpl->GetText(); } $iframe = iframe_editor('desc', $desc, $backlink != '', 'ProblemSettings', $this->gateway->content_settings['iframe']); $tmp = handler_get_list('ProblemSettings'); $arr = $tmp['onsubmit']; $onsubmit = ''; for ($i = 0; $i < count($arr); $i++) { $onsubmit .= ' ' . handler_build_callback($arr[$i]); } $form = new CVCForm(); $form->Init('ProblemSettings', 'method=POST;enctype=multipart/form-data;action=' . $action . ';titlewidth=160;caption=' . ($act == 'create' ? 'Создать' : 'Сохранить') . ';onsubmit=' . prepare_arg($onsubmit) . ';backlink=' . prepare_arg($backlink) . ';'); for ($i = 0, $n = count($fields); $i < $n; $i++) { $f = $fields[$i]; if ($f['action'] != '' && $f['action'] != $act) { continue; } $v = $data[$f['name']]; if (strtolower($f['type']) == 'custom') { $v = array('src' => $f['src'], 'value' => $v, 'check_value' => $f['check_value']); } $form->AppendField($f['title'], $f['postname'], $f['type'], $v, array('important' => $f['important'])); } if ($act != 'create') { $form->AppendField('Состояние', '', 'CUSTOM', array('src' => $this->Template('problems.state', array('data' => $data)))); } if (isset($promtadd)) { $form->AppendCheckBoxField('Добавить на контест', 'addToContest', false); } $form->AppendCustomField(array('src' => '<center><b>Условие задачи</b>' . $iframe . '</center>')); return $form; }
function get_body_handlers() { return handler_get_list('body'); }