Beispiel #1
0
 /**
  * checks that an empty form is initialized correctly
  */
 function test_defaults()
 {
     global $INPUT;
     global $ID;
     $ID = 'some:test';
     $INPUT->get->set('id', $ID);
     $INPUT->get->set('foo', 'bar');
     $form = new Form\Form();
     $html = $form->toHTML();
     $pq = phpQuery::newDocumentXHTML($html);
     $this->assertTrue($pq->find('form')->hasClass('doku_form'));
     $this->assertEquals(wl($ID, array('foo' => 'bar'), false, '&'), $pq->find('form')->attr('action'));
     $this->assertEquals('post', $pq->find('form')->attr('method'));
     $this->assertTrue($pq->find('input[name=sectok]')->length == 1);
 }
 /**
  * check that posted values overwrite preset default
  */
 function test_prefill()
 {
     global $INPUT;
     $INPUT->post->set('foo', 'second');
     $form = new Form\Form();
     $form->addRadioButton('foo', 'label text first')->val('first')->attr('checked', 'checked');
     $form->addRadioButton('foo', 'label text second')->val('second');
     $html = $form->toHTML();
     $pq = phpQuery::newDocumentXHTML($html);
     $inputs = $pq->find('input[name=foo]');
     $this->assertEquals('first', pq($inputs->elements[0])->val());
     $this->assertEquals('second', pq($inputs->elements[1])->val());
     $this->assertEquals('', pq($inputs->elements[0])->attr('checked'));
     $this->assertEquals('checked', pq($inputs->elements[1])->attr('checked'));
 }
 /**
  * Form to add a new schema
  *
  * @return string
  */
 protected function html_newschema()
 {
     $form = new Form();
     $form->addClass('struct_newschema');
     $form->addFieldsetOpen($this->getLang('create'));
     $form->setHiddenField('do', 'admin');
     $form->setHiddenField('page', 'struct_schemas');
     $form->addTextInput('table', $this->getLang('schemaname'));
     $form->addRadioButton('lookup', $this->getLang('page schema'))->val('0')->attr('checked', 'checked');
     $form->addRadioButton('lookup', $this->getLang('lookup schema'))->val('1');
     $form->addButton('', $this->getLang('save'));
     $form->addHTML('<p>' . $this->getLang('createhint') . '</p>');
     // FIXME is that true? we probably could
     $form->addFieldsetClose();
     return $form->toHTML();
 }
 /**
  * Returns the Admin Form to edit the schema
  *
  * This data is processed by the SchemaBuilder class
  *
  * @return string the HTML for the editor form
  * @see SchemaBuilder
  */
 public function getEditor()
 {
     $form = new Form(array('method' => 'POST', 'id' => 'plugin__struct_editor'));
     $form->setHiddenField('do', 'admin');
     $form->setHiddenField('page', 'struct_schemas');
     $form->setHiddenField('table', $this->schema->getTable());
     $form->setHiddenField('schema[id]', $this->schema->getId());
     $form->setHiddenField('schema[islookup]', $this->schema->isLookup());
     $form->addHTML('<table class="inline">');
     $form->addHTML("<tr>\n            <th>{$this->hlp->getLang('editor_sort')}</th>\n            <th>{$this->hlp->getLang('editor_label')}</th>\n            <th>{$this->hlp->getLang('editor_multi')}</th>\n            <th>{$this->hlp->getLang('editor_conf')}</th>\n            <th>{$this->hlp->getLang('editor_type')}</th>\n            <th>{$this->hlp->getLang('editor_enabled')}</th>\n        </tr>");
     foreach ($this->schema->getColumns() as $key => $col) {
         $form->addHTML($this->adminColumn($col->getColref(), $col));
     }
     // FIXME new one needs to be added dynamically, this is just for testing
     $form->addHTML($this->adminColumn('new1', new Column($this->schema->getMaxsort() + 10, new Text()), 'new'));
     $form->addHTML('</table>');
     $form->addFieldsetOpen();
     $form->addTextInput('schema[editors]', $this->hlp->getLang('editor_editors'))->val($this->schema->getEditors());
     $form->addFieldsetClose();
     $form->addButton('save', 'Save')->attr('type', 'submit');
     return $form->toHTML() . $this->initJSONEditor();
 }