Construtor de tipos PHP ExtJS

O ExtJS-Types-Builder é um OOP-PHP-Framework e cria strings JSON adequadas para a comunicação
com seu ExtJS-GUI. Devido a uma interface fluente, você pode facilmente construir e preparar os tipos.

Status da versão

Construir um campo de texto

$item = new ExtjsTypes_TextField('email', 'Ihre E-Mail:');

$data
= $item->setValue('meine-email@web.de')
->setVtype(new ExtjsTypes_VTypes_Email())
->prepare();

print_r
(json_encode($data));

O resultado será:

{
"xtype": "textfield",
"name": "email",
"fieldLabel": "Ihre E-Mail:",
"allowBlank": false,
"value": "meine-email@web.de",
"vtype": "email"
}

Construir uma combobox (caixa de seleção)

$comboBox = new ExtJsTypes_ComboBox('My friends as combo-box');
$comboBox
->setDisplayField('name')
->setValueField('name-value')
->addData('freunde', 'Miki')
->addData('freunde', 'Joe')
->addData('freunde2', 'Miki')
->addData('freunde2', 'Joe');

$data
= $comboBox->prepare();

print_r
(json_encode($data));

O resultado será:

{
"xtype": "combo",
"mode": "static",
"editable": false,
"triggerAction": "all",
"fieldLabel": "My friends as combo-box",
"displayField": "name",
"valueField": "name-value",
"store": [
[
"freunde",
"Miki"
],
[
"freunde",
"Joe"
],
[
"freunde2",
"Miki"
],
[
"freunde2",
"Joe"
]
]
}

Construir um formulário com campo de texto e combobox

$typeForm = new ExtJsTypes_Form(
'Node deatails',
'controller=extjstemplate&act=gettemplates'
);

$textFieldName
= new ExtJsTypes_TextField('name', 'Ihr Name');
$textFieldEmail
= new ExtJsTypes_TextField('email', 'Ihre E-Mail');

$comboBox
= new ExtJsTypes_ComboBox('My friends as combo-box');
$comboBox
->setDisplayField('name')
->setValueField('name-value')
->addData('freunde', 'Miki')
->addData('freunde', 'Joe');

$data
= $typeForm->addItem($textFieldName)
->addItem($textFieldEmail)
->addItem($comboBox)
->prepare();

print_r
(json_encode($data));

O resultado será:

{
"xtype": "form",
"config": {
"title": "Node deatails",
"url": "controller=extjstemplate&act=gettemplates",
"items": [
{
"xtype": "textfield",
"name": "name",
"fieldLabel": "Ihr Name",
"allowBlank": false
},
{
"xtype": "textfield",
"name": "email",
"fieldLabel": "Ihre E-Mail",
"allowBlank": false
},
{
"xtype": "combo",
"mode": "static",
"editable": false,
"triggerAction": "all",
"fieldLabel": "My friends as combo-box",
"displayField": "name",
"valueField": "name-value",
"store": [
[
"freunde",
"Miki"
],
[
"freunde",
"Joe"
]
]
}
]
}
}

Construir uma grade

$fields = new ExtJsTypes_Fields();
$fields
->add('name')
->add('vorname')
->add('email');

$columns
= new ExtJsTypes_Columns();
$columns
->add('Name', 'name')
->add('Vorname', 'vorname')
->add('E-Mail', 'email', true);

$data
= new ExtJsTypes_Data();
$data
->put(array('name' => 'Miki', 'email' => 'miki@maus.de'))
->put(array('name' => 'Olie', 'email' => 'olie@maus.de'));

$grid
= new ExtJsTypes_Grid('My friends');
$grid
->setFields($fields)
->setColumns($columns)
->setData($data);

$data
= $grid->prepare();

print_r
(json_encode($data));

O resultado será:

{
"xtype": "gridpanel",
"config": {
"title": "My friends",
"fields": [
"name",
"email"
],
"columns": [
{
"header": "Name",
"dataIndex": "name",
"flex": false
},
{
"header": "E-Mail",
"dataIndex": "email",
"flex": true
}
],
"data": [
{
"name": "Miki",
"email": "miki@maus.de"
},
{
"name": "Olie",
"email": "olie@maus.de"
}
]
}
}

Construir uma grade com campo de texto encaixado

$fields = new ExtJsTypes_Fields();
$fields
->add('name')
->add('vorname');

$columns
= new ExtJsTypes_Columns();
$columns
->add('Name', 'name')
->add('Vorname', 'vorname', true);

$data
= new ExtJsTypes_Data();
$data
->put(array('name' => 'Miki', 'vorname' => 'Maus'))
->put(array('name' => 'Olie', 'vorname' => 'Otto'));

$grid
= new ExtJsTypes_Grid('My friends');
$grid
->setFields($fields)
->setColumns($columns)
->setData($data)
->dockItem(
new ExtJsTypes_ItemsDocker(
new ExtJsTypes_Textfield('new-scale', 'Add Scale')
)
);

$data
= $grid->prepare();

print_r
(json_encode($data));

O resultado será:

{
"xtype": "gridpanel",
"config": {
"title": "My friends",
"fields": [
"name",
"vorname"
],
"columns": [
{
"header": "Name",
"dataIndex": "name",
"flex": false
},
{
"header": "Vorname",
"dataIndex": "vorname",
"flex": true
}
],
"data": [
{
"name": "Miki",
"vorname": "Maus"
},
{
"name": "Olie",
"vorname": "Otto"
}
],
"dockeditems": [
{
"xtype": "textfield",
"buttonLabel": "Add Scale"
}
]
}
}

Faça o download ou faça um fork aqui https://github.com/gjerokrsteski/php-to-extjs-types-builder