Esempio n. 1
0
// **************************** Even more fun: a login window!
$formpanelcfg = new Ext_form_FormPanel_Config();
$loginitems = array(array('fieldLabel' => 'Username', 'name' => 'loginUsername', 'allowBlank' => false), array('fieldLabel' => 'Password', 'name' => 'loginPassword', 'inputType' => 'password', 'allowBlank' => false));
$loginbuttons = array(array('text' => 'Login', 'formBind' => true));
$login = new Ext_form_FormPanel($formpanelcfg->labelWidth(80)->frame(true)->title('Please Login')->width(230)->defaultType('textfield')->monitorValid(true)->buttons($loginbuttons)->items($loginitems));
$wincfg = new Ext_Window_Config();
$jswin = new Ext_Window($wincfg->layout('fit')->width(300)->height(150)->closable(false)->resizable(false)->plain(true)->items($login));
$win = new JsVariable('win', $jswin);
$win->show();
$cfg = new Ext_Panel_Config();
$tabactions = new Ext_Panel($cfg->frame(true)->title('Actions')->collapsible(true)->contentEl('actions')->titleCollapse(true));
$cfg = new Ext_Panel_Config();
$actionpanel = new Ext_Panel($cfg->id('action-panel')->collapsible(true)->width(340)->border(false)->baseCls('x-plain')->items($tabactions)->associate('region', 'west')->associate('split', true)->associate('collapseMode', 'mini')->associate('minWidth', 150));
$cfg = new Ext_TabPanel_Config();
$jstabpanel = new Ext_TabPanel($cfg->deferredRender(false)->autoScroll(true)->activeTab(0)->items(array(array('id' => 'tab1', 'contentEl' => 'tabs', 'title' => 'Button', 'closable' => false, 'autoScroll' => true), array('id' => 'tab2', 'contentEl' => 'tabs', 'title' => 'Grid Panel', 'closable' => false, 'autoScroll' => true)))->associate('region', 'center')->associate('margins', '0 4 4 0')->associate('title', 'Main')->associate('closable', false));
$tabpanel = new JsVariable('tabpanel', $jstabpanel);
$cfg = new Ext_Viewport_Config();
$viewport = new Ext_Viewport($cfg->layout('border')->items(array($actionpanel, $tabpanel->name())));
$viewport->jsrender();
$tabpanel->add(array('title' => 'New Tab', 'iconCls' => 'tabs', 'autoLoad' => array('url' => 'extphptest.php?content1'), 'closable' => true));
new JsReady(JsWriter::get());
?>
</script>
Click the button: <div id='button1-div'></div>
<br />
A Grid Panel: <div id='grid1-div'></div>

<ul id="actions" class="x-hidden">
	<li>
		<a id="use" href="#">Bogus Item #1</a>
	</li>
Esempio n. 2
0
 protected function parseCode($code)
 {
     $this->length = strlen($code);
     for ($i = 0; $i < $this->length; $i++) {
         switch ($code[$i]) {
             case '{':
                 //handle sub-scopes
                 $this->segments[] = '{';
                 $subScope = new JsScope(substr($code, $i + 1));
                 $this->segments[] = $subScope;
                 $i += $subScope->getLength() + 1;
                 $this->segments[] = '}';
                 break;
             case '}':
                 $this->length = $i;
                 $this->removeLastSemicolon();
                 $this->removeLastSpace();
                 break;
             case '(':
                 $this->segments[] = '(';
                 $subScope = new JsScope(substr($code, $i + 1));
                 $this->segments[] = $subScope;
                 $i += $subScope->getLength() + 1;
                 $this->segments[] = ')';
                 break;
             case ')':
                 $this->length = $i;
                 $this->removeLastSpace();
                 break;
             case "'":
                 //handle strings
                 $string = new JsString(substr($code, $i), "'");
                 $this->segments[] = $string;
                 $i += $string->getLength() - 1;
                 break;
             case '"':
                 $string = new JsString(substr($code, $i), '"');
                 $this->segments[] = $string;
                 $i += $string->getLength() - 1;
                 break;
             case '/':
                 //handle comments
                 $comment = new JsComment(substr($code, $i));
                 if ($comment->isComment()) {
                     $i += $comment->getLength() - 1;
                     break;
                 } else {
                     $lastChar = end($this->segments);
                     if (ctype_space($lastChar) || in_array($lastChar, [',', ';', '='])) {
                         $regex = new JsRegex(substr($code, $i));
                         $this->segments[] = $regex;
                         $i += $regex->getLength() - 1;
                         break;
                     }
                 }
                 // no break
             // no break
             case 'f':
                 if (substr($code, $i, 3) == 'for' && (ctype_space($code[3]) || $code[3] == '(')) {
                     $conditionStart = strpos($code, '(', $i + 3);
                     $i = $conditionStart - 1;
                     $this->segments[] = 'for';
                     break;
                 } elseif (substr($code, $i, 8) == 'function' && (ctype_space($code[8]) || $code[8] == '(')) {
                     $function = new JsFunction(substr($code, $i));
                     $this->segments[] = $function;
                     $i += $function->getLength() - 1;
                     break;
                 }
                 // no break
             // no break
             case 'i':
                 if (substr($code, $i, 2) == 'if' && (ctype_space($code[2]) || $code[2] == '(')) {
                     $conditionStart = strpos($code, '(', $i + 2);
                     $i = $conditionStart - 1;
                     $this->segments[] = 'if';
                     break;
                 }
                 // no break
             // no break
             case 'w':
                 if (substr($code, $i, 5) == 'while' && (ctype_space($code[5]) || $code[5] == '(')) {
                     $conditionStart = strpos($code, '(', $i + 5);
                     $i = $conditionStart - 1;
                     $this->segments[] = 'while';
                     break;
                 }
                 // no break
             // no break
             default:
                 if (ctype_space($code[$i])) {
                     //avoid pointless whitespaces
                     $lastChar = end($this->segments);
                     if (is_string($lastChar) && !ctype_space($lastChar) && !in_array($lastChar, self::$jsNoSpaceBehindChars, true)) {
                         $this->segments[] = ' ';
                     }
                 } else {
                     $lastChar = end($this->segments);
                     if (!$lastChar || ctype_space($lastChar) || in_array($lastChar, self::$jsNoSpaceBehindChars, true) && !in_array($code[$i], JsVariable::$jsVariableDelimiters, true)) {
                         $variable = new JsVariable(substr($code, $i));
                         if ($variable->isKeyword()) {
                             $this->segments[] = $variable->__toString();
                             $i += $variable->getLength() - 1;
                         } elseif ($variable->isFunctionCall()) {
                             $this->segments[] = $variable;
                             $i += $variable->getLength() - 1;
                         } else {
                             $this->segments[] = $variable;
                             $i += $variable->getLength() - 1;
                         }
                     } else {
                         $this->segments[] = $code[$i];
                     }
                 }
                 break;
         }
     }
 }