<?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/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"));
// 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.\""))));
$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"));