1: <?php
2: require_once('../qcubed.inc.php');
3:
4: class UrlForm extends QForm {
5:
6: protected $dtg;
7: protected $lblVars;
8:
9: protected function Form_Create() {
10: $this->dtg = new QHtmlTable($this);
11: $this->dtg->SetDataBinder('BindData');
12:
13: $col = $this->dtg->CreateCallableColumn('Link', [$this, 'dtg_LinkRender']);
14: $col->HtmlEntities = false;
15: $col = $this->dtg->CreateCallableColumn('Button', [$this, 'dtg_ButtonRender']);
16: $col->HtmlEntities = false;
17:
18: $this->lblVars = new QLabel ($this);
19: }
20:
21: public function dtg_LinkRender ($item) {
22: return (QHtml::RenderTag('a', ['href'=>$item], urldecode($item)));
23: }
24:
25: public function dtg_ButtonRender ($item) {
26: $strControl = new QButton ($this);
27: $strControl->Text = 'Button';
28: $strControl->ActionParameter = $item;
29: $strControl->AddAction (new QClickEvent(), new QServerAction('btn_click'));
30:
31: return $strControl->Render(false);
32: }
33:
34: protected function btn_click($strFormId, $strControlId, $strParameter) {
35: QApplication::Redirect($strParameter);
36: }
37:
38: public function BindData() {
39: $a = [
40: QHtml::MakeUrl(QApplication::$ScriptName, null, 'anchor'),
41: QHtml::MakeUrl(QApplication::$ScriptName, ['a'=>1, 'b'=>'this & that', 'c'=>'/forward\back']),
42: QHtml::MakeUrl(QApplication::$ScriptName, ['a'=>1, 'b'=>'this & that', 'c'=>'/forward\back'], null, QHtml::HTTP, $_SERVER['HTTP_HOST']),
43: QHtml::MailToUrl('test', 'qcu.be', ['subject'=>'Hey you.']),
44: QHtml::MailToUrl('test', 'qcu.be', ['subject'=>'What & About \ this /']),
45: QHtml::MailToUrl('"very.(),:;<>[]\".VERY.\"very@\\ \"very\".unusual"', 'strange.email.com', ['subject'=>'What & About \ this /']),
46:
47: ];
48:
49: $this->dtg->DataSource = $a;
50:
51: $this->lblVars->Text = var_dump ($_GET);
52: }
53:
54: }
55:
56: UrlForm::Run('UrlForm');
57: