Пример #1
0
 function TaskForm($args)
 {
     parent::__construct();
     /* General form setup and test some properties */
     $this->setup('task-form', ANEWT_FORM_METHOD_POST, Request::url(true));
     //$this->set('error', 'This is a general form error.');
     //$this->set('description', 'This is the form\'s description.');
     $ctl =& new AnewtFormControlText('id');
     $ctl->set('label', 'Task id:');
     $ctl->set('secondary-label', '(assigned automatically)');
     $ctl->set('readonly', true);
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlChoice('state');
     $ctl->set('label', 'State:');
     $ctl->add_option_value_label('enabled', 'enabled');
     $ctl->add_option_value_label('disabled', 'disabled');
     $ctl->set('value', 'enabled');
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlText('type');
     $ctl->set('label', 'Type:');
     $ctl->set('secondary-label', '(e.g.: fetch, index)');
     $ctl->set('value', 'fetch');
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlText('program');
     $ctl->set('label', 'Program:');
     $ctl->set('secondary-label', '(e.g.: feedworker.py)');
     $ctl->set('size', 100);
     $ctl->set('value', 'feedworker.py');
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlText('args');
     $ctl->set('label', 'Arguments:');
     $ctl->set('secondary-label', '(arguments that will be passed to the program)');
     $ctl->set('size', 100);
     $ctl->set('value', '-u \'...\'');
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlText('hostname');
     $ctl->set('label', 'Host restriction:');
     $ctl->set('secondary-label', '(allow:HOSTNAME or deny:HOSTNAME)');
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlText('periodicity');
     $ctl->set('label', 'Periodicity:');
     $ctl->set('secondary-label', '(interval to run jobs for this task; e.g., 00:15:00 for "every 15 minutes")');
     $ctl->set('value', '00:15:00');
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlChoice('autoperiodicity');
     $ctl->set('label', 'Auto-adjust periodicity:');
     $ctl->add_option_value_label('enabled', 'enabled');
     $ctl->add_option_value_label('disabled', 'disabled');
     $ctl->set('disabled', true);
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlText('hour');
     $ctl->set('label', 'Hour:');
     $ctl->set('secondary-label', '(specific hour to run jobs for this task)');
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlText('minute');
     $ctl->set('label', 'Minute:');
     $ctl->set('secondary-label', '(specific minute to run jobs for this task)');
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlText('second');
     $ctl->set('label', 'Second:');
     $ctl->set('secondary-label', '(specific second to run jobs for this task)');
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlText('latest_run');
     $ctl->set('label', 'Latest run:');
     $ctl->set('secondary-label', '(datatime when a job was last run for the task)');
     $ctl->set('readonly', true);
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlText('resource_id');
     $ctl->set('label', 'Resource id:');
     $ctl->set('secondary-label', '(id of the resource assigned to this task)');
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlText('data');
     $ctl->set('label', 'Extra data:');
     $ctl->set('secondary-label', '(anything that might in principle be used by the program running jobs)');
     $ctl->set('size', 100);
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlButtonSubmit('submit');
     $ctl->set('label', 'Save task');
     $this->add_control($ctl);
 }
Пример #2
0
 function FeedForm($args)
 {
     parent::__construct();
     /* General form setup and test some properties */
     $this->setup('feed-form', ANEWT_FORM_METHOD_POST, Request::url(true));
     //$this->set('error', 'This is a general form error.');
     //$this->set('description', 'This is the form\'s description.');
     $ctl =& new AnewtFormControlText('id');
     $ctl->set('label', 'Feed id:');
     $ctl->set('secondary-label', '(assigned automatically)');
     $ctl->set('readonly', true);
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlText('url');
     $ctl->set('label', 'Feed URL:');
     $ctl->set('secondary-label', '(should point to an RSS/Atom feed)');
     $ctl->set('size', 100);
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlChoice('m_kind');
     $ctl->set('label', 'Kind:');
     $ctl->add_option_value_label('full', 'full');
     $ctl->add_option_value_label('partial', 'partial (permalinks will be fetched for items)');
     $ctl->set('value', 'full');
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlText('m_partial_args');
     $ctl->set('label', 'Permalink fetching args:');
     $ctl->set('size', 50);
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlText('m_tags');
     $ctl->set('label', 'Tags:');
     $ctl->set('size', 50);
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlText('m_language');
     $ctl->set('label', 'Language:');
     $ctl->set('secondary-label', '(optional)');
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlChoice('m_class');
     $ctl->set('label', 'Class:');
     $ctl->add_option_value_label('text', 'text');
     $ctl->add_option_value_label('audio', 'audio');
     $ctl->add_option_value_label('video', 'video');
     $ctl->set('value', 'text');
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlText('t_id');
     $ctl->set('label', 'Task id:');
     $ctl->set('secondary-label', '(assigned automatically)');
     $ctl->set('readonly', true);
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlChoice('t_state');
     $ctl->set('label', 'State:');
     $ctl->add_option_value_label('enabled', 'enabled');
     $ctl->add_option_value_label('disabled', 'disabled');
     $ctl->set('value', 'enabled');
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlText('t_type');
     $ctl->set('label', 'Type:');
     $ctl->set('secondary-label', '(e.g.: fetch, index)');
     $ctl->set('value', 'fetch');
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlText('t_program');
     $ctl->set('label', 'Program:');
     $ctl->set('secondary-label', '(e.g.: feedworker.py)');
     $ctl->set('size', 100);
     $ctl->set('value', 'feedworker.py');
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlText('t_args');
     $ctl->set('label', 'Arguments:');
     $ctl->set('secondary-label', '(assigned automatically, unless modified manually)');
     $ctl->set('size', 100);
     $ctl->set('value', $this->default_t_args);
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlText('t_hostname');
     $ctl->set('label', 'Host restriction:');
     $ctl->set('secondary-label', '(allow:HOSTNAME or deny:HOSTNAME)');
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlText('t_periodicity');
     $ctl->set('label', 'Periodicity:');
     $ctl->set('secondary-label', '(interval to run jobs for this task; e.g., 00:15:00 for "every 15 minutes")');
     $ctl->set('value', '00:15:00');
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlChoice('t_autoperiodicity');
     $ctl->set('label', 'Auto-adjust periodicity:');
     $ctl->add_option_value_label('enabled', 'enabled');
     $ctl->add_option_value_label('disabled', 'disabled');
     $ctl->set('disabled', true);
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlText('t_hour');
     $ctl->set('label', 'Hour:');
     $ctl->set('secondary-label', '(specific hour to run jobs for this task)');
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlText('t_minute');
     $ctl->set('label', 'Minute:');
     $ctl->set('secondary-label', '(specific minute to run jobs for this task)');
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlText('t_second');
     $ctl->set('label', 'Second:');
     $ctl->set('secondary-label', '(specific second to run jobs for this task)');
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlText('t_latest_run');
     $ctl->set('label', 'Latest run:');
     $ctl->set('secondary-label', '(datatime when a job was last run for the task)');
     $ctl->set('readonly', true);
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlText('t_resource_id');
     $ctl->set('label', 'Resource id:');
     $ctl->set('secondary-label', '(id of the resource assigned to this task)');
     $this->add_control($ctl);
     $ctl =& new AnewtFormControlText('t_data');
     $ctl->set('label', 'Extra data:');
     $ctl->set('secondary-label', '(anything that might in principle be used by the program running jobs)');
     $ctl->set('size', 100);
     $this->add_control($ctl);
     // cleanup parameters
     $fieldset_cleanup = new AnewtFormFieldset('feed-auto');
     $fieldset_cleanup->set('label', 'HTML model-based cleaning parameters');
     $ctl =& new AnewtFormControlChoice('m_cleanup');
     $ctl->set('label', 'Apply cleaning:');
     $ctl->add_option_value_label('enabled', 'enabled');
     $ctl->add_option_value_label('disabled', 'disabled');
     $ctl->set('enabled', false);
     $fieldset_cleanup->add_control($ctl);
     $ctl =& new AnewtFormControlText('m_cleanup_threshold');
     $ctl->set('label', 'Threshold:');
     $ctl->set('secondary-label', '(number between 0.0 and 1.0; higher value = more conservative cleanup)');
     $ctl->set('value', '0.1');
     $fieldset_cleanup->add_control($ctl);
     $ctl =& new AnewtFormControlText('m_cleanup_train_size');
     $ctl->set('label', 'Training size:');
     $ctl->set('secondary-label', '(number of HTMLs used for model training)');
     $ctl->set('value', '20');
     $fieldset_cleanup->add_control($ctl);
     $ctl =& new AnewtFormControlText('m_cleanup_max_duplicates');
     $ctl->set('label', 'Max # of duplicates:');
     $ctl->set('secondary-label', '(max number of identical HTMLs that can be present in HTMLs for model training)');
     $ctl->set('value', '2');
     $fieldset_cleanup->add_control($ctl);
     $ctl =& new AnewtFormControlText('ct_id');
     $ctl->set('label', 'Model updating task id:');
     $ctl->set('secondary-label', '(assigned automatically)');
     $ctl->set('readonly', true);
     $fieldset_cleanup->add_control($ctl);
     $ctl =& new AnewtFormControlText('ct_periodicity');
     $ctl->set('label', 'Model updating periodicity:');
     $ctl->set('secondary-label', '(e.g., 04:00:00 for "once every four hours")');
     $ctl->set('value', '23:59:59');
     $fieldset_cleanup->add_control($ctl);
     $this->add_fieldset($fieldset_cleanup);
     $fieldset = new AnewtFormFieldset('feed-auto');
     $fieldset->set('label', 'Extracted from the feed automatically');
     $ctl =& new AnewtFormControlText('title');
     $ctl->set('label', 'Feed title:');
     $ctl->set('size', 50);
     $ctl->set('readonly', true);
     $fieldset->add_control($ctl);
     $ctl =& new AnewtFormControlText('description');
     $ctl->set('label', 'Description:');
     $ctl->set('size', 100);
     $ctl->set('readonly', true);
     $fieldset->add_control($ctl);
     $ctl =& new AnewtFormControlText('language');
     $ctl->set('label', 'Language:');
     $ctl->set('readonly', true);
     $fieldset->add_control($ctl);
     $ctl =& new AnewtFormControlText('copyright');
     $ctl->set('label', 'Copyright:');
     $ctl->set('readonly', true);
     $ctl->set('size', 100);
     $fieldset->add_control($ctl);
     $ctl =& new AnewtFormControlText('type');
     $ctl->set('label', 'Type:');
     $ctl->set('readonly', true);
     $fieldset->add_control($ctl);
     $ctl =& new AnewtFormControlText('class');
     $ctl->set('label', 'Class:');
     $ctl->set('readonly', true);
     $fieldset->add_control($ctl);
     $ctl =& new AnewtFormControlText('flavicon');
     $ctl->set('label', 'Flavicon:');
     $ctl->set('readonly', true);
     $fieldset->add_control($ctl);
     $ctl =& new AnewtFormControlText('encoding');
     $ctl->set('label', 'Encoding:');
     $ctl->set('readonly', true);
     $fieldset->add_control($ctl);
     $ctl =& new AnewtFormControlText('pub_date');
     $ctl->set('label', 'Publication date:');
     $ctl->set('readonly', true);
     $fieldset->add_control($ctl);
     $ctl =& new AnewtFormControlText('mod_date');
     $ctl->set('label', 'Last modified:');
     $ctl->set('readonly', true);
     $fieldset->add_control($ctl);
     $this->add_fieldset($fieldset);
     $ctl =& new AnewtFormControlButtonSubmit('submit');
     $ctl->set('label', 'Save feed');
     $this->add_control($ctl);
 }
Пример #3
0
 function make_interval_selection($current_interval)
 {
     $form = new AnewtForm();
     $form->setup('interval', ANEWT_FORM_METHOD_GET, $this->make_url(0));
     foreach ($this->params as $name => $val) {
         if ($name != 'interval') {
             $c =& new AnewtFormControlHidden($name);
             $c->set('value', $val);
             $form->add_control($c);
         }
     }
     $c =& new FormChoiceAutoSubmit('interval');
     $c->set('label', 'Interval:');
     $c->set('threshold', 3);
     $c->add_option_value_label('1 HOUR', '1 hour');
     $c->add_option_value_label('1 DAY', '1 day');
     $c->add_option_value_label('3 DAY', '3 days');
     $c->add_option_value_label('7 DAY', '1 week');
     $c->add_option_value_label('31 DAY', '1 month');
     $c->add_option_value_label('92 DAY', '3 months');
     $c->add_option_value_label('*', 'any time');
     $c->set('value', $this->interval);
     $form->add_control($c);
     $fr =& new AnewtFormRendererDefault();
     $fr->set_form($form);
     return $fr;
 }
Пример #4
0
 function TestForm()
 {
     parent::__construct();
     /* General form setup and test some properties */
     $this->setup('test-name', ANEWT_FORM_METHOD_POST, AnewtRequest::url(true));
     $this->set('error', 'This is a general form error.');
     $this->set('description', 'This is the form\'s description.');
     /* Test text entry controls */
     $text1 = new AnewtFormControlText('text1');
     $text1->set('label', 'Text field:');
     $text1->set('secondary-label', 'Secondary label');
     $text1->set('value', 'Short string with & spécial chars');
     $text1->set('help', 'You can type some text here.');
     $text1->set('description', 'Type at least 3 characters here.');
     $text1->add_validator(new AnewtValidatorLength(3, null), 'Too short (minimum number of characters is 3).');
     $this->add_control($text1);
     $text2 = new AnewtFormControlTextMultiline('text2');
     $this->add_control($text2);
     /* Set properties after adding to test references */
     $text2->set('description', 'You may enter some longer text here.');
     $text2->set('value', "Some readonly text\nwith multiple\nlines\nand some spécial characters\nlike &, ', < and >.");
     $text2->set('label', 'Multiline textfield:');
     $text2->set('readonly', true);
     $text3 = new AnewtFormControlTextMultiline('text3');
     $text3->set('value', "A larger control with a\nbit more space (4 lines!)\nto type some text, if only\nit wasn't disabled…");
     $text3->set('label', 'Larger multiline:');
     $text3->set('secondary-label', 'Secondary label');
     $text3->set('rows', 4);
     $text3->set('columns', 40);
     $text3->set('disabled', true);
     $text3->set('error', 'This is an error description.');
     $this->add_control($text3);
     $text4 = new AnewtFormControlTextMultiline('text4');
     $text4->set('value', 'Okay, this is multiline text you can edit yourself…');
     $text4->set('label', 'Another multiline:');
     $text4->set('rows', 2);
     $text4->set('columns', 50);
     $this->add_control($text4);
     /* Test adding custom nodes to the form */
     $this->add_node(ax_p('This is a normal paragraph inside the form.'));
     $this->add_node(ax_raw('<p><strong>Formatted text</strong> can be here as well.</p>'));
     /* Some more text controls with various property combinations */
     $text5 = new AnewtFormControlText('text5');
     $text5->set('label', 'A number between 1 and 10:');
     $text5->set('description', 'This should be 8 by default. You should not be able to type more than 2 characters into this field.');
     $text5->set('value', '7');
     // Set again to 8 later using set_control_value!
     $text5->set('help', 'Enter a number between 1 and 10 inclusive, please.');
     $text5->set('size', 2);
     $text5->set('maxlength', 2);
     $text5->add_validator(new AnewtValidatorInteger(1, 10), 'This number is not valid.');
     $this->add_control($text5);
     $text6 = new AnewtFormControlPassword('text6');
     $text6->set('label', 'Password:'******'description', 'This control can hold only 8 characters. This field is not required and will give a NULL value when left empty.');
     $text6->set('size', 8);
     $text6->set('maxlength', 8);
     $text6->set('value', 'not-shown');
     $text6->set('required', false);
     $text6->set('help', 'Enter a password, please.');
     $this->add_control($text6);
     $text7 = new AnewtFormControlPassword('text7');
     $text7->set('label', 'Echoed password:'******'description', 'This password is echoed back when the form is submitted.');
     $text7->set('value', 'shown');
     $text7->set('show-value', true);
     $this->add_control($text7);
     $text8 = new AnewtFormControlText('text8');
     $text8->set('label', 'Email:');
     $text8->set('value', '*****@*****.**');
     $text8->add_validator(new AnewtValidatorEmail(), 'This does not look like an email address.');
     $this->add_control($text8);
     /* Check box */
     $check1 = new AnewtFormControlCheckbox('check1');
     $check1->set('label', 'Checkbox:');
     $check1->set('secondary-label', 'Check me');
     $check1->set('help', 'Feel free to check me!');
     $this->add_control($check1);
     $check2 = new AnewtFormControlCheckbox('check2');
     $check2->set('label', 'Disabled checkbox:');
     $check2->set('disabled', true);
     $this->add_control($check2);
     $check3 = new AnewtFormControlCheckbox('check3');
     $check3->set('label', 'Another checkbox:');
     $check3->set('secondary-label', 'Check me too');
     $check3->set('value', true);
     $this->add_control($check3);
     /* Choice control, multiple same values */
     $choice_same_values = new AnewtFormControlChoice('choice-same-values');
     $choice_same_values->set('label', 'Choose:');
     $choice_same_values->set('description', 'Multiple options have the same value. Only the first should be selected.');
     $choice_same_values->add_option_value_label('same-value', 'Option 1 (same value as option 2');
     $choice_same_values->add_option_value_label('same-value', 'Option 2 (same value as option 1');
     $choice_same_values->add_option_value_label('other-value', 'Option 3');
     $choice_same_values->set('value', 'same-value');
     $this->add_control($choice_same_values);
     /* Choice control, single select */
     $single_choice_fieldset = new AnewtFormFieldset('single-choice');
     $single_choice_fieldset->set('label', 'Single select');
     $single_choice_fieldset->set('description', 'You can select a single value here. By default, the second option is selected in both cases, and the first option is disabled.');
     $choice1 = new AnewtFormControlChoice('choice1');
     $choice1->set('label', 'Make a choice:');
     $option = new AnewtFormOption('first', 'First option');
     $option->set('disabled', true);
     $choice1->add_option($option);
     unset($option);
     $choice1->add_option_value_label('second', 'Second option');
     $choice1->add_option_value_label('third', 'Third option');
     $choice1->add_option_value_label('fourth', 'Fourth option');
     $choice1->set('value', 'second');
     $single_choice_fieldset->add_control($choice1);
     $choice2 = new AnewtFormControlChoice('choice2');
     $choice2->set('threshold', 3);
     $choice2->set('label', 'Make a choice:');
     $option = new AnewtFormOption('first', 'First option');
     $option->set('disabled', true);
     $choice2->add_option($option);
     unset($option);
     $choice2->add_option_value_label('second', 'Second option');
     $choice2->add_option_value_label('third', 'Third option');
     $choice2->add_option_value_label('fourth', 'Fourth option');
     $choice2->set('value', 'second');
     $single_choice_fieldset->add_control($choice2);
     $choice3 = new AnewtFormControlChoice('choice3');
     $choice3->set('threshold', 3);
     $choice3->set('size', 4);
     $choice3->set('label', 'Make a choice:');
     $option = new AnewtFormOption('first', 'First option');
     $option->set('disabled', true);
     $choice3->add_option($option);
     unset($option);
     $choice3->add_option_value_label('second', 'Second option');
     $choice3->add_option_value_label('third', 'Third option');
     $choice3->add_option_value_label('fourth', 'Fourth option');
     $choice3->set('value', 'second');
     $single_choice_fieldset->add_control($choice3);
     $single_choice_fieldset->add_node(ax_p('This is a normal paragraph inside a fieldset.'));
     $this->add_fieldset($single_choice_fieldset);
     /* Choice control, multiple select */
     $multiple_choice_fieldset = new AnewtFormFieldset('multiple-choice');
     $multiple_choice_fieldset->set('label', 'Multiple select');
     $multiple_choice_fieldset->set('description', 'You can select multiple values here. By default, the second and third options are selected in both cases, and the first option is disabled.');
     $choice4 = new AnewtFormControlChoice('choice4');
     $choice4->set('multiple', true);
     $choice4->set('label', 'Make a choice:');
     $option = new AnewtFormOption('first', 'First option');
     $option->set('disabled', true);
     $choice4->add_option($option);
     unset($option);
     $choice4->add_option_value_label('second', 'Second option');
     $choice4->add_option_value_label('third', 'Third option');
     $choice4->add_option_value_label('fourth', 'Fourth option');
     /* Value is deliberately set twice to test unsetting of old values */
     $choice4->set('value', array('first', 'second'));
     $choice4->set('value', array('second', 'third'));
     $multiple_choice_fieldset->add_control($choice4);
     $choice5 = new AnewtFormControlChoice('choice5');
     $choice5->set('multiple', true);
     $choice5->set('threshold', 3);
     $choice5->set('label', 'Make a choice:');
     $option = new AnewtFormOption('first', 'First option');
     $option->set('disabled', true);
     $choice5->add_option($option);
     unset($option);
     $choice5->add_option_value_label('second', 'Second option');
     $choice5->add_option_value_label('third', 'Third option');
     $choice5->add_option_value_label('fourth', 'Fourth option');
     $choice5->set('value', array('second', 'third'));
     $multiple_choice_fieldset->add_control($choice5);
     $this->add_fieldset($multiple_choice_fieldset);
     /* Choice control, with option groups */
     $option_groups_fieldset = new AnewtFormFieldset('option-groups-fieldset');
     $option_groups_fieldset->set('label', 'Option groups');
     $option_groups_fieldset->set('description', 'Single and multiple select controls with option groups.');
     $choice6 = new AnewtFormControlChoice('choice6');
     $og = new AnewtFormOptionGroup('First group');
     $og->add_option_value_label('1a', 'A');
     $og->add_option_value_label('1b', 'B');
     $choice6->add_option_group($og);
     $og = new AnewtFormOptionGroup('Second group');
     $og->add_option_value_label('2a', 'A');
     $og->add_option_value_label('2b', 'B');
     $choice6->add_option_group($og);
     $choice6->set('label', 'Make a choice:');
     $choice6->set('description', 'Choice 2a selected by default.');
     $choice6->set('value', '2a');
     $option_groups_fieldset->add_control($choice6);
     $choice7 = new AnewtFormControlChoice('choice7');
     $choice7->add_option_value_label('o1', 'First option (not in a group)');
     $option_group_1 = new AnewtFormOptionGroup('First group');
     $option = new AnewtFormOption('g1o1', 'First disabled suboption in first group');
     $option->set('disabled', true);
     $option_group_1->add_option($option);
     $option_group_1->add_option_value_label('g1o2', 'Second suboption in first group');
     $option_group_1->add_option_value_label('g1o3', 'Third suboption in first group');
     $choice7->add_option_group($option_group_1);
     $option_group_2 = new AnewtFormOptionGroup('Second group');
     $option_group_2->add_option_value_label('g2o1', 'First suboption in second group');
     $option_group_2->add_option_value_label('g2o2', 'Second suboption in second group');
     $choice7->add_option_group($option_group_2);
     $choice7->add_option_value_label('o3', 'Third option (not in a group)');
     $option_group_3 = new AnewtFormOptionGroup('Third group (completely disabled)');
     $option_group_3->set('disabled', true);
     $option_group_3->add_option_value_label('g3o1', 'Only suboption in third group');
     $choice7->add_option_group($option_group_3);
     $choice7->add_option_value_label('04', 'Fourth option, not in a group');
     $choice7->set('label', 'Make multiple choices:');
     $choice7->set('description', 'Options 1 and group 2 option 1 are selected by default.');
     $choice7->set('multiple', true);
     $choice7->set('value', array('g2o1', 'o1'));
     $option_groups_fieldset->add_control($choice7);
     $choice8 = new AnewtFormControlChoice('choice8');
     $choice8->set('label', 'No selection here:');
     $choice8->set('description', 'This choice control only contains disabled options and disabled or empty option groups. The first one should be forcibly selected. Yes, this is a really nasty edge case.');
     $og = new AnewtFormOptionGroup('Empty group 1');
     $choice8->add_option_group($og);
     $og = new AnewtFormOptionGroup('Disabled group 2');
     $og->set('disabled', true);
     $og->add_option_value_label('none', '1a');
     $og->add_option_value_label('none', '1b');
     $choice8->add_option_group($og);
     $option = new AnewtFormOption('none', 'Disabled option');
     $option->set('disabled', true);
     $choice8->add_option($option);
     $choice8->set('value', 'too bad this is totally invalid');
     $option_groups_fieldset->add_control($choice8);
     $this->add_fieldset($option_groups_fieldset);
     /* Hidden controls */
     $hidden1 = new AnewtFormControlHidden('hidden1');
     $hidden1->set('value', 'sekr1t!');
     $this->add_control($hidden1);
     $this->add_hidden_control('hidden2', 'another && śèkŕ1t');
     /* Buttons */
     $button_fieldset = new AnewtFormFieldset('buttons');
     $button_fieldset->set('label', 'Button fieldset');
     $submit = new AnewtFormControlButtonSubmit('submit');
     $submit->set('label', 'Submit form');
     $submit->set('help', 'Press this button to submit this form');
     $button_fieldset->add_control($submit);
     $submit2 = new AnewtFormControlButtonSubmit('submit2');
     $submit2->set('label', 'Disabled submit button');
     $submit2->set('disabled', true);
     $button_fieldset->add_control($submit2);
     $submit = new AnewtFormControlButtonSubmit('submit3');
     $submit->set('label', 'Another submit button');
     $button_fieldset->add_control($submit);
     $reset = new AnewtFormControlButtonReset('reset');
     $reset->set('label', 'Reset to default values');
     $reset->set('help', 'Reset the values of the form fields to their original values');
     $button_fieldset->add_control($reset);
     $extra = new AnewtFormControlButton('extra-button');
     $extra->set('label', 'Extra button that does not do anything');
     $button_fieldset->add_control($extra);
     $this->add_fieldset($button_fieldset);
 }