$if_leaf_html = PhpExt_Javascript::functionNoDef("if", $add_tab_invoke_html, array("n.leaf")); $add_tab_onclick = PhpExt_Javascript::functionDef(null, $if_leaf, array("n")); $add_tab_oncontextmenu = PhpExt_Javascript::functionDef(null, $if_leaf_html, array("n")); $output_add_tab_onclick = $get_tree_panel->on("click", $add_tab_onclick); $output_add_tab_oncontextmenu = $get_tree_panel->on("contextmenu", $add_tab_oncontextmenu); $output_add_tab_function = new PhpExt_JavascriptStm($add_tab_function); //-----------------------------------------------------------BARRA DE ESTADO-------------------------------------------------------------------------------------------- $function_win_open = PhpExt_Javascript::callfunction("window.open", array("'http://www.nutus.com.ar'")); $handler_abrir_pagina = PhpExt_Javascript::functionDef("", $function_win_open, array("e")); $function_win_open2 = PhpExt_Javascript::callfunction("window.open", array("'http://soporte.nutus.info'")); $handler_abrir_pagina2 = PhpExt_Javascript::functionDef("", $function_win_open2, array("e")); $barra_estado = new PhpExt_Toolbar_StatusBar(); $barra_estado->setId("status_bar"); $barra_estado->setDefaultText("Terminado"); $barra_estado->addButton("ayuda", "Ayuda on-line", null, $handler_abrir_pagina2); $barra_estado->addButton("Pagina", "© Nutus 2009", null, $handler_abrir_pagina); $status_bar = new PhpExt_Panel(); $status_bar->setBottomToolbar($barra_estado); //USO UN VIEWPORT YA QUE SE ADAPTA AL ANCHO DE LA PAGINA //creo uno nuevo y le agrego todos los items setando el area $contenedor = new PhpExt_Viewport(); $contenedor->setLayout(new PhpExt_Layout_BorderLayout()); $contenedor->addItem($menu_top, PhpExt_Layout_BorderLayoutData::createNorthRegion()); $contenedor->addItem($menu_acordion, PhpExt_Layout_BorderLayoutData::createWestRegion()); $contenedor->addItem($principal, PhpExt_Layout_BorderLayoutData::createCenterRegion()); $contenedor->addItem($status_bar, PhpExt_Layout_BorderLayoutData::createSouthRegion()); //FUNCTIONS DE USO GENERAL $format_money = "\t\nfunction FormatMoney(v,sign){\t\t\t\t\n v = (Math.round((v-0)*100))/100;\n v = (v == Math.floor(v)) ? v + '.00' : ((v*10 == Math.floor(v*10)) ? v + '0' : v);\n v = String(v); \n if(v.charAt(0) == '-'){\n return '-' + sign + v.substr(1).replace('.',',');\n }\n return sign + v.replace('.',',');\n}\n"; $unformat_money = "\nfunction unformatMoney(num) {\n\tvar value = num.replace(',','.');\t\t\n\treturn value.replace(/([^0-9\\.\\-])/g,'')*1;\t\n}\n"; echo PhpExt_Ext::OnReady(PhpExt_QuickTips::init(), $contenedor->getJavascript(false, "Contenedor"), $contenedor->render(PhpExt_Javascript::inlineStm("document.body")), $output_add_tab_function->output(), $output_add_tab_onclick, $output_add_tab_oncontextmenu, $unformat_money, $format_money);
// Configure Reader and Store $reader = new PhpExt_Data_JsonReader(); $reader->setRoot("topics")->setTotalProperty("totalCount")->setId("post_id"); $reader->addField(new PhpExt_Data_FieldConfigObject("postId", "post_id")); $reader->addField(new PhpExt_Data_FieldConfigObject("title", "topic_title")); $reader->addField(new PhpExt_Data_FieldConfigObject("topicId", "topic_id")); $reader->addField(new PhpExt_Data_FieldConfigObject("author", "author")); $reader->addField(new PhpExt_Data_FieldConfigObject("lastPost", "post_time", "date", "timestamp")); $reader->addField(new PhpExt_Data_FieldConfigObject("excerpt", "post_text")); $ds = new PhpExt_Data_Store(); $ds->setProxy(new PhpExt_Data_ScriptTagProxy('http://extjs.com/forum/topics-remote.php'))->setReader($reader)->setBaseParams(array("limit" => 20, "forumId" => 21)); // ->setBaseParams(new PhpExt_Config_ConfigObject(array("limit"=>20,"forumId"=>21)); // Configure Custom SearchField $resultTpl = new PhpExt_XTemplate('<tpl for=".">', '<div class="search-item">', '<h3><span>{lastPost:date("M j, Y")}<br />by {author}</span>', '<a href="http://extjs.com/forum/showthread.php?t={topicId}&p={postId}" target="_blank">{title}</a></h3>', '<p>{excerpt}</p>', '</div></tpl>'); $panel = new PhpExt_Panel(); $panel->setApplyTo("search-panel")->setTitle("Forum Search")->setHeight(300)->setAutoScroll(true); $dv = new PhpExt_DataView("div.search-item"); $dv->setStore($ds)->setTemplate($resultTpl); $panel->addItem($dv); $searchField = new PhpExtUx_App_SearchField(); $searchField->setStore($ds)->setWidth(320); $tb = $panel->getTopToolbar(); $tb->addTextItem(1, "Search: "); $tb->addSpacer(2); $tb->addItem(3, $searchField); $paging = new PhpExt_Toolbar_PagingToolbar(); $paging->setStore($ds)->setPageSize(20)->setDisplayInfo("Topics {0} - {1} of {2}")->setEmptyMessage("No topics to display"); $panel->setBottomToolbar($paging); //------------ Ext.OnReady echo PhpExt_Ext::onReady($ds->getJavascript(false, "ds"), $resultTpl->getJavascript(false, "resultTpl"), $panel->getJavascript(false, "panel"), $ds->load(new PhpExt_Data_StoreLoadOptions(array("start" => 0, "limit" => 0, "forumId" => 21, "query" => "\"PHP-Ext 0.\""))));
<?php set_include_path(get_include_path() . PATH_SEPARATOR . realpath('../../library')); include_once 'PhpExt/Javascript.php'; PhpExt_Javascript::sendContentType(); include_once 'PhpExt/Ext.php'; include_once 'PhpExt/Panel.php'; $p = new PhpExt_Panel(); $p->setTitle("My Panel")->setCollapsible(true)->setRenderTo(PhpExt_Javascript::variable("Ext.get('centercolumn')"))->setWidth(400)->setHtml(PhpExt_Javascript::variable("Ext.example.bogusMarkup")); echo PhpExt_Ext::OnReady($p->getJavascript(false, "p"));
$accordion = new PhpExt_Layout_AccordionLayout(); $accordion->setTitleCollapse(true) ->setActiveOnTop(true) ->setAnimate(true) ; $accordionPanel->setLayout($accordion); $p1 = new PhpExt_Panel(); $p1->setTitle("Navigation") ->setHtml("This <bt>is the navigation panel"); $p2 = new PhpExt_Panel(); $p2->setTitle("Settings") ->setHtml("This <br>is the settings panel"); $accordionPanel->addItem($p1); $accordionPanel->addItem($p2); $accordionPanel->setRenderTo(PhpExt_Javascript::inlineStm("Ext.get('centercolumn')")); */ $accordionPanel = new PhpExt_Panel(); $accordionPanel->setTitle("Accordion Sample")->setWidth(500)->setHeight(300); $accordion = new PhpExt_Layout_AccordionLayout(); $accordion->setTitleCollapse(true)->setAnimate(true); $accordionPanel->setLayout($accordion); $p1 = new PhpExt_Panel(); $p1->setTitle("Navigation")->setHtml("This <bt>is the navigation panel"); $p2 = new PhpExt_Panel(); $p2->setTitle("Settings")->setHtml("This <br>is the settings panel"); $accordionPanel->addItem($p1); $accordionPanel->addItem($p2); $accordionPanel->setRenderTo(PhpExt_Javascript::inlineStm("Ext.get('centercolumn')")); echo PhpExt_Ext::onReady($accordionPanel->getJavascript(false, "accordionPanel"));
<?php set_include_path(get_include_path() . PATH_SEPARATOR . realpath('../../library')); include_once 'PhpExt/Javascript.php'; PhpExt_Javascript::sendContentType(); include_once 'PhpExt/Ext.php'; include_once 'PhpExt/Data/Store.php'; include_once 'PhpExt/Data/XmlReader.php'; include_once 'PhpExt/Data/FieldConfigObject.php'; include_once 'PhpExt/Grid/ColumnModel.php'; include_once 'PhpExt/Grid/ColumnConfigObject.php'; include_once 'PhpExt/Grid/GridPanel.php'; // Xml Reader $reader = new PhpExt_Data_XmlReader(); $reader->setRecord("Item")->setTotalRecords("@total")->setId("ASIN"); $reader->addField(new PhpExt_Data_FieldConfigObject("Author", "ItemAttributes > Author")); $reader->addField(new PhpExt_Data_FieldConfigObject("Title")); $reader->addField(new PhpExt_Data_FieldConfigObject("Manufacturer")); $reader->addField(new PhpExt_Data_FieldConfigObject("ProductGroup")); // Store $store = new PhpExt_Data_Store(); $store->setUrl("examples/grid/sheldon.xml")->setReader($reader); // ColumnModel $colModel = new PhpExt_Grid_ColumnModel(); $colModel->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Author", "Author", null, 120, null, null, true))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Title", "Title", null, 180, null, null, null, true))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Manufacturer", "Manufacturer", null, 115, null, null, true))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Product Group", "ProductGroup", null, 100, null, null, true)); // Grid $grid = new PhpExt_Grid_GridPanel(); $grid->setStore($store)->setColumnModel($colModel)->setHeight(200)->setWidth(540)->setTitle("Xml Grid"); // Ext.OnReady ----------------------- echo PhpExt_Ext::onReady($store->getJavascript(false, "store"), $grid->getJavascript(false, "grid"), $grid->render("example-grid"), $store->load());
$fs->setFrame(true)->setTitle("XML Form")->setLabelAlign(PhpExt_Form_FormPanel::LABEL_ALIGN_RIGHT)->setLabelWidth(85)->setWidth(340)->setWaitMsgTarget(true); // configure how to read the XML Data $reader = new PhpExt_Data_XmlReader(); $reader->setRecord("contact")->setSuccess("@success"); $reader->addField(new PhpExt_Data_FieldConfigObject("first", "name/first")); // custom mapping $reader->addField(new PhpExt_Data_FieldConfigObject("last", "name/last")); $reader->addField(new PhpExt_Data_FieldConfigObject("company", "company")); $reader->addField(new PhpExt_Data_FieldConfigObject("email", "email")); $reader->addField(new PhpExt_Data_FieldConfigObject("state", "state")); $reader->addField(new PhpExt_Data_FieldConfigObject("dob", "dob", "date", "m/d/Y")); // custom data types $fs->setReader($reader); $fs->setErrorReader(new PhpExtUx_Form_XmlErrorReader()); $fset = new PhpExt_Form_FieldSet(); $fset->setTitle("Contact Information")->setAutoHeight(true)->setDefaultType("textfield")->setDefaults(new PhpExt_Config_ConfigObject(array("width" => 190)))->addItem(PhpExt_Form_TextField::createTextField("first", "First Name"))->addItem(PhpExt_Form_TextField::createTextField("last", "Last Name"))->addItem(PhpExt_Form_TextField::createTextField("company", "Company"))->addItem(PhpExt_Form_TextField::createTextField("email", "Email", null, PhpExt_Form_FormPanel::VTYPE_EMAIL)); $combo = PhpExt_Form_ComboBox::createComboBox("state", "State")->setValueField("abbr")->setDisplayField("state")->setTypeAhead(true)->setMode(PhpExt_Form_ComboBox::MODE_LOCAL)->setTriggerAction(PhpExt_Form_ComboBox::TRIGGER_ACTION_ALL)->setEmptyText("Select a state...")->setSelectOnFocus(true); $store = new PhpExt_Data_SimpleStore(); $store->addField("abbr"); $store->addField("state"); $store->setData(PhpExt_Javascript::variable("Ext.exampledata.states")); $combo->setStore($store); $fset->addItem($combo); $fset->addItem(PhpExt_Form_DateField::createDateField("dob", "Data of Birth")->setAllowBlank(false)); $fs->addItem($fset); $fs->addButton(PhpExt_Button::createTextButton("Load", new PhpExt_Handler(PhpExt_Javascript::stm("fs.getForm().load({url:'examples/form/xml-form.xml', waitMsg:'Loading',method: 'GET'})")))); $submitBtn = PhpExt_Button::createTextButton("Submit", new PhpExt_Handler(PhpExt_Javascript::stm("fs.getForm().submit({url:'examples/form/xml-errors.xml', waitMsg:'Saving Data...'})"))); $fs->addButton($submitBtn); //****************************** onReady echo PhpExt_Ext::onReady(PhpExt_Javascript::stm(PhpExt_QuickTips::init()), PhpExt_Javascript::assign("Ext.form.Field.prototype.msgTarget", PhpExt_Javascript::valueToJavascript(PhpExt_Form_FormPanel::MSG_TARGET_SIDE)), $fs->getJavascript(false, "fs"), PhpExt_Javascript::assignNew("submit", $submitBtn->getJavascript()), $fs->render("form-ct"));
set_include_path(get_include_path() . PATH_SEPARATOR . realpath('../../library')); include_once 'PhpExt/Javascript.php'; PhpExt_Javascript::sendContentType(); include_once 'PhpExt/Ext.php'; include_once 'PhpExt/Data/Store.php'; include_once 'PhpExt/Data/ScriptTagProxy.php'; include_once 'PhpExt/Data/JsonReader.php'; include_once 'PhpExt/Data/FieldConfigObject.php'; include_once 'PhpExt/Config/ConfigObject.php'; include_once 'PhpExt/XTemplate.php'; include_once 'PhpExt/Form/ComboBox.php'; include_once 'PhpExt/Listener.php'; $ds = new PhpExt_Data_Store(); $ds->setProxy(new PhpExt_Data_ScriptTagProxy('http://extjs.com/forum/topics-remote.php')); $reader = new PhpExt_Data_JsonReader(); $reader->setRoot("topics")->setTotalProperty("totalCount")->setId("post_id"); $reader->addField(new PhpExt_Data_FieldConfigObject("postId", "post_id")); $reader->addField(new PhpExt_Data_FieldConfigObject("title", "topic_title")); $reader->addField(new PhpExt_Data_FieldConfigObject("topicId", "topic_id")); $reader->addField(new PhpExt_Data_FieldConfigObject("author", "author")); $reader->addField(new PhpExt_Data_FieldConfigObject("lastPost", "post_time", "date", "timestamp")); $reader->addField(new PhpExt_Data_FieldConfigObject("excerpt", "post_text")); $ds->setReader($reader); $ds->setBaseParams(array("limit" => 20, "forumId" => 21)); $resultTpl = new PhpExt_XTemplate('<tpl for="."><div class="search-item">', '<h3><span>{lastPost:date("M j, Y")}<br />by {author}</span>{title}</h3>', '{excerpt}', '</div></tpl>'); $search = new PhpExt_Form_ComboBox(null, "searchbox"); $search->setStore($ds)->setDisplayField("title")->setTypeAhead(false)->setLoadingText("Searching...")->setWidth(570)->setPageSize(10)->setHideTrigger(true)->setTemplate($resultTpl)->setApplyTo("fsearch")->setItemCssSelector("div.search-item")->attachListener("onSelect", new PhpExt_Listener(PhpExt_Javascript::functionDef(null, "window.location =\r\n String.format('http://extjs.com/forum/showthread.php?t={0}&p={1}', record.data.topicId, record.id)", array("record")))); //------------ Ext.OnReady echo PhpExt_Ext::onReady($ds->getJavascript(false, "ds"), $resultTpl->getJavascript(false, "resultTpl"), $search->getJavascript(false, "search"));
*/ $italicRenderer = PhpExt_Javascript::functionDef("italic", "return '<i>' + value + '</i>'", array("value")); $changeRenderer = PhpExt_Javascript::functionDef("change", "if(val > 0){\r\n return '<span style=\"color:green;\">' + val + '</span>';\r\n }else if(val < 0){\r\n return '<span style=\"color:red;\">' + val + '</span>';\r\n }\r\n return val;", array("val")); $pctChangeRenderer = PhpExt_Javascript::functionDef("pctChange", "if(val > 0){\r\n return '<span style=\"color:green;\">' + val + '%</span>';\r\n }else if(val < 0){\r\n return '<span style=\"color:red;\">' + val + '%</span>';\r\n }\r\n return val;", array("val")); // ColumnModel $colModel = new PhpExt_Grid_ColumnModel(); $colModel->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Company", "company", "company", 160, null, null, true, false))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Price", "price", null, 75, null, PhpExt_Javascript::variable("Ext.util.Format.usMoney"), null, true))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Change", "change", null, 75, null, PhpExt_Javascript::variable('change'), null, true))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("% Change", "pctChange", null, 75, null, PhpExt_Javascript::variable('pctChange'), null, true))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Last Updated", "lastChange", null, 75, null, PhpExt_Javascript::variable("Ext.util.Format.dateRenderer('m/d/Y')"), null, true)); // Form Panel $gridForm = new PhpExt_Form_FormPanel("company-form"); $gridForm->setFrame(true)->setLabelAlign(PhpExt_Form_FormPanel::LABEL_ALIGN_LEFT)->setTitle("Company Data")->setBodyStyle("padding: 5px;")->setWidth(750)->setLayout(new PhpExt_Layout_ColumnLayout()); // Setup Grid $leftPanel = new PhpExt_Panel(); $leftPanel->setLayout(new PhpExt_Layout_FitLayout()); $selModel = new PhpExt_Grid_RowSelectionModel(); $selModel->setSingleSelect(true)->attachListener("rowselect", new PhpExt_Listener(PhpExt_Javascript::functionDef(null, "Ext.getCmp(\"company-form\").getForm().loadRecord(rec);", array("sm", "row", "rec")))); $grid = new PhpExt_Grid_GridPanel(); $grid->setStore($store)->setColumnModel($colModel)->setSelectionModel($selModel)->setAutoExpandColumn("company")->setHeight(350)->setTitle("Company Data")->setBorder(true)->attachListener("render", new PhpExt_Listener(PhpExt_Javascript::functionDef(null, "g.getSelectionModel().selectRow(0);", array("g")), null, 10)); $leftPanel->addItem($grid); $gridForm->addItem($leftPanel, new PhpExt_Layout_ColumnLayoutData(0.6)); // Setup Fields $rightPanel = new PhpExt_Form_FieldSet(); $rightPanel->setLabelWidth(90)->setTitle("Company Details")->setDefaults(new PhpExt_Config_ConfigObject(array("width" => 140)))->setDefaultType("textfield")->setAutoHeight(true)->setBodyStyle(PhpExt_Javascript::inlineStm("Ext.isIE ? 'padding:0 0 5px 15px;' : 'padding:10px 15px;'"))->setBorder(false)->setCssStyle(new PhpExt_Config_ConfigObject(array("margin-left" => "10px", "margin-right" => PhpExt_Javascript::inlineStm('Ext.isIE6 ? (Ext.isStrict ? "-10px" : "-13px") : "0"')))); $rightPanel->addItem(PhpExt_Form_TextField::createTextField("company", "Name")); $rightPanel->addItem(PhpExt_Form_TextField::createTextField("price", "Price")); $rightPanel->addItem(PhpExt_Form_TextField::createTextField("pctChange", "% Change")); $rightPanel->addItem(PhpExt_Form_TextField::createTextField("lastChange", "Last Updated")); $gridForm->addItem($rightPanel, new PhpExt_Layout_ColumnLayoutData(0.4)); $gridForm->setRenderTo(PhpExt_Javascript::variable("Ext.get('centercolumn')")); //****************************** onReady echo PhpExt_Ext::onReady(PhpExt_Javascript::stm(PhpExt_QuickTips::init()), PhpExt_Javascript::assign("data", PhpExt_Javascript::valueToJavascript($myData)), $store->getJavascript(false, "ds"), $italicRenderer, $changeRenderer, $pctChangeRenderer, $colModel->getJavascript(false, "colModel"), $gridForm->getJavascript(false, "gridForm"));
include_once 'PhpExt/Data/JsonStore.php'; include_once 'PhpExt/Toolbar/PagingToolbar.php'; include_once 'PhpExt/Grid/ColumnModel.php'; include_once 'PhpExt/Grid/ColumnConfigObject.php'; include_once 'PhpExt/Grid/GridPanel.php'; $PageSize = 10; $changeRenderer = PhpExt_Javascript::functionDef("change", "if(val > 0){\r\n return '<span style=\"color:green;\">' + val + '</span>';\r\n }else if(val < 0){\r\n return '<span style=\"color:red;\">' + val + '</span>';\r\n }\r\n return val;", array("val")); $pctChangeRenderer = PhpExt_Javascript::functionDef("pctChange", "if(val > 0){\r\n return '<span style=\"color:green;\">' + val + '%</span>';\r\n }else if(val < 0){\r\n return '<span style=\"color:red;\">' + val + '%</span>';\r\n }\r\n return val;", array("val")); $reader = new PhpExt_Data_JsonReader(); $reader->setRoot("topics")->setTotalProperty("totalCount")->setId("id"); $reader->addField(new PhpExt_Data_FieldConfigObject("company")); $reader->addField(new PhpExt_Data_FieldConfigObject("price", null, "float")); $reader->addField(new PhpExt_Data_FieldConfigObject("change", null, "float")); $reader->addField(new PhpExt_Data_FieldConfigObject("pctChange", null, "float")); $reader->addField(new PhpExt_Data_FieldConfigObject("lastChange", null, "date", "n/j h:ia")); $reader->addField(new PhpExt_Data_FieldConfigObject("industry")); // Store $store = new PhpExt_Data_Store(); $store->setUrl($baseUrl . '/grid/json_exampledata.php')->setReader($reader)->setBaseParams(array("limit" => $PageSize)); // ColumnModel $colModel = new PhpExt_Grid_ColumnModel(); $colModel->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Company", "company", "company", 160, null, null, true, false))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Price", "price", null, 75, null, PhpExt_Javascript::variable("Ext.util.Format.usMoney"), true, true))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Change", "change", null, 75, null, PhpExt_Javascript::variable('change'), null, true))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("% Change", "pctChange", null, 75, null, PhpExt_Javascript::variable('pctChange'), null, true))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Last Updated", "lastChange", null, 85, null, PhpExt_Javascript::variable("Ext.util.Format.dateRenderer('m/d/Y')"), null, true))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Industry", "industry", null, 85, null, null, true, true)); // Grid $grid = new PhpExt_Grid_GridPanel(); $grid->setStore($store)->setColumnModel($colModel)->setStripeRows(true)->setAutoExpandColumn("company")->setHeight(350)->setWidth(600)->setTitle("Json Grid"); $paging = new PhpExt_Toolbar_PagingToolbar(); $paging->setStore($store)->setPageSize($PageSize)->setDisplayInfo("Topics {0} - {1} of {2}")->setEmptyMessage("No topics to display"); $grid->setBottomToolbar($paging); // Ext.OnReady ----------------------- echo PhpExt_Ext::onReady($changeRenderer, $pctChangeRenderer, $store->getJavascript(false, "store"), $store->load(new PhpExt_Data_StoreLoadOptions(array("start" => 0, "limit" => $PageSize))), $grid->getJavascript(false, "grid"), $grid->render("grid-example"));
$tabs2->addItem($columnPanel2); //- First column $firstColumn2 = new PhpExt_Panel(); // Use FormLayout to enable field labels and autoarrange fields on the panel $firstColumn2->setBorder(false)->setLayout(new PhpExt_Layout_FormLayout()); // Anchor the field to 95% of the panel by setting AnchorLayoutData (FormLayout extends AnchorLayout) $firstColumn2->addItem(PhpExt_Form_TextField::createTextField("first", "First Name"), new PhpExt_Layout_AnchorLayoutData("95%"))->addItem(PhpExt_Form_TextField::createTextField("company", "Company"), new PhpExt_Layout_AnchorLayoutData("95%")); // adds the panel as a 50% column using ColumnLayoutData $columnPanel2->addItem($firstColumn2, new PhpExt_Layout_ColumnLayoutData(0.5)); //- Second column $secondColumn2 = new PhpExt_Panel(); $secondColumn2->setBorder(false)->setLayout(new PhpExt_Layout_FormLayout())->addItem(PhpExt_Form_TextField::createTextField("last", "Last Name"), new PhpExt_Layout_AnchorLayoutData("95%"))->addItem(PhpExt_Form_TextField::createTextField("email", "Email")->setVType(PhpExt_Form_FormPanel::VTYPE_EMAIL), new PhpExt_Layout_AnchorLayoutData("95%")); $columnPanel2->addItem($secondColumn2, new PhpExt_Layout_ColumnLayoutData(0.5)); //- Tab Panel $tabPanel2 = new PhpExt_TabPanel(); $tabPanel2->setPlain(true)->setActiveTab(0)->setHeight(235)->setDefaults(new PhpExt_Config_ConfigObject(array("bodyStyle" => "padding:10px"))); $detailsTab2 = new PhpExt_Panel(); $detailsTab2->setTitle("Personal Details")->setLayout(new PhpExt_Layout_FormLayout())->setDefaults(new PhpExt_Config_ConfigObject(array("width" => 230)))->setDefaultType("textfield")->addItem(PhpExt_Form_TextField::createTextField("first", "First Name")->setAllowBlank(false)->setValue("Jack"))->addItem(PhpExt_Form_TextField::createTextField("company", "Company")->setValue("Slocum"))->addItem(PhpExt_Form_TextField::createTextField("last", "Last Name")->setValue("Ext JS"))->addItem(PhpExt_Form_TextField::createTextField("email", "Email")->setVType(PhpExt_Form_FormPanel::VTYPE_EMAIL)); $phonesTab2 = new PhpExt_Panel(); $phonesTab2->setTitle("Phone Numbers")->setLayout(new PhpExt_Layout_FormLayout())->setDefaults(new PhpExt_Config_ConfigObject(array("width" => 230)))->setDefaultType("textfield")->addItem(PhpExt_Form_TextField::createTextField("home", "Home")->setValue("(888) 555-1212"))->addItem(PhpExt_Form_TextField::createTextField("business", "Business"))->addItem(PhpExt_Form_TextField::createTextField("mobile", "Mobile"))->addItem(PhpExt_Form_TextField::createTextField("fax", "Fax")); $bioTab = new PhpExt_Panel(); $bioTab->setCssClass("x-plain")->setTitle("Biography")->setLayout(new PhpExt_Layout_FitLayout())->addItem(PhpExt_Form_HtmlEditor::createHtmlEditor("bio2", "Biography", "bio2")); $tabPanel2->addItem($detailsTab2); $tabPanel2->addItem($phonesTab2); $tabPanel2->addItem($bioTab); $tabs2->addItem($tabPanel2); $tabs2->addButton(PhpExt_Button::createTextButton("Save")); $tabs2->addButton(PhpExt_Button::createTextButton("Cancel")); //****************************** onReady echo PhpExt_Ext::onReady(PhpExt_QuickTips::init(), PhpExt_Javascript::assign("bd", "Ext.get('centercolumn')"), PhpExt_Javascript::stm("bd.createChild({tag: 'h2', html: 'Form 1 - Very Simple'})"), $simple->getJavascript(false, "simple"), $simple->render(PhpExt_Javascript::variable("Ext.get('centercolumn')")), PhpExt_Javascript::stm("bd.createChild({tag: 'h2', html: 'Form 2 - Adding fieldsets'})"), $fsf->getJavascript(false, "fsf"), $fsf->render(PhpExt_Javascript::variable("Ext.get('centercolumn')")), PhpExt_Javascript::stm("bd.createChild({tag: 'h2', html: 'Form 3 - A little more complex'})"), $top->getJavascript(false, "top"), $top->render(PhpExt_Javascript::variable("Ext.get('centercolumn')")), PhpExt_Javascript::stm("bd.createChild({tag: 'h2', html: 'Form 4 - Forms can be a TabPanel...'})"), $tabs->getJavascript(false, "tabs"), $tabs->render(PhpExt_Javascript::variable("Ext.get('centercolumn')")), PhpExt_Javascript::stm("bd.createChild({tag: 'h2', html: 'Form 5 - ... and forms can contain TabPanel(s)'})"), $tabs2->getJavascript(false, "tabs2"), $tabs2->render(PhpExt_Javascript::variable("Ext.get('centercolumn')")));
set_include_path(get_include_path() . PATH_SEPARATOR . realpath('../../library')); include_once 'PhpExt/Javascript.php'; PhpExt_Javascript::sendContentType(); include_once 'PhpExt/Ext.php'; include_once 'PhpExt/Window.php'; include_once 'PhpExt/Form/FormPanel.php'; include_once 'PhpExt/Form/TextField.php'; include_once 'PhpExt/Form/TextArea.php'; include_once 'PhpExt/Button.php'; include_once 'PhpExt/Layout/FitLayout.php'; include_once 'PhpExt/Layout/AnchorLayoutData.php'; $form = new PhpExt_Form_FormPanel(); // Properties can be set by using the closures... $form->setBaseCssClass("x-plain")->setLabelWidth(55)->setUrl("save-form.php")->setDefaultType("textfield"); // or in the traditional way. $textfield1 = new PhpExt_Form_TextField(); $textfield1->setName("to"); $textfield1->setFieldLabel("Send To"); $form->addItem($textfield1, new PhpExt_Layout_AnchorLayoutData("100%")); // anchor width by percentage $textfield2 = PhpExt_Form_TextField::createTextField("subject", "Subject"); $form->addItem($textfield2, new PhpExt_Layout_AnchorLayoutData("100%")); $textarea = PhpExt_Form_TextArea::createTextArea("msg")->setHideLabel(true); $form->addItem($textarea, new PhpExt_Layout_AnchorLayoutData("100% -53")); $window = new PhpExt_Window(); $window->setTitle("Resize Me")->setWidth(500)->setHeight(300)->setMinWidth(300)->setMinHeight(200)->setLayout(new PhpExt_Layout_FitLayout())->setPlain(true)->setBodyStyle("padding:5px")->setButtonAlign(PhpExt_Ext::HALIGN_CENTER); $window->addButton(PhpExt_Button::createTextButton("Send")); $window->addButton(PhpExt_Button::createTextButton("Cancel")); $window->addItem($form); echo PhpExt_Ext::onReady($form->getJavascript(false, "form"), $window->getJavascript(false, "window"), $window->show());
$viewport->addItem($east, PhpExt_Layout_BorderLayoutData::createEastRegion()->setSplit(true)->setMinSize(175)->setMaxSize(400)->setMargins("0 5 0 0")); // West Region $west = new PhpExt_Panel(); $west->setTitle("West")->setCollapsible(true)->setWidth(200)->setId("west-panel"); $accordion = new PhpExt_Layout_AccordionLayout(); $accordion->setAnimate(true); $west->setLayout($accordion); // panel 1 $p1 = new PhpExt_Panel(); $p1->setContentElement("west")->setTitle("Navigation")->setBorder(false)->setIconCssClass("nav"); $west->addItem($p1); // panel 2 $p2 = new PhpExt_Panel(); $p2->setHtml('<p>Some settings in here.</p>')->setTitle("Settings")->setBorder(false)->setIconCssClass("settings"); $west->addItem($p2); $viewport->addItem($west, PhpExt_Layout_BorderLayoutData::createWestRegion()->setSplit(true)->setMinSize(175)->setMaxSize(400)->setMargins("0 0 0 5")); // Center Region $center = new PhpExt_TabPanel(); $center->setActiveTab(0); $tabLayout = new PhpExt_Layout_TabLayout(); $tabLayout->setDeferredRender(true); $center->setLayout($tabLayout); $c1 = new PhpExt_Panel(); $c1->setContentElement("center1")->setTitle("Close Me")->setAutoScroll(true); $center->addItem($c1, new PhpExt_Layout_TabLayoutData(true)); $c2 = new PhpExt_Panel(); $c2->setContentElement("center2")->setTitle("Center Panel")->setAutoScroll(true); $center->addItem($c2); $viewport->addItem($center, PhpExt_Layout_BorderLayoutData::createCenterRegion()); echo PhpExt_Ext::OnReady($viewport->getJavascript(false, "v"), $viewport->render("viewport"));
<?php set_include_path(get_include_path() . PATH_SEPARATOR . realpath('../../library')); include_once 'PhpExt/Javascript.php'; PhpExt_Javascript::sendContentType(); include_once 'PhpExt/Ext.php'; include_once 'PhpExt/Tree/TreePanel.php'; include_once 'PhpExt/Tree/TreeLoader.php'; include_once 'PhpExt/Tree/AsyncTreeNode.php'; $loader = new PhpExt_Tree_TreeLoader(); $loader->setDataUrl("examples/tree/get-nodes.php"); $tree = new PhpExt_Tree_TreePanel(); $tree->setUseArrows(true)->setAnimate(true)->setEnableDd(true)->setContainerScroll(true)->setLoader($loader)->setAutoScroll(true); $root = new PhpExt_Tree_AsyncTreeNode(); $root->setText("PHP-Ext Examples")->setDraggable(false)->setId("examples"); echo PhpExt_Ext::OnReady($tree->getJavascript(false, "tree"), $root->getJavascript(false, "root"), $tree->setRootNode($root), $tree->render("tree-div"), $root->expand());
$txtCommon = PhpExt_Form_TextField::createTextField('txtCommon')->setAllowBlank(false); $cmbLight = PhpExt_Form_ComboBox::createComboBox("cmbLight")->setTypeAhead(true)->setTriggerAction(PhpExt_Form_ComboBox::TRIGGER_ACTION_ALL)->setTransform("light")->setLazyRender(true)->setListCssClass('x-combo-list-small'); $txtPrice = PhpExt_Form_NumberField::createNumberField("txtPrice")->setAllowBlank(false)->setAllowNegative(false)->setMaxValue(100000); $dtAvailable = PhpExt_Form_DateField::createDateField("dtAvaliable")->setFormat("m/d/y")->setMinValue("01/01/06")->setDisabledDays(array(0, 6))->setDisabledDaysText("Plants are not available on the weekends"); $colModel = new PhpExt_Grid_ColumnModel(); $colModel->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Common Name", "common", "common", 220)->setEditor($txtCommon))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Light", "light", null, 130)->setEditor($cmbLight))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Price", "price", "price", 70, PhpExt_Ext::HALIGN_RIGHT, "usMoney")->setEditor($txtPrice))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Avaliable", "availDate", "availDate", 95, null, PhpExt_Javascript::variable('formatDate'))->setEditor($dtAvailable))->addColumn($checkColumn); // this could be inline, but we want to define the Plant record // type so we can add records dynamically $fields = new PhpExt_Data_FieldConfigObjectCollection(); $fields->add(new PhpExt_Data_FieldConfigObject("common", null, PhpExt_Data_FieldConfigObject::TYPE_STRING)); $fields->add(new PhpExt_Data_FieldConfigObject("botanical", null, PhpExt_Data_FieldConfigObject::TYPE_STRING)); $fields->add(new PhpExt_Data_FieldConfigObject("light")); $fields->add(new PhpExt_Data_FieldConfigObject("price", null, PhpExt_Data_FieldConfigObject::TYPE_FLOAT)); $fields->add(new PhpExt_Data_FieldConfigObject("availDate", "availability", PhpExt_Data_FieldConfigObject::TYPE_DATE, "m/d/Y")); $fields->add(new PhpExt_Data_FieldConfigObject("indoor", null, PhpExt_Data_FieldConfigObject::TYPE_BOOLEAN)); $plant = PhpExt_Data_Record::create($fields); // Reader $reader = new PhpExt_Data_XmlReader(); $reader->setRecord("plant"); $reader->setRecordType("Plant"); // Store $store = new PhpExt_Data_Store(); $store->setUrl("examples/grid/plants.xml")->setReader($reader)->setSortInfo(new PhpExt_Data_SortInfoConfigObject("common")); // Grid $grid = new PhpExt_Grid_EditorGridPanel(); $grid->setClicksToEdit(1)->setStore($store)->setColumnModel($colModel)->setAutoExpandColumn("common")->setFrame(true)->setHeight(300)->setWidth(600)->setTitle("Edit Plants?")->setRenderTo("editor-grid"); $grid->getPlugins()->add($checkColumn); $grid->getTopToolbar()->addButton("add", "Add Plant", null, new PhpExt_Handler(PhpExt_Javascript::inlineStm("var p = new Plant({\r\n common: 'New Plant 1',\r\n light: 'Mostly Shade',\r\n price: 0,\r\n availDate: (new Date()).clearTime(),\r\n indoor: false\r\n });\r\n grid.stopEditing();\r\n store.insert(0, p);\r\n grid.startEditing(0, 0);"))); // Ext.OnReady ----------------------- echo PhpExt_Ext::onReady(PhpExt_QuickTips::init(), $formatDate, $checkColumn->getJavascript(false, "checkColumn"), $colModel->getJavascript(false, "cm"), PhpExt_Javascript::assignNew("Plant", $plant), $store->getJavascript(false, "store"), $grid->getJavascript(false, "grid"), $store->load());
public static function Render($dataModel, $object, $PageSize = 5, $Titulo = '') { include_once 'PhpExt/Ext.php'; include_once 'PhpExt/Data/SimpleStore.php'; include_once 'PhpExt/Data/ArrayReader.php'; include_once 'PhpExt/Data/JsonReader.php'; include_once 'PhpExt/Data/ScriptTagProxy.php'; include_once 'PhpExt/Data/FieldConfigObject.php'; include_once 'PhpExt/Data/StoreLoadOptions.php'; include_once 'PhpExt/Data/HttpProxy.php'; include_once 'PhpExt/Data/JsonStore.php'; include_once 'PhpExt/Button.php'; include_once 'PhpExt/Toolbar/PagingToolbar.php'; include_once 'PhpExt/Grid/ColumnModel.php'; include_once 'PhpExt/Grid/ColumnConfigObject.php'; include_once 'PhpExt/Grid/GridPanel.php'; include_once 'PhpExt/Window.php'; include_once 'PhpExt/Form/FormPanel.php'; include_once 'PhpExt/Ext.php'; include_once 'PhpExt/Data/Store.php'; include_once 'PhpExt/Data/ArrayReader.php'; include_once 'PhpExt/Data/FieldConfigObject.php'; include_once 'PhpExt/Grid/ColumnModel.php'; include_once 'PhpExt/Grid/ColumnConfigObject.php'; include_once 'PhpExt/Panel.php'; include_once 'PhpExt/Grid/GridPanel.php'; include_once 'PhpExt/Grid/RowSelectionModel.php'; include_once 'PhpExt/Listener.php'; include_once 'PhpExt/Config/ConfigObject.php'; include_once 'PhpExt/Form/FormPanel.php'; include_once 'PhpExt/Form/FieldSet.php'; include_once 'PhpExt/Form/TextField.php'; include_once 'PhpExt/QuickTips.php'; include_once 'PhpExt/Layout/ColumnLayout.php'; include_once 'PhpExt/Layout/ColumnLayoutData.php'; include_once 'PhpExt/Layout/FitLayout.php'; $reader = new PhpExt_Data_JsonReader(); $reader->setRoot("topics")->setTotalProperty("totalCount")->setId("ID"); foreach ($object->properties as $k => $v) { $reader->addField(new PhpExt_Data_FieldConfigObject($k)); } $store = new PhpExt_Data_Store(); $store->setUrl('action_main.php')->setReader($reader)->setBaseParams(array("limit" => $PageSize)); $colModel = new PhpExt_Grid_ColumnModel(); foreach ($object->properties as $k => $v) { if (strpos($k, "S_") !== 0) { $colModel->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn($object->properties_desc[$k], $k, $k, null, null, null, true, true)); } } readfile(dirname(__FILE__) . "/local/Tmpl/PhpExt.tmpl"); $selModel = new PhpExt_Grid_RowSelectionModel(); $selModel->setSingleSelect(true)->attachListener("rowselect", new PhpExt_Listener(PhpExt_Javascript::functionDef(null, "Ext.getCmp(\"idGrid\").getForm().loadRecord(rec);", array("sm", "row", "rec")))); // Grid $grid = new PhpExt_Grid_GridPanel("idGrid"); $grid->setStore($store)->setColumnModel($colModel)->setStripeRows(true)->setWidth(500)->setHeight(350)->setTitle("Elementos"); $grid->setSelectionModel($selModel); $paging = new PhpExt_Toolbar_PagingToolbar(); $paging->setStore($store)->setPageSize($PageSize)->setDisplayInfo("Topics {0} - {1} of {2}")->setEmptyMessage("No topics to display"); $grid->setBottomToolbar($paging); $window = new PhpExt_Window(); $window->setTitle($Titulo)->setWidth(600)->setHeight(450)->setMinWidth(300)->setMinHeight(200)->setPlain(true)->setBodyStyle("padding:5px")->setButtonAlign(PhpExt_Ext::HALIGN_CENTER); $window->addButton(PhpExt_Button::createTextButton("Editar")); $window->addButton(PhpExt_Button::createTextButton("Borrar")); $window->addItem($grid); // Ext.OnReady ----------------------- echo PhpExt_Ext::onReady(null, null, $store->getJavascript(false, "store"), $store->load(new PhpExt_Data_StoreLoadOptions(array("start" => 0, "limit" => $PageSize))), $grid->getJavascript(false, "grid"), $window->getJavascript(false, "window"), $window->show()); echo "</script>"; }
set_include_path(get_include_path() . PATH_SEPARATOR . realpath('../../library')); include_once 'PhpExt/Javascript.php'; PhpExt_Javascript::sendContentType(); include_once 'PhpExt/Ext.php'; include_once 'PhpExt/Data/SimpleStore.php'; include_once 'PhpExt/Data/ArrayReader.php'; include_once 'PhpExt/Data/FieldConfigObject.php'; include_once 'PhpExt/Grid/ColumnModel.php'; include_once 'PhpExt/Grid/ColumnConfigObject.php'; include_once 'PhpExt/Grid/GridPanel.php'; // Sample Data $myData = array(array('3m Co', 71.72, 0.02, 0.03, '9/1 12:00am'), array('Alcoa Inc', 29.01, 0.42, 1.47, '9/1 12:00am'), array('Altria Group Inc', 83.81, 0.28, 0.34, '9/1 12:00am'), array('American Express Company', 52.55, 0.01, 0.02, '9/1 12:00am'), array('American International Group, Inc.', 64.13, 0.31, 0.49, '9/1 12:00am'), array('AT&T Inc.', 31.61, -0.48, -1.54, '9/1 12:00am'), array('Boeing Co.', 75.43000000000001, 0.53, 0.71, '9/1 12:00am'), array('Caterpillar Inc.', 67.27, 0.92, 1.39, '9/1 12:00am'), array('Citigroup, Inc.', 49.37, 0.02, 0.04, '9/1 12:00am'), array('E.I. du Pont de Nemours and Company', 40.48, 0.51, 1.28, '9/1 12:00am'), array('Exxon Mobil Corp', 68.09999999999999, -0.43, -0.64, '9/1 12:00am'), array('General Electric Company', 34.14, -0.08, -0.23, '9/1 12:00am'), array('General Motors Corporation', 30.27, 1.09, 3.74, '9/1 12:00am'), array('Hewlett-Packard Co.', 36.53, -0.03, -0.08, '9/1 12:00am'), array('Honeywell Intl Inc', 38.77, 0.05, 0.13, '9/1 12:00am'), array('Intel Corporation', 19.88, 0.31, 1.58, '9/1 12:00am'), array('International Business Machines', 81.41, 0.44, 0.54, '9/1 12:00am'), array('Johnson & Johnson', 64.72, 0.06, 0.09, '9/1 12:00am'), array('JP Morgan & Chase & Co', 45.73, 0.07000000000000001, 0.15, '9/1 12:00am'), array('McDonald\'s Corporation', 36.76, 0.86, 2.4, '9/1 12:00am'), array('Merck & Co., Inc.', 40.96, 0.41, 1.01, '9/1 12:00am'), array('Microsoft Corporation', 25.84, 0.14, 0.54, '9/1 12:00am'), array('Pfizer Inc', 27.96, 0.4, 1.45, '9/1 12:00am'), array('The Coca-Cola Company', 45.07, 0.26, 0.58, '9/1 12:00am'), array('The Home Depot, Inc.', 34.64, 0.35, 1.02, '9/1 12:00am'), array('The Procter & Gamble Company', 61.91, 0.01, 0.02, '9/1 12:00am'), array('United Technologies Corporation', 63.26, 0.55, 0.88, '9/1 12:00am'), array('Verizon Communications', 35.57, 0.39, 1.11, '9/1 12:00am'), array('Wal-Mart Stores, Inc.', 45.45, 0.73, 1.63, '9/1 12:00am')); $changeRenderer = PhpExt_Javascript::functionDef("change", "if(val > 0){\r\n return '<span style=\"color:green;\">' + val + '</span>';\r\n }else if(val < 0){\r\n return '<span style=\"color:red;\">' + val + '</span>';\r\n }\r\n return val;", array("val")); $pctChangeRenderer = PhpExt_Javascript::functionDef("pctChange", "if(val > 0){\r\n return '<span style=\"color:green;\">' + val + '%</span>';\r\n }else if(val < 0){\r\n return '<span style=\"color:red;\">' + val + '%</span>';\r\n }\r\n return val;", array("val")); // Store $store = new PhpExt_Data_SimpleStore(); $store->addField(new PhpExt_Data_FieldConfigObject("company")); $store->addField(new PhpExt_Data_FieldConfigObject("price", null, "float")); $store->addField(new PhpExt_Data_FieldConfigObject("change", null, "float")); $store->addField(new PhpExt_Data_FieldConfigObject("pctChange", null, "float")); $store->addField(new PhpExt_Data_FieldConfigObject("lastChange", null, "date", "n/j h:ia")); // ColumnModel $colModel = new PhpExt_Grid_ColumnModel(); $colModel->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Company", "company", "company", 160, null, null, true, false))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Price", "price", null, 75, null, PhpExt_Javascript::variable("Ext.util.Format.usMoney"), null, true))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Change", "change", null, 75, null, PhpExt_Javascript::variable('change'), null, true))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("% Change", "pctChange", null, 75, null, PhpExt_Javascript::variable('pctChange'), null, true))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Last Updated", "lastChange", null, 85, null, PhpExt_Javascript::variable("Ext.util.Format.dateRenderer('m/d/Y')"), null, true)); // Grid $grid = new PhpExt_Grid_GridPanel(); $grid->setStore($store)->setColumnModel($colModel)->setStripeRows(true)->setAutoExpandColumn("company")->setHeight(350)->setWidth(600)->setTitle("Array Grid"); // Ext.OnReady ----------------------- echo PhpExt_Ext::onReady(PhpExt_Javascript::assignNew("myData", PhpExt_Javascript::valueToJavascript($myData)), $changeRenderer, $pctChangeRenderer, $store->getJavascript(false, "store"), $store->loadData(PhpExt_Javascript::variable("myData")), $grid->getJavascript(false, "grid"), $grid->render("grid-example"));
include_once 'PhpExt/Grid/GridPanel.php'; include_once 'PhpExt/Grid/GroupingView.php'; // Sample Data $myData = array(array('3m Co', 71.72, 0.02, 0.03, '4/2 12:00am', 'Manufacturing'), array('Alcoa Inc', 29.01, 0.42, 1.47, '4/1 12:00am', 'Manufacturing'), array('Altria Group Inc', 83.81, 0.28, 0.34, '4/3 12:00am', 'Manufacturing'), array('American Express Company', 52.55, 0.01, 0.02, '4/8 12:00am', 'Finance'), array('American International Group, Inc.', 64.13, 0.31, 0.49, '4/1 12:00am', 'Services'), array('AT&T Inc.', 31.61, -0.48, -1.54, '4/8 12:00am', 'Services'), array('Boeing Co.', 75.43000000000001, 0.53, 0.71, '4/8 12:00am', 'Manufacturing'), array('Caterpillar Inc.', 67.27, 0.92, 1.39, '4/1 12:00am', 'Services'), array('Citigroup, Inc.', 49.37, 0.02, 0.04, '4/4 12:00am', 'Finance'), array('E.I. du Pont de Nemours and Company', 40.48, 0.51, 1.28, '4/1 12:00am', 'Manufacturing'), array('Exxon Mobil Corp', 68.09999999999999, -0.43, -0.64, '4/3 12:00am', 'Manufacturing'), array('General Electric Company', 34.14, -0.08, -0.23, '4/3 12:00am', 'Manufacturing'), array('General Motors Corporation', 30.27, 1.09, 3.74, '4/3 12:00am', 'Automotive'), array('Hewlett-Packard Co.', 36.53, -0.03, -0.08, '4/3 12:00am', 'Computer'), array('Honeywell Intl Inc', 38.77, 0.05, 0.13, '4/3 12:00am', 'Manufacturing'), array('Intel Corporation', 19.88, 0.31, 1.58, '4/2 12:00am', 'Computer'), array('International Business Machines', 81.41, 0.44, 0.54, '4/1 12:00am', 'Computer'), array('Johnson & Johnson', 64.72, 0.06, 0.09, '4/2 12:00am', 'Medical'), array('JP Morgan & Chase & Co', 45.73, 0.07000000000000001, 0.15, '4/2 12:00am', 'Finance'), array('McDonald\'s Corporation', 36.76, 0.86, 2.4, '4/2 12:00am', 'Food'), array('Merck & Co., Inc.', 40.96, 0.41, 1.01, '4/2 12:00am', 'Medical'), array('Microsoft Corporation', 25.84, 0.14, 0.54, '4/2 12:00am', 'Computer'), array('Pfizer Inc', 27.96, 0.4, 1.45, '4/8 12:00am', 'Services', 'Medical'), array('The Coca-Cola Company', 45.07, 0.26, 0.58, '4/1 12:00am', 'Food'), array('The Home Depot, Inc.', 34.64, 0.35, 1.02, '4/8 12:00am', 'Retail'), array('The Procter & Gamble Company', 61.91, 0.01, 0.02, '4/1 12:00am', 'Manufacturing'), array('United Technologies Corporation', 63.26, 0.55, 0.88, '4/1 12:00am', 'Computer'), array('Verizon Communications', 35.57, 0.39, 1.11, '4/3 12:00am', 'Services'), array('Wal-Mart Stores, Inc.', 45.45, 0.73, 1.63, '4/3 12:00am', 'Retail'), array('Walt Disney Company (The) (Holding Company)', 29.89, 0.24, 0.8100000000000001, '4/1 12:00am', 'Services')); $changeRenderer = PhpExt_Javascript::functionDef("change", "if(val > 0){\r\n return '<span style=\"color:green;\">' + val + '</span>';\r\n }else if(val < 0){\r\n return '<span style=\"color:red;\">' + val + '</span>';\r\n }\r\n return val;", array("val")); $reader = new PhpExt_Data_ArrayReader(); $reader->addField(new PhpExt_Data_FieldConfigObject("company")); $reader->addField(new PhpExt_Data_FieldConfigObject("price", null, "float")); $reader->addField(new PhpExt_Data_FieldConfigObject("change", null, "float")); $reader->addField(new PhpExt_Data_FieldConfigObject("pctChange", null, "float")); $reader->addField(new PhpExt_Data_FieldConfigObject("lastChange", null, "date", "n/j h:ia")); $reader->addField(new PhpExt_Data_FieldConfigObject("industry")); // Store $store = new PhpExt_Data_GroupingStore(); $store->setSortInfo(new PhpExt_Data_SortInfoConfigObject("company")); $store->setGroupField("industry"); $store->setReader($reader); $store->setData($myData); // ColumnModel $colModel = new PhpExt_Grid_ColumnModel(); $colModel->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Company", "company", "company", 60, null, null, true, false))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Price", "price", null, 20, null, PhpExt_Javascript::variable("Ext.util.Format.usMoney"), true))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Change", "change", null, 20, null, PhpExt_Javascript::variable('change'), true))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Industry", "industry", null, 20, null, null, true))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Last Updated", "lastChange", null, 20, null, PhpExt_Javascript::variable("Ext.util.Format.dateRenderer('m/d/Y')"), true)); // View $view = new PhpExt_Grid_GroupingView(); $view->setForceFit(true); $view->setGroupTextTemplate('{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})'); // Grid $grid = new PhpExt_Grid_GridPanel(); $grid->setStore($store)->setColumnModel($colModel)->setView($view)->setFrame(true)->setCollapsible(true)->setAnimCollapse(true)->setTitle("Grouping Example")->setIconCssClass("icon-grid")->setRenderTo("grouping-example")->setWidth(700)->setHeight(450); // Ext.OnReady ----------------------- echo PhpExt_Ext::onReady(PhpExt_Javascript::assignNew("myData", PhpExt_Javascript::valueToJavascript($myData)), $changeRenderer, $store->getJavascript(false, "store"), $grid->getJavascript(false, "grid"));
include_once 'PhpExt/MessageBox.php'; include_once 'PhpExt/MessageBoxOptions.php'; include_once 'PhpExt/ProgressBarWaitConfig.php'; $mb1Element = PhpExt_Element::getById('mb1'); $mb1Handler = PhpExt_Javascript::functionDef(null, PhpExt_MessageBox::confirm("Confirm", "Are you sure you want to do that", PhpExt_Javascript::variable('showResult')), array("e")); $mb2Element = PhpExt_Element::getById('mb2'); $mb2Handler = PhpExt_Javascript::functionDef(null, PhpExt_MessageBox::prompt("Name", "Please enter your name:", PhpExt_Javascript::variable('showResultText')), array("e")); $mb3Element = PhpExt_Element::getById('mb3'); $mb3Options = PhpExt_MessageBoxOptions::createMsgOptions()->setTitle('Address')->setMsg('Please enter your address:')->setWidth(300)->setButtons(PhpExt_MessageBox::OKCANCEL())->setMultiline(true)->setFn(PhpExt_Javascript::variable('showResultText'))->setAnimEl('mb3'); $mb3Handler = PhpExt_Javascript::functionDef(null, PhpExt_MessageBox::show($mb3Options)); $mb4Element = PhpExt_Element::getById('mb4'); $mb4Options = PhpExt_MessageBoxOptions::createMsgOptions()->setTitle('Save Changes?')->setMsg('You are closing a tab that has unsaved changes. <br />Would you like to save your changes?')->setButtons(PhpExt_MessageBox::YESNOCANCEL())->setFn(PhpExt_Javascript::variable('showResult'))->setAnimEl('mb4')->setIcon(PhpExt_MessageBox::QUESTION()); $mb4Handler = PhpExt_Javascript::functionDef(null, PhpExt_MessageBox::show($mb4Options)); $mb6Element = PhpExt_Element::getById('mb6'); $mb6Options = PhpExt_MessageBoxOptions::createMsgOptions()->setTitle('Please wait')->setMsg('Loading items...')->setProgressText('Initializing...')->setWidth(300)->setProgress(true)->setClosable(false)->setAnimEl('mb6'); $mb6Hide = PhpExt_MessageBox::hide()->output(); $mb6Progress = PhpExt_MessageBox::updateProgress(PhpExt_Javascript::variable("i"), PhpExt_Javascript::inlineStm("Math.round(100*i)+'% completed'"))->output(); $mb6Handler = PhpExt_Javascript::functionDef(null, PhpExt_MessageBox::show($mb6Options)->output() . "\r\n\t\t// this hideous block creates the bogus progress\r\n var f = function(v){\r\n return function(){\r\n if(v == 12){\r\n " . $mb6Hide . ";\r\n Ext.example.msg('Done', 'Your fake items were loaded!');\r\n }else{\r\n var i = v/11;\r\n\t\t\t\t\t" . $mb6Progress . "; \r\n }\r\n };\r\n };\r\n for(var i = 1; i < 13; i++){\r\n setTimeout(f(i), i*500);\r\n }"); $mb7Element = PhpExt_Element::getById('mb7'); $mb7Options = PhpExt_MessageBoxOptions::createMsgOptions()->setMsg('Saving your data, please wait...')->setProgressText('Saving...')->setWait(true)->setWaitConfig(PhpExt_ProgressBarWaitConfig::createWaitConfig()->setInterval(200))->setIcon('ext-mb-download')->setAnimEl('mb7'); $mb7Handler = PhpExt_Javascript::functionDef(null, PhpExt_MessageBox::show($mb7Options)->output() . "\r\n\t\tsetTimeout(function(){\r\n //This simulates a long-running operation like a database save or XHR call.\r\n //In real code, this would be in a callback function.\r\n " . PhpExt_MessageBox::hide()->output() . ";\r\n Ext.example.msg('Done', 'Your fake data was saved!');\r\n }, 8000);"); $mb8Element = PhpExt_Element::getById('mb8'); $mb8Handler = PhpExt_Javascript::functionDef(null, PhpExt_MessageBox::alert("Status", "Changes saved successfully.", PhpExt_Javascript::variable('showResult'))); $comboValues = PhpExt_Javascript::stm("\r\n\t//Add these values dynamically so they aren't hard-coded in the html\r\n Ext.fly('info').dom.value = Ext.MessageBox.INFO;\r\n Ext.fly('question').dom.value = Ext.MessageBox.QUESTION;\r\n Ext.fly('warning').dom.value = Ext.MessageBox.WARNING;\r\n Ext.fly('error').dom.value = Ext.MessageBox.ERROR;\r\n"); $mb9Element = PhpExt_Element::getById('mb9'); $mb9Options = PhpExt_MessageBoxOptions::createMsgOptions()->setTitle('Icon Support')->setMsg('Here is a message with an icon!')->setButtons(PhpExt_MessageBox::OK())->setFn(PhpExt_Javascript::variable('showResult'))->setAnimEl('mb9')->setIcon(PhpExt_Javascript::variable("Ext.get('icons').dom.value")); $mb9Handler = PhpExt_Javascript::functionDef(null, PhpExt_MessageBox::show($mb9Options)); $showResult = PhpExt_Javascript::stm("function showResult(btn){\r\n Ext.example.msg('Button Click', 'You clicked the {0} button', btn);\r\n };"); $showResultText = PhpExt_Javascript::stm("function showResultText(btn, text){\r\n Ext.example.msg('Button Click', 'You clicked the {0} button and entered the text \"{1}\".', btn, text);\r\n };"); echo PhpExt_Ext::OnReady($mb1Element->on("click", $mb1Handler), $mb2Element->on("click", $mb2Handler), $mb3Element->on("click", $mb3Handler), $mb4Element->on("click", $mb4Handler), $mb6Element->on("click", $mb6Handler), $mb7Element->on("click", $mb7Handler), $mb8Element->on("click", $mb8Handler), $comboValues, $mb9Element->on("click", $mb9Handler), $showResult, $showResultText);
<?php set_include_path(get_include_path() . PATH_SEPARATOR . realpath('../../library')); include_once 'PhpExt/Javascript.php'; PhpExt_Javascript::sendContentType(); include_once 'PhpExt/Ext.php'; include_once 'PhpExt/Handler.php'; include_once 'PhpExt/Template.php'; include_once 'PhpExt/XTemplate.php'; include_once 'PhpExt/Panel.php'; include_once 'PhpExt/Toolbar/Toolbar.php'; $data = array('name' => 'Jack Slocum', 'company' => 'Ext JS, LLC', 'address' => '4 Red Bulls Drive', 'city' => 'Cleveland', 'state' => 'Ohio', 'zip' => '44102', 'kids' => array(array('name' => 'Sara Grace', 'age' => 3), array('name' => 'Zachary', 'age' => 2), array('name' => 'John James', 'age' => 0))); /* Example 1: Basic Template */ $t = new PhpExt_Template("<p>Name: {name}</p>", "<p>Company: {company}</p>", '<p>Location: {city}, {state}</p>'); $p = new PhpExt_Panel(); $p->setTitle('Basic Template')->setWidth('300')->setHtml('<p><i>Apply the template to see results here</i></p>'); $tb = $p->getTopToolbar(); $tb->addButton("apply", "Apply Template", null, new PhpExt_Handler(PhpExt_Javascript::stm($t->getJavascript(false, "tpl")), $t->overwrite(PhpExt_Javascript::variable("p.body"), PhpExt_Javascript::variable("data")))); $p->setRenderTo(PhpExt_Javascript::inlineStm("Ext.get('centercolumn')")); /** Example 2: XTemplate */ $t2 = new PhpExt_XTemplate('<p>Name: {name}</p>', '<p>Company: {company}</p>', '<p>Location: {city}, {state}</p>', '<p>Kids: ', '<tpl for="kids" if="name==\\\'Jack Slocum\\\'">', '<tpl if="age > 1"><p>{#}. {parent.name}\\\'s kid - {name}</p></tpl>', '</tpl></p>'); //$t2->VarName = "tpl2"; $p2 = new PhpExt_Panel(); $p2->setTitle('XTemplate')->setWidth('300')->setHtml('<p><i>Apply the template to see results here</i></p>'); $tb2 = $p2->getTopToolbar(); $tb2->addButton("apply", "Apply Template", null, new PhpExt_Handler(PhpExt_Javascript::stm($t2->getJavascript(false, "tpl2")), $t2->overwrite(PhpExt_Javascript::variable("p2.body"), PhpExt_Javascript::variable("data")))); $p2->setRenderTo(PhpExt_Javascript::variable("Ext.get('centercolumn')")); echo PhpExt_Ext::onReady(PhpExt_Javascript::stm("var data = " . PhpExt_Javascript::jsonEncode($data) . ";"), $p->getJavascript(false, "p"), $p2->getJavascript(false, "p2"));
<?php set_include_path(get_include_path() . PATH_SEPARATOR . realpath('../../library')); include_once 'PhpExt/Javascript.php'; PhpExt_Javascript::sendContentType(); include_once 'PhpExt/Ext.php'; include_once 'PhpExt/Data/SimpleStore.php'; include_once 'PhpExt/Data/FieldConfigObject.php'; include_once 'PhpExt/Form/ComboBox.php'; include_once 'PhpExt/QuickTips.php'; // simple array store $store = new PhpExt_Data_SimpleStore(); $store->addField("abbr"); $store->addField("state"); $store->addField("nick"); $store->setData(PhpExt_Javascript::variable("Ext.exampledata.states")); // from states.js $combo = new PhpExt_Form_ComboBox(); $combo->setStore($store)->setDisplayField("state")->setTypeAhead(true)->setMode(PhpExt_Form_ComboBox::MODE_LOCAL)->setTriggerAction(PhpExt_Form_ComboBox::TRIGGER_ACTION_ALL)->setEmptyText("Select a state...")->setSelectOnFocus(true)->setApplyTo("local-states"); $comboWithTooltip = new PhpExt_Form_ComboBox(); $comboWithTooltip->setTemplate('<tpl for="."><div ext:qtip="{state}. {nick}" class="x-combo-list-item">{state}</div></tpl>')->setStore($store)->setDisplayField("state")->setTypeAhead(true)->setMode(PhpExt_Form_ComboBox::MODE_LOCAL)->setTriggerAction(PhpExt_Form_ComboBox::TRIGGER_ACTION_ALL)->setEmptyText("Select a state...")->setSelectOnFocus(true)->setApplyTo("local-states-with-qtip"); $converted = new PhpExt_Form_ComboBox(); $converted->setTypeAhead(true)->setTriggerAction(PhpExt_Form_ComboBox::TRIGGER_ACTION_ALL)->setTransform("state")->setWidth(135)->setForceSelection(true); echo PhpExt_Ext::onReady(PhpExt_Javascript::stm(PhpExt_QuickTips::init()), $store->getJavascript(false, "store"), $combo->getJavascript(false, "combo"), $comboWithTooltip->getJavascript(false, "comboWithTooltip"), $converted->getJavascript(false, "converted"));