public function testVerificaInclusaoDeOpcoes() { $opcao1 = $this->getMock('FT\\Formulario\\Types\\Option', array(), array("valor1", "legenda1", "selected")); $opcao2 = $this->getMock('FT\\Formulario\\Types\\Option', array(), array("valor2", "legenda2", "")); $selecao = new Select("id", "nome", "legenda"); $selecao->add($opcao1); $selecao->add($opcao2); $this->assertEquals(2, count($selecao->getFields())); $selecao->resetFields(); $this->assertEquals(0, count($selecao->getFields())); }
function doIndex() { $this->fetch("list"); $select = new Select("lookups"); if (!empty($this->list["sort"]["key"])) { $select->addOrder($this->list["sort"]["key"], $this->list["sort"]["order"]); $this->serverDatas["sort"] = $this->list["sort"]; } if (!empty($this->list["filter"])) { $filter = $this->list["filter"]; $select->expressions = array(); $select->add(Exp::like("type", $filter["type"], Exp::MATCH_BOTH)); $select->add(Exp::like("code", $filter["code"], Exp::MATCH_BOTH)); } $this->list["list"] = DB::query($select); Apu::dispatch("/todo/faces/lookup/lookup_list.php"); }
function doLogin() { $this->save("login"); if (empty($this->messages)) { $select = new Select("users"); $select->add(Exp::eq("username", $this->login["username"])); $user = DB::unique($select); if (empty($user)) { $this->addMsgMessage("error.fieldNotFound", "login.username"); Msg::save($this->messages); Apu::redirect("login"); } if ($user["password"] != $this->login["password"]) { $this->addMsgMessage("error.fieldNotFound", "login.password"); Msg::save($this->messages); Apu::redirect("login"); } $date = new Date(); Session::save(LOGIN_SCOPE, $user, "user"); Session::save(LOGIN_SCOPE, $date, "last_access"); $this->remove(); Apu::redirect("frame"); } else { Msg::save($this->messages); Apu::redirect("login"); } }
$form = new Form(); $form->setAction('controller.php'); $form->setJs(' onsubmit="return PSA.indexcol();" '); $form->build(); // TODO: check if table name already exists $name = new Input(); $name->setName('idxname'); $name->setSize(50); $name->setMaxlength(128); $name->setId('idxname'); $body->line('Name : ' . $name->dump() . ' ' . $cmd->dump() . '<br>'); for ($i = 0; $i < sizeof($fields); ++$i) { $select = new Select(); $select->setName('col' . $i); $select->setSize(1); $select->add('', '-'); for ($j = 0; $j < sizeof($fields); ++$j) { $select->add($fields[$j], $fields[$j]); } $body->line('index on : ' . $select->dump() . '<br>'); } $submit->build(); $tblname = new Input(); $tblname->setName('tblname'); $tblname->setSize(128); $tblname->setValue($req->get('table')); $tblname->setType('hidden'); $tblname->build(); unset($form); $body->line('</div>'); include_once './inc/footer.php';
$th->add('type'); $th->add('primary'); $th->add('size'); $th->add('null'); $th->add('default'); $th->build(); $colname = new Input(); $colname->setName('colname'); $colname->setSize(25); $colname->setMaxlength(128); $colname->setId('colname'); $coltype = new Select(); $coltype->setName('coltype'); $coltype->setSize(1); $coltype->setId('coltype'); $coltype->add('VARCHAR', 'VARCHAR'); $coltype->add('INTEGER', 'INTEGER'); $coltype->add('FLOAT', 'FLOAT'); $coltype->add('TEXT', 'TEXT'); $coltype->add('DATETIME', 'DATETIME'); $colprime = new Input(); $colprime->setName('colprime'); $colprime->setType('checkbox'); $colprime->setId('colprime'); $colprime->setJs(' onclick="PSA.checkprimary();" '); $colsize = new Input(); $colsize->setName('colsize'); $colsize->setSize(7); $colsize->setMaxlength(7); $colsize->setId('colsize'); $colsize->setJs(' onblur="PSA.checknumeric();" ');
function byId($id, $table) { $select = new Select($table); $select->add(Exp::eq("id", $id)); return DB::unique($select); }