コード例 #1
0
 public function end()
 {
     $this->privateName = 'customgrid_' . Util::makeRandomKey();
     $storePrivateName = 'store_' . Util::makeRandomKey();
     $templatePrivateName = 'tpl_' . Util::makeRandomKey();
     $xtemplatePrivateName = 'xtpl_' . Util::makeRandomKey();
     $dataviewPrivateName = 'dv_' . Util::makeRandomKey();
     $this->attributes[$storePrivateName]['url'] = $this->proxy['url'];
     $this->attributes[$storePrivateName]['root'] = 'rows';
     $this->attributes[$storePrivateName]['fields'][] = $this->afExtjs->asAnonymousClass(array('name' => 'message'));
     $this->attributes[$storePrivateName]['fields'][] = $this->afExtjs->asAnonymousClass(array('name' => 'redirect'));
     $this->attributes[$storePrivateName]['fields'][] = $this->afExtjs->asAnonymousClass(array('name' => 'html'));
     $this->attributes[$storePrivateName]['listeners']['load'] = $this->afExtjs->asMethod(array("parameters" => "object,records,options", "source" => 'if(records.length>0&&records[0].json.redirect&&records[0].json.message){var rec=records[0].json;Ext.Msg.alert("Failure", rec.message, function(){afApp.loadCenterWidget(rec.redirect);});}'));
     $this->afExtjs->private[$storePrivateName] = $this->afExtjs->JsonStore($this->attributes[$storePrivateName]);
     unset($this->attributes[$storePrivateName]);
     $this->afExtjs->private[$templatePrivateName] = '<tpl for="."><div class="item-wrap"><div class="item">{html}</div></div></tpl><div class="x-clear"></div>';
     $this->afExtjs->private[$xtemplatePrivateName] = $this->afExtjs->XTemplate(array($templatePrivateName));
     $this->attributes[$dataviewPrivateName]['store'] = $this->afExtjs->asVar($storePrivateName);
     $this->attributes[$dataviewPrivateName]['tpl'] = $this->afExtjs->asVar($xtemplatePrivateName);
     $this->attributes[$dataviewPrivateName]['autoHeight'] = true;
     $this->attributes[$dataviewPrivateName]['multiSelect'] = true;
     $this->attributes[$dataviewPrivateName]['overClass'] = 'x-view-over';
     $this->attributes[$dataviewPrivateName]['itemSelector'] = 'div.item-wrap';
     $this->attributes[$dataviewPrivateName]['emptyText'] = 'No data to display !';
     $this->attributes[$dataviewPrivateName]['plugins'][] = "new Ext.DataView.DragSelector()";
     $this->afExtjs->private[$dataviewPrivateName] = $this->afExtjs->DataView($this->attributes[$dataviewPrivateName]);
     unset($this->attributes[$dataviewPrivateName]);
     $this->addItem($dataviewPrivateName);
     @($this->attributes['listeners']['render']["source"] .= $storePrivateName . ".load();");
     $attributes['listeners']['render']["source"] = $this->attributes['listeners']['render']["source"];
     unset($this->attributes['listeners']['render']["source"]);
     $this->attributes['listeners']['render'] = $this->afExtjs->asMethod(array("parameters" => "", "source" => $attributes['listeners']['render']["source"]));
     unset($attributes['listeners']['render']["source"]);
     $this->afExtjs->private[$this->privateName] = $this->afExtjs->Panel($this->attributes);
 }
コード例 #2
0
 public function __construct($attributes = array())
 {
     $this->afExtjs = afExtjs::getInstance();
     $this->afExtjs->setAddons(array('js' => array('/appFlowerPlugin/js/custom/cheatJS.js')));
     $this->privateName = 'panel_' . Util::makeRandomKey();
     $this->attributes['id'] = $this->privateName;
     if (isset($attributes['idxml']) && $attributes['idxml']) {
         $this->attributes['id'] = $attributes['idxml'];
     }
     if (isset($attributes['plugins'])) {
         $this->attributes['plugins'][] = $attributes['plugins'];
         unset($attributes['plugins']);
     }
     if (isset($attributes['portal']) && $attributes['portal'] == true) {
         $this->attributes = array_merge($this->attributes, array('anchor' => '100%', 'frame' => true, 'collapsible' => true, 'draggable' => true, 'maximizable' => true, 'cls' => 'x-portlet'));
         $this->attributes['plugins'][] = 'new Ext.ux.MaximizeTool()';
         unset($attributes['portal']);
     }
     if (isset($attributes['tools'])) {
         $this->attributes['tools'] = $attributes['tools']->end();
         unset($attributes['tools']);
     }
     $this->attributes['getWidgetConfig'] = $this->afExtjs->asMethod("var o={}; o.idxml=this.idxml || false; return o;");
     if (count($attributes) > 0) {
         $this->attributes = array_merge($this->attributes, $attributes);
     }
     $this->attributes['listeners']['bodyresize'] = $this->afExtjs->asMethod(array("parameters" => "object,layout", "source" => "if(object.ownerCt.ownerCt)object.ownerCt.ownerCt.doLayout();"));
     if (isset($attributes['autoEnd']) && $attributes['autoEnd'] || !isset($attributes['autoEnd'])) {
         $this->end();
     }
 }
コード例 #3
0
 public function __construct($attributes = array())
 {
     $this->afExtjs = afExtjs::getInstance();
     $this->portalPrivateName = 'portal_' . Util::makeRandomKey();
     if (isset($attributes['portalLayoutType'])) {
         $this->attributes['portal']['portalLayoutType'] = $attributes['portalLayoutType'];
         unset($attributes['portalLayoutType']);
     }
     if (isset($attributes['portalWidgets'])) {
         $this->attributes['portal']['portalWidgets'] = $attributes['portalWidgets'];
         unset($attributes['portalWidgets']);
     }
     /**
      * fixing ticket #1295 part 2
      * 
      * @author Radu Topala <*****@*****.**>
      */
     $this->attributes['portal']['dropConfig']['ddGroup'] = $this->portalPrivateName . '_dd';
     $this->attributes['portal']['bodyBorder'] = false;
     $this->attributes['portal']['autoWidth'] = true;
     @($this->attributes['portal']['style'] .= 'padding-right:5px;');
     @($this->attributes['portal']['bodyStyle'] .= 'overflow-x:hidden;overflow-y:hidden;padding-right:5px;');
     if (count($attributes) > 0) {
         $this->attributes = array_merge($this->attributes, $attributes);
     }
 }
コード例 #4
0
 public function __construct($attributes = array())
 {
     $this->afExtjs = afExtjs::getInstance();
     $this->privateName = 'form_' . Util::makeRandomKey();
     $this->attributes['name'] = $this->privateName;
     $this->attributes['id'] = $this->privateName;
     //$this->attributes['defaults']=array('labelStyle'=>'width:75px;font-size:11px;font-weight:bold;padding:0 3px 3px 0;');
     if (isset($attributes['labelWidth'])) {
         //$this->attributes['defaults']=array('labelStyle'=>'width:'.$attributes['labelWidth'].'px;font-size:11px;font-weight:bold;padding:0 3px 3px 0;');
     }
     /*if(isset($attributes['idxml'])&&$attributes['idxml'])
     		{
     			$this->attributes['id']=$attributes['idxml'];
     		}*/
     $this->afExtjs->setAddons(array('css' => array('/appFlowerPlugin/css/my-extjs.css', $this->afExtjs->getPluginsDir() . 'multiselect/multiselect.css'), 'js' => array($this->afExtjs->getPluginsDir() . 'multiselect/DDView.js', $this->afExtjs->getPluginsDir() . 'multiselect/MultiSelect.js', $this->afExtjs->getPluginsDir() . 'multiselect/ItemSelector.js', $this->afExtjs->getPluginsDir() . 'multiselect/Ext.ux.TreeItemSelector.js', $this->afExtjs->getPluginsDir() . 'tree/Ext.tree.TreeSerializer.js', $this->afExtjs->getPluginsDir() . 'form/Ext.ux.ClassicFormPanel.js', $this->afExtjs->getPluginsDir() . 'form/Ext.ux.form.ComboWButton.js')));
     if (isset($attributes['action'])) {
         $this->attributes['url'] = $attributes['action'];
         unset($attributes['action']);
     }
     if (isset($attributes['portal']) && $attributes['portal'] == true) {
         $this->attributes = array_merge($this->attributes, array('anchor' => '100%', 'frame' => true, 'collapsible' => true, 'draggable' => true, 'cls' => 'x-portlet'));
         unset($attributes['portal']);
     }
     if (isset($attributes['tools'])) {
         $this->attributes['tools'] = $attributes['tools']->end();
         unset($attributes['tools']);
     }
     $this->attributes['getWidgetConfig'] = $this->afExtjs->asMethod("var o={}; o.idxml=this.idxml || false; return o;");
     if (count($attributes) > 0) {
         $this->attributes = array_merge($this->attributes, $attributes);
     }
 }
コード例 #5
0
 public function __construct($attributes = array())
 {
     $this->afExtjs = afExtjs::getInstance();
     if (count($attributes)) {
         $this->attributes = array_merge($this->attributes, $attributes);
     }
     $this->privateName = 'menu_' . Util::makeRandomKey();
 }
コード例 #6
0
 public function __construct($attributes = array())
 {
     $this->afExtjs = afExtjs::getInstance();
     $this->afExtjs->setAddons(array('js' => array($this->afExtjs->getPluginsDir() . 'comet/Ext.Comet.js', $this->afExtjs->getPluginsDir() . 'comet/Ext.ux.Updater.js')));
     $this->privateName = 'updater_' . Util::makeRandomKey();
     $this->attributes['id'] = $this->privateName;
     if (count($attributes) > 0) {
         $this->attributes = array_merge($this->attributes, $attributes);
     }
     $this->end();
 }
コード例 #7
0
 public function __construct($attributes = array())
 {
     $this->afExtjs = afExtjs::getInstance();
     $this->privateName = 'window_' . Util::makeRandomKey();
     $this->attributes['id'] = $this->privateName;
     if (isset($attributes['tools'])) {
         $this->attributes['tools'] = $attributes['tools']->end();
         unset($attributes['tools']);
     }
     if (count($attributes) > 0) {
         $this->attributes = array_merge($this->attributes, $attributes);
     }
 }
コード例 #8
0
 public function __construct($containerObject, $attributes = array())
 {
     $this->afExtjs = afExtjs::getInstance();
     $this->privateName = 'field_' . Util::makeRandomKey();
     $this->attributes['xtype'] = 'multiselect';
     $this->attributes['width'] = '250';
     $this->attributes['height'] = '100';
     if (isset($attributes['plugin']) && $attributes['plugin'] == 'listfield') {
         $this->afExtjs->setAddons(array('js' => array($this->afExtjs->getPluginsDir() . 'multiselect/ListField.js')));
         $this->attributes['xtype'] = 'listfield';
         $this->attributes['height'] = 250;
     }
     if (isset($attributes['name'])) {
         $this->attributes['name'] = $attributes['name'];
         $this->attributes['id'] = $this->privateName;
     }
     /**
      * add a button to clear the selection
      */
     if (isset($attributes['clear'])) {
         $this->attributes['tbar'] = array($this->afExtjs->asAnonymousClass(array('text' => 'clear', 'handler' => $this->afExtjs->asMethod(array('parameters' => '', 'source' => 'Ext.getCmp("' . $this->attributes['id'] . '").reset();')))));
         unset($attributes['clear']);
     }
     /**
      * the options attribute, an assoc array for now
      */
     if (isset($attributes['options']) && count($attributes['options']) > 0) {
         $options = array();
         foreach ($attributes['options'] as $key => $value) {
             $options[] = array($key, $value);
         }
         $this->attributes['dataFields'] = $this->afExtjs->asVar("['key','value']");
         $this->attributes['valueField'] = "key";
         $this->attributes['displayField'] = "value";
         $this->attributes['data'] = $this->afExtjs->asVar(json_encode($options));
         unset($attributes['options']);
     }
     /**
      * PROCESS selected values FROM value & selected ATTRIBUTES
      * you can use either selected and/or value attributes arrays to select some values from options attribute
      */
     $this->processSelectedValues($attributes);
     /**
      * PROCESS state ATTRIBUTE
      * state can have "disabled" or "editable" values; if state is "readonly", then it's equal to "disabled"
      */
     $this->processState($attributes);
     parent::__construct($containerObject, $attributes);
 }
コード例 #9
0
 public function end()
 {
     /**
      * don't use the hidden attribute
      */
     unset($this->attributes['hidden']);
     $this->privateName = 'button_' . Util::makeRandomKey();
     if (isset($this->attributes['listeners']) && count($this->attributes['listeners']) > 0) {
         foreach ($this->attributes['listeners'] as $type => $type_params) {
             /**
              * if listener function source is not an array then the string is used directly
              */
             if (isset($type_params['parameters']) && isset($type_params['source']) && !is_array($type_params['source'])) {
                 $this->attributes['listeners'][$type] = $this->afExtjs->asMethod(array('parameters' => $type_params['parameters'], 'source' => $type_params['source']));
             }
         }
     }
     $this->afExtjs->private[$this->privateName] = $this->afExtjs->Button($this->attributes);
     return $this->privateName;
 }
コード例 #10
0
 public function addCombo($attributes = array())
 {
     $storePrivateName = 'store_' . Util::makeRandomKey();
     $readerPrivateName = 'reader_' . Util::makeRandomKey();
     $proxyPrivateName = 'proxy_' . Util::makeRandomKey();
     $templatePrivateName = 'tpl_' . Util::makeRandomKey();
     $xtemplatePrivateName = 'xtpl_' . Util::makeRandomKey();
     $attributes[$readerPrivateName]['totalProperty'] = 'totalCount';
     $attributes[$readerPrivateName]['root'] = 'rows';
     foreach ($this->proxy['fields'] as $field) {
         $attributes[$readerPrivateName]['fields'][] = $this->afExtjs->asAnonymousClass(array('name' => $field));
     }
     $attributes[$readerPrivateName]['fields'][] = $this->afExtjs->asAnonymousClass(array('name' => 'url'));
     $this->afExtjs->private[$readerPrivateName] = $this->afExtjs->JsonReader($attributes[$readerPrivateName]);
     unset($attributes[$readerPrivateName]);
     $attributes[$proxyPrivateName]['url'] = $this->proxy['url'];
     $this->afExtjs->private[$proxyPrivateName] = $this->afExtjs->HttpProxy($attributes[$proxyPrivateName]);
     unset($attributes[$proxyPrivateName]);
     $attributes[$storePrivateName]['reader'] = $this->afExtjs->asVar($readerPrivateName);
     $attributes[$storePrivateName]['proxy'] = $this->afExtjs->asVar($proxyPrivateName);
     $this->afExtjs->private[$storePrivateName] = $this->afExtjs->Store($attributes[$storePrivateName]);
     unset($attributes[$storePrivateName]);
     $this->afExtjs->private[$templatePrivateName] = '<tpl for="."><div class="search-item">' . $this->template . '</div></tpl>';
     $this->afExtjs->private[$xtemplatePrivateName] = $this->afExtjs->XTemplate(array($templatePrivateName));
     $attributes['typeAhead'] = false;
     $attributes['loadingText'] = 'Searching...';
     $attributes['width'] = '520';
     $attributes['pageSize'] = $this->proxy['limit'];
     $attributes['hideTrigger'] = true;
     $attributes['itemSelector'] = 'div.search-item';
     $attributes['tpl'] = $this->afExtjs->asVar($xtemplatePrivateName);
     $attributes['store'] = $this->afExtjs->asVar($storePrivateName);
     $attributes['id'] = 'center_combo';
     $attributes['minChars'] = $this->proxy['minChars'];
     $attributes['onSelect'] = $this->afExtjs->asMethod(array("parameters" => "record", "source" => "window.location.href=record.data.url;"));
     $attributes['applyTo'] = 'search_input';
     $this->afExtjs->private['combo'] = $this->afExtjs->ComboBox($attributes);
     //$this->addInitMethodSource('Ext.get("center_combo").boxWrap().addClass("x-box-blue");Ext.get("center_combo").dom.parentNode.parentNode.parentNode.parentNode.parentNode.style.width="500px";Ext.get("center_combo").show();');
 }
コード例 #11
0
    public function end()
    {
        /*$this->attributes['listeners']['afterrender']=$this->afExtjs->asMethod(array(
        			"parameters"=>"value, metadata, record",
        			"source"=>"var tb = this.getTopToolbar();
        			if(!tb) return;	
        			var box = this.getBox();
        			tb.setWidth(box.width);	"
        		));	
        		*/
        $this->attributes['canMask'] = $this->afExtjs->asMethod(array("parameters" => "", "source" => "return !Ext.isIE&&!" . $this->privateName . ".disableLoadMask&&!Ext.get('loading');"));
        if (!$this->attributes['tree']) {
            $this->attributes['view'] = $this->afExtjs->GroupingColorView(array('forceFit' => $this->attributes['forceFit'], 'groupTextTpl' => ' {text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})'));
            if (isset($this->attributes['clearGrouping']) && $this->attributes['clearGrouping']) {
                @($this->attributes['listeners']['render']["source"] .= "this.store.clearGrouping();");
            }
        } else {
            $this->afExtjs->setAddons(array('css' => array($this->afExtjs->getPluginsDir() . 'treegrid/css/TreeGrid.css'), 'js' => array($this->afExtjs->getPluginsDir() . 'treegrid/TreeGrid.js', $this->afExtjs->getPluginsDir() . 'treegrid/Ext.ux.SynchronousTreeExpand.js')));
            $this->attributes['viewConfig'] = $this->afExtjs->asAnonymousClass(array('forceFit' => $this->attributes['forceFit']));
        }
        if (isset($this->proxy['url']) && count($this->columns) > 0) {
            $this->proxy['url'] = sfContext::getInstance()->getRequest()->getRelativeUrlRoot() . $this->proxy['url'];
            $filtersPrivateName = 'filters_' . Util::makeRandomKey();
            $storePrivateName = 'store_' . Util::makeRandomKey();
            $readerPrivateName = 'reader_' . Util::makeRandomKey();
            if ($this->attributes['pager']) {
                $pagingToolbarPrivateName = 'pt_' . Util::makeRandomKey();
            }
            $wasSort = false;
            $firstSortableCol = null;
            $summaryPlugin = false;
            foreach ($this->columns as $column) {
                $temp_column = null;
                $temp_field = null;
                $temp_name = 'Header ' . Util::makeRandomKey();
                $temp_column['dataIndex'] = isset($column['name']) ? $column['name'] : Util::stripText($temp_name);
                $temp_field['name'] = isset($column['name']) ? $column['name'] : Util::stripText($temp_name);
                //$temp_field['type']=isset($column['type'])?$column['type']:'auto';
                $temp_field['sortType'] = isset($column['sortType']) ? $column['sortType'] : 'asText';
                $temp_column['sortType'] = isset($column['sortType']) ? $column['sortType'] : 'asText';
                //Grid summary plugin
                $temp_column['summaryType'] = isset($column['summaryType']) ? $column['summaryType'] : null;
                if (!$summaryPlugin && $temp_column['summaryType'] != null) {
                    $this->attributes['plugins'][] = "new Ext.ux.grid.GridSummary";
                    $summaryPlugin = true;
                }
                $temp_column['header'] = isset($column['label']) ? $column['label'] : $temp_name;
                $temp_column['sortable'] = isset($column['sortable']) ? $column['sortable'] : true;
                if (isset($column['width']) && $column['width'] != 'auto') {
                    $temp_column['width'] = $column['width'];
                }
                $temp_column['hidden'] = isset($column['hidden']) ? $column['hidden'] : false;
                $temp_column['hideable'] = isset($column['hideable']) ? $column['hideable'] : true;
                $temp_column = $this->formatNumberColumn($temp_column);
                /**
                 * Edit link at defined column
                 * Please comment this block if the edit should be under the Actions column.
                 * This section looks the edit="true" in the xml columns. If found, and if 
                 * there is a row actions matching the name or label with edit, this will
                 * be transformed to the edit="true" column
                 */
                if (isset($column['edit']) && $column['edit'] || isset($column['action'])) {
                    //print_r($this->actionsObject);
                    if ($this->actionsObject) {
                        $actions = $this->actionsObject->getActions();
                        //print_r($actions);
                        if (is_array($actions)) {
                            foreach ($actions as $key => $action) {
                                if (isset($column['action']) && preg_match("/list[0-9]+_" . preg_replace("/^\\//", "", $column['action']) . "\$/", $action['name']) || isset($column['edit']) && $column['edit'] === "true" && (preg_match("/_edit\$/", $action['name']) || preg_match("/edit\$/i", $action['label']) || preg_match("/_modify\$/", $action['name']) || preg_match("/modify\$/i", $action['label']) || preg_match("/_update\$/", $action['name']) || preg_match("/update\$/i", $action['label']))) {
                                    $urlIndex = $action['urlIndex'];
                                    $credential = ComponentCredential::urlHasCredential($action['url']);
                                    $actionUrl = UrlUtil::url($action['url']);
                                    if (isset($action['load']) && $action['load'] == "page") {
                                        $actionUrl = $action['url'];
                                    }
                                    $temp_column['renderer'] = $this->afExtjs->asMethod(array("parameters" => "value, metadata, record", "source" => "if(!" . intval($credential) . ") return value;var action = record.get('" . $urlIndex . "'); if(!action) return value; var m = action.toString().match(/.*?\\?(.*)/);return '<a  href=\"" . $actionUrl . "?'+m[1]+'\" qtip=\"" . (isset($action['tooltip']) ? $action['tooltip'] : '') . "\">'+ value + '</a>';"));
                                    $this->actionsObject = $this->actionsObject->changeProperty($action['name'], 'hidden', true);
                                    if (isset(afExtjs::getInstance()->private[$this->actionsObject->privateName])) {
                                        unset(afExtjs::getInstance()->private[$this->actionsObject->privateName]);
                                    }
                                    $this->actionsObject->end();
                                    $this->movedRowActions++;
                                }
                            }
                        }
                    }
                }
                /*
                 * check for context menu
                 */
                $style = '';
                $arrowSpan = '';
                if (isset($column['contextMenu']) && $column['contextMenu']) {
                    $style = "";
                    $arrowSpan = '<span class="interactive-arrow"><a class="interactive-arrow-a"  href="#">&nbsp;</a></span>';
                    $contextMenu = context_menu($column['contextMenu'])->privateName;
                    $this->contextMenu[$temp_field['name']] = $contextMenu;
                    $temp_column['renderer'] = $this->afExtjs->asMethod(array("parameters" => "value, metadata, record", "source" => "return '<span {$style}>{$arrowSpan}' + value + '</span>';"));
                }
                /*else{
                			$contextMenu = context_menu('',array('grid'))->privateName;
                			$this->contextMenu[$temp_field['name']] = $contextMenu;
                		}*/
                /**********************************************************************************/
                if (isset($column['qtip']) && $column['qtip']) {
                    $temp_column['renderer'] = $this->afExtjs->asMethod(array("parameters" => "value, metadata, record", "source" => "var qtip = Ext.util.Format.htmlEncode(value); return '<span qtip=\"' + qtip + '\" {$style}>{$arrowSpan}' + value + '</span>';"));
                }
                //If numeric data, right align while rendering...
                // Disabled for now. JS error: "record is undefined"
                //$this->handleNumericColumns($temp_column);
                // Add filter here
                afExtjsGridFilter::add($this, $column, $temp_column, $temp_field);
                //Remote filter
                if (isset($column['sortIndex'])) {
                    $temp_column['sortIndex'] = $column['sortIndex'];
                }
                if (!isset($temp_column['id'])) {
                    $temp_column['id'] = $temp_column['dataIndex'];
                }
                if (!$this->attributes['tree']) {
                    if (isset($column['id']) && $column['id']) {
                        $temp_column['id'] = $temp_column['dataIndex'];
                        if (!isset($this->attributes[$readerPrivateName]['id'])) {
                            $this->attributes[$readerPrivateName]['id'] = $temp_column['dataIndex'];
                        }
                    }
                    if (isset($column['groupField']) && $column['groupField']) {
                        $this->attributes[$storePrivateName]['groupField'] = $temp_column['dataIndex'];
                    }
                }
                if (!$wasSort && isset($column['sort']) && in_array($column['sort'], array('ASC', 'DESC'))) {
                    $wasSort = true;
                    $this->defineSortInfo($storePrivateName, $temp_column['dataIndex'], $column['sort']);
                }
                if (!$firstSortableCol && ArrayUtil::isTrue($temp_column, 'sortable')) {
                    $firstSortableCol = $temp_column['dataIndex'];
                }
                $this->attributes['columns'][] = $this->afExtjs->asAnonymousClass($temp_column);
                if ($this->attributes['tree'] && !isset($this->attributes['master_column_id'])) {
                    $this->attributes['master_column_id'] = $temp_column['dataIndex'];
                }
                $this->attributes[$readerPrivateName]['fields'][] = $this->afExtjs->asAnonymousClass($temp_field);
            }
            /*
             * Add listeners for context menu
             */
            $this->_addListenersForContextMenu($attributes);
            /**********************************************************/
            if (!$wasSort && $firstSortableCol) {
                $this->defineSortInfo($storePrivateName, $firstSortableCol, 'ASC');
            }
            $count_actions = is_object($this->actionsObject) ? count($this->actionsObject->attributes['actions']) : 0;
            if ($count_actions > 0) {
                for ($i = 1; $i <= $count_actions; $i++) {
                    $this->attributes[$readerPrivateName]['fields'][] = $this->afExtjs->asAnonymousClass(array('name' => 'action' . $i, 'type' => 'string'));
                    $this->attributes[$readerPrivateName]['fields'][] = $this->afExtjs->asAnonymousClass(array('name' => 'hide' . $i, 'type' => 'boolean'));
                }
            }
            $this->attributes[$readerPrivateName]['fields'][] = $this->afExtjs->asAnonymousClass(array('name' => 'message'));
            $this->attributes[$readerPrivateName]['fields'][] = $this->afExtjs->asAnonymousClass(array('name' => 'redirect'));
            $this->attributes[$readerPrivateName]['fields'][] = $this->afExtjs->asAnonymousClass(array('name' => 'load'));
            if ($this->attributes['tree']) {
                $this->attributes[$readerPrivateName]['fields'][] = $this->afExtjs->asAnonymousClass(array('name' => '_id', 'type' => 'int'));
                $this->attributes[$readerPrivateName]['fields'][] = $this->afExtjs->asAnonymousClass(array('name' => '_parent', 'type' => 'auto'));
                $this->attributes[$readerPrivateName]['fields'][] = $this->afExtjs->asAnonymousClass(array('name' => '_is_leaf', 'type' => 'bool'));
                $this->attributes[$readerPrivateName]['fields'][] = $this->afExtjs->asAnonymousClass(array('name' => '_color', 'type' => 'auto'));
                $this->attributes[$readerPrivateName]['fields'][] = $this->afExtjs->asAnonymousClass(array('name' => '_cell_color', 'type' => 'auto'));
                $this->attributes[$readerPrivateName]['fields'][] = $this->afExtjs->asAnonymousClass(array('name' => '_buttonOnColumn', 'type' => 'auto'));
                $this->attributes[$readerPrivateName]['fields'][] = $this->afExtjs->asAnonymousClass(array('name' => '_buttonText', 'type' => 'auto'));
                $this->attributes[$readerPrivateName]['fields'][] = $this->afExtjs->asAnonymousClass(array('name' => '_buttonDescription', 'type' => 'auto'));
                if ($this->attributes['select']) {
                    $this->attributes[$readerPrivateName]['fields'][] = $this->afExtjs->asAnonymousClass(array('name' => '_selected', 'type' => 'auto'));
                }
                $this->attributes[$readerPrivateName]['id'] = '_id';
            } else {
                $this->attributes[$readerPrivateName]['fields'][] = $this->afExtjs->asAnonymousClass(array('name' => '_color', 'type' => 'auto'));
                $this->attributes[$readerPrivateName]['fields'][] = $this->afExtjs->asAnonymousClass(array('name' => '_cell_color', 'type' => 'auto'));
                //Select for normal grid too.....
                if ($this->attributes['select']) {
                    $this->attributes[$readerPrivateName]['fields'][] = $this->afExtjs->asAnonymousClass(array('name' => '_selected', 'type' => 'auto'));
                }
                //..................................
                if (!isset($this->attributes[$readerPrivateName]['id'])) {
                    $this->attributes[$readerPrivateName]['id'] = '_id';
                }
            }
            $this->attributes[$readerPrivateName]['totalProperty'] = 'totalCount';
            $this->attributes[$readerPrivateName]['root'] = 'rows';
            $this->attributes[$readerPrivateName]['properties'] = 'properties';
            $this->afExtjs->private[$readerPrivateName] = $this->afExtjs->JsonReader($this->attributes[$readerPrivateName]);
            unset($this->attributes[$readerPrivateName]);
            $this->attributes[$storePrivateName]['reader'] = $this->afExtjs->asVar($readerPrivateName);
            if (isset($this->attributes['remoteSort'])) {
                $this->attributes[$storePrivateName]['remoteSort'] = $this->attributes['remoteSort'];
                unset($this->attributes['remoteSort']);
            }
            $this->attributes[$storePrivateName]['proxy'] = $this->afExtjs->HttpProxy(array('url' => $this->proxy['url'], 'method' => 'GET', 'disableCaching' => false, 'listeners' => array('beforeload' => $this->afExtjs->asMethod(array('parameters' => 'proxy,params', 'source' => 'proxy.lastParams=params')), 'exception' => self::getJsExceptionListener($this->afExtjs, $this->privateName))));
            $beforeloadListener = "\r\n\t\t\t\tif(" . $this->privateName . ".canMask()){" . $this->privateName . ".getEl().mask('Loading, please Wait...', 'x-mask-loading');}\r\n\t\t\t";
            if (isset($this->proxy['stateId'])) {
                $this->attributes[$storePrivateName]['pt_state_loaded'] = false;
                $this->attributes[$storePrivateName]['pt_state'] = "Ext.state.Manager.get('" . $this->proxy['stateId'] . "')";
                $this->attributes[$storePrivateName]['listeners']['beforeload'] = $this->afExtjs->asMethod(array("parameters" => "object,options", "source" => "if(!this.pt_state_loaded&&this.pt_state){options.params=this.pt_state;this.pt_state_loaded=true;}" . $beforeloadListener));
            } else {
                $this->attributes[$storePrivateName]['listeners']['beforeload'] = $this->afExtjs->asMethod(array("parameters" => "object,options", "source" => $beforeloadListener));
            }
            $this->attributes[$storePrivateName]['listeners']['load'] = $this->afExtjs->asMethod(array("parameters" => "object,records,options", "source" => '/*console.log(eval(' . $this->privateName . '.bindForm));*/if(records.length>0&&records[0].json.redirect&&records[0].json.message&&records[0].json.load){var rec=records[0].json;Ext.Msg.alert("Failure", rec.message, function(){afApp.load(rec.redirect,rec.load);});}else{if(' . $this->privateName . '.canMask()){' . $this->privateName . '.getEl().unmask();}}
																			' . $this->privateName . '.ownerCt.ownerCt.doLayout();/*Chrome fix*/' . $this->privateName . '.body.dom.lastChild.style.width=\'100%\';/*Toolbars fix*/if(' . $this->privateName . '.bbar){' . $this->privateName . '.bbar.dom.style.width=\'auto\';' . $this->privateName . '.bbar.dom.firstChild.style.width=\'auto\';}if(' . $this->privateName . '.tbar){' . $this->privateName . '.tbar.dom.style.width=\'auto\';' . $this->privateName . '.tbar.dom.firstChild.style.width=\'auto\';}' . ($this->dataLoadedHandler != '' ? "{$this->dataLoadedHandler}({$this->privateName});" : '') . $this->resizeToolBars()));
            $this->attributes[$storePrivateName]['listeners']['loadexception'] = $this->afExtjs->asMethod(array("parameters" => "", "source" => 'if(' . $this->privateName . '.canMask()){' . $this->privateName . '.getEl().unmask();}'));
            if (!$this->attributes['tree']) {
                $this->afExtjs->private[$storePrivateName] = $this->afExtjs->GroupingStore($this->attributes[$storePrivateName]);
            } else {
                $this->afExtjs->private[$storePrivateName] = $this->afExtjs->AdjacencyListStore($this->attributes[$storePrivateName]);
            }
            unset($this->attributes[$storePrivateName]);
            if ($this->attributes['pager']) {
                $this->attributes[$pagingToolbarPrivateName]['store'] = $this->afExtjs->asVar($storePrivateName);
                $this->attributes[$pagingToolbarPrivateName]['displayInfo'] = true;
                if (isset($this->attributes['pagerTemplate'])) {
                    $this->attributes[$pagingToolbarPrivateName]['displayMsg'] = $this->parsePagerTemplate($this->attributes['pagerTemplate']);
                }
                $this->attributes[$pagingToolbarPrivateName]['pageSize'] = isset($this->proxy['limit']) ? $this->proxy['limit'] : 20;
                if (isset($this->proxy['stateId'])) {
                    $this->attributes[$pagingToolbarPrivateName]['stateId'] = $this->proxy['stateId'];
                    $this->attributes[$pagingToolbarPrivateName]['stateEvents'] = array('change');
                    $this->attributes[$pagingToolbarPrivateName]['stateful'] = true;
                    $this->attributes[$pagingToolbarPrivateName]['getState'] = $this->afExtjs->asMethod(array("parameters" => "", "source" => "return { start: " . (isset($this->proxy['start']) ? $this->proxy['start'] : "this.cursor") . ",\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlimit: this.pageSize };"));
                }
                if (count($this->filters) > 0) {
                    //$this->attributes[$pagingToolbarPrivateName]['plugins'] = $this->afExtjs->asVar($filtersPrivateName);
                }
                if (!$this->attributes['tree']) {
                    $this->afExtjs->private[$pagingToolbarPrivateName] = $this->afExtjs->PagingToolbar($this->attributes[$pagingToolbarPrivateName]);
                } else {
                    $this->afExtjs->private[$pagingToolbarPrivateName] = $this->afExtjs->GridTreePagingToolbar($this->attributes[$pagingToolbarPrivateName]);
                }
                unset($this->attributes[$pagingToolbarPrivateName]);
            }
        }
        if (count($this->filters) > 0) {
            $this->attributes[$filtersPrivateName]['filters'] = $this->filters;
            $this->attributes[$filtersPrivateName]['local'] = isset($this->attributes['remoteFilter']) && $this->attributes['remoteFilter'] ? false : true;
            //$this->attributes[$filtersPrivateName]['filterby']=sfContext::getInstance()->getActionStack()->getLastEntry()->getActionInstance()->getRequestParameter("filterby",false);
            $this->attributes[$filtersPrivateName]['filterby'] = sfContext::getInstance()->getUser()->getAttribute('filterby', false);
            $this->attributes[$filtersPrivateName]['filterbyKeyword'] = sfContext::getInstance()->getUser()->getAttribute('filterbyKeyword', false);
            sfContext::getInstance()->getUser()->setAttribute('filterby', false);
            sfContext::getInstance()->getUser()->setAttribute('filterbyKeyword', false);
            //$this->attributes['title'] = $this->attributes['title'].": <font color=red>(Filtered by keyword: '".$this->attributes[$filtersPrivateName]['filterbyKeyword']."'</font>)";
            $this->afExtjs->private[$filtersPrivateName] = $this->afExtjs->GridFilters($this->attributes[$filtersPrivateName]);
            $this->attributes['plugins'][] = $this->afExtjs->asVar($filtersPrivateName);
            unset($this->attributes[$filtersPrivateName]);
        }
        if ($count_actions > 0) {
            if ($this->movedRowActions) {
                if ($count_actions - $this->movedRowActions > 0) {
                    $this->attributes['columns'][] = $this->afExtjs->asVar($this->actionsObject->privateName);
                }
            } else {
                $this->attributes['columns'][] = $this->afExtjs->asVar($this->actionsObject->privateName);
            }
            $this->attributes['plugins'][] = $this->afExtjs->asVar($this->actionsObject->privateName);
        }
        $this->attributes['store'] = $this->afExtjs->asVar($storePrivateName);
        if ($this->attributes['pager']) {
            $this->attributes['bbar'] = $this->afExtjs->asVar($pagingToolbarPrivateName);
        }
        //changed to have select on normal grid too..
        //if($this->attributes['tree'] && $this->attributes['select'])
        if ($this->attributes['select']) {
            $this->afExtjs->setAddons(array('js' => array($this->afExtjs->getPluginsDir() . 'treegrid/Ext.ux.CheckboxSelectionModel.js')));
            $selectionModelPrivateName = 'sm_' . Util::makeRandomKey();
            $this->afExtjs->private[$selectionModelPrivateName] = $this->afExtjs->UxCheckboxSelectionModel(array());
            $this->attributes['sm'] = $this->afExtjs->asVar($selectionModelPrivateName);
            //if($this->attributes['tree'])
            $this->attributes['columns'][] = $this->afExtjs->asVar($selectionModelPrivateName);
            //array_unshift($this->attributes['columns'],$this->afExtjs->asVar($selectionModelPrivateName));
            /*
             * Since the insertion of checkbox selection model at the beginning of the grid, the tree structrue get lost, though it was 
             * fine for non-tree grid. To overcome this first the grid is rendered as it is with the checkbox selection model at the end
             * and when the grid is rendered the checkbox selection model is now moved to the initial column position of the grid.
             */
            $jsSource = "\r\n\t\t\t\tvar gcm = " . $this->privateName . ".getColumnModel();\r\n\t\t\t\tif(gcm.getColumnHeader(gcm.getColumnCount()-1) == '<div class=\"x-grid3-hd-checker\" id=\"hd-checker\">&#160;</div>') \r\n\t\t\t\tgcm.moveColumn(gcm.getColumnCount()-1,0);\r\n\t\t\t\t";
        } else {
            $jsSource = '';
        }
        @($this->attributes['listeners']['render']["source"] .= "\r\n\t\t\tthis.store.load({\r\n\t\t\t\tparams:{\r\n\t\t\t\t\tstart:" . (isset($this->proxy['start']) ? $this->proxy['start'] : 0) . ", \r\n\t\t\t\t\tlimit:" . (isset($this->proxy['limit']) ? $this->proxy['limit'] : 20) . "\r\n\t\t\t\t}\r\n\t\t\t});");
        $attributes['listeners']['render']["source"] = $this->attributes['listeners']['render']["source"];
        $attributes['listeners']['render']["source"] .= $jsSource;
        unset($this->attributes['listeners']['render']["source"]);
        $this->attributes['listeners']['render'] = $this->afExtjs->asMethod(array("parameters" => "", "source" => $attributes['listeners']['render']["source"]));
        unset($attributes['listeners']['render']["source"]);
        //attach center loading ajax to links with class="widgetLoad"
        $this->attributes['listeners']['mouseover'] = $this->afExtjs->asMethod(array("parameters" => "", "source" => "afApp.attachHrefWidgetLoad();"));
        if (count($this->filters) > 0) {
            $this->afExtjs->setAddons(array('js' => array($this->afExtjs->getPluginsDir() . 'grid-filtering/ux/menu/EditableItem.js', $this->afExtjs->getPluginsDir() . 'grid-filtering/ux/menu/ComboMenu.js', $this->afExtjs->getPluginsDir() . 'grid-filtering/ux/menu/RangeMenu.js', $this->afExtjs->getPluginsDir() . 'grid-filtering/ux/grid/GridFilters.js', $this->afExtjs->getPluginsDir() . 'grid-filtering/ux/grid/DrillFilter.js', $this->afExtjs->getPluginsDir() . 'grid-filtering/ux/grid/RePositionFilters.js', $this->afExtjs->getPluginsDir() . 'grid-filtering/ux/grid/SaveSearchState.js', $this->afExtjs->getPluginsDir() . 'grid-filtering/ux/grid/FilterInfo.js', $this->afExtjs->getPluginsDir() . 'grid-filtering/ux/grid/FilterOption.js', $this->afExtjs->getPluginsDir() . 'grid-filtering/ux/grid/filter/Filter.js', $this->afExtjs->getPluginsDir() . 'grid-filtering/ux/grid/filter/BooleanFilter.js', $this->afExtjs->getPluginsDir() . 'grid-filtering/ux/grid/filter/ComboFilter.js', $this->afExtjs->getPluginsDir() . 'grid-filtering/ux/grid/filter/DateFilter.js', $this->afExtjs->getPluginsDir() . 'grid-filtering/ux/grid/filter/ListFilter.js', $this->afExtjs->getPluginsDir() . 'grid-filtering/ux/grid/filter/NumericFilter.js', $this->afExtjs->getPluginsDir() . 'grid-filtering/ux/grid/filter/StringFilter.js', $this->afExtjs->getPluginsDir() . 'grid-filtering/ux/grid/filter/TextFilter.js'), 'css' => array($this->afExtjs->getPluginsDir() . 'grid-filtering/resources/style.css')));
            // Add reset filters on menu action if there is filter in grid
            $this->addMenuActionsItem(array('label' => 'Filters', 'icon' => '/images/famfamfam/drink.png', 'listeners' => array('click' => array('parameters' => '', 'source' => 'var grid = ' . $this->privateName . ';
							var filters = grid.filters;
							if(!filters) return;							
							var saveFilter = Ext.ux.SaveSearchState(grid);
							saveFilter.viewSavedList();'))));
            $this->addMenuActionsItem(array('xtype' => 'menuseparator'));
            if (isset($this->attributes['name']) || isset($this->attributes['path'])) {
                $savedFilters = afSaveFilterPeer::getFiltersByName(isset($this->attributes['name']) ? $this->attributes['name'] : $this->attributes['path']);
                $fc = 0;
                foreach ($savedFilters as $f) {
                    //if($fc > 4) break;
                    $this->addMenuActionsItem(array('label' => ++$fc . ". " . $f->getName(), 'listeners' => array('click' => array('parameters' => '', 'source' => '
    							var grid = ' . $this->privateName . ';
    							var filters = grid.filters;
    							if(!filters) return;							
    							var saveFilter = Ext.ux.SaveSearchState(grid);							
    							saveFilter.restore(\'' . $f->getFilter() . '\',"' . $f->getName() . '");'))));
                }
            }
        }
        $this->addMenuActions();
        if (!$this->attributes['tree']) {
            $this->afExtjs->private[$this->privateName] = $this->afExtjs->GridPanel($this->attributes);
        } else {
            $this->afExtjs->private[$this->privateName] = $this->afExtjs->GridTreePanel($this->attributes);
        }
        //print_r($this);
    }
コード例 #12
0
 public function beforeEnd()
 {
     if (isset($this->attributes['viewport']['center_panel']) && count($this->attributes['viewport']['center_panel']) > 0) {
         $attributes = array_merge(array(), $this->attributes['viewport']['center_panel']);
     }
     if (isset($this->attributes['idxml'])) {
         $attributes['idxml'] = $this->attributes['idxml'];
     }
     if (isset($this->attributes['layoutType'])) {
         $attributes['layoutType'] = $this->attributes['layoutType'];
     }
     switch ($this->attributes['layoutType']) {
         case afPortalStatePeer::TYPE_NORMAL:
             if (isset($this->attributes['tools'])) {
                 if (!afExtjs::getInstance()->isDesktop()) {
                     $attributes['tools'] = $this->attributes['tools']->end();
                 } else {
                     $attributes['winTools'] = $this->attributes['tools']->end();
                     unset($attributes['tools']);
                 }
             }
             if (afExtjs::getInstance()->isDesktop()) {
                 $attributes['winTitle'] = $attributes['title'];
                 unset($attributes['title']);
             }
             if (isset($this->attributes['portalLayoutType'])) {
                 $attributes['portalLayoutType'] = $this->attributes['portalLayoutType'];
             }
             if (isset($this->attributes['portalWidgets'])) {
                 $attributes['portalWidgets'] = $this->attributes['portalWidgets'];
             }
             $attributes['autoScroll'] = true;
             //$attributes['id']='center_panel_first_panel';
             $attributes['border'] = false;
             $attributes['bodyBorder'] = false;
             /**
              * fixing ticket #1295 part 2
              * 
              * @author Radu Topala <*****@*****.**>
              */
             $attributes['dropConfig']['ddGroup'] = 'portal_' . Util::makeRandomKey() . '_dd';
             $this->afExtjs->privateAttributes['container'] = $attributes;
             $this->afExtjs->private['center_panel_first_panel'] = $this->afExtjs->Portal($attributes);
             $attributesPanel['items'][] = $this->afExtjs->asVar('center_panel_first_panel');
             $attributesPanel['border'] = true;
             $attributesPanel['bodyBorder'] = true;
             $attributesPanel['layout'] = 'fit';
             $attributesPanel['id'] = 'center_panel_first';
             $this->afExtjs->private['center_panel_first'] = $this->afExtjs->Panel($attributesPanel);
             $attributesPanelContainer['items'][] = $this->afExtjs->asVar('center_panel_first');
             $attributesPanelContainer['style'] = 'padding-right:5px;';
             $attributesPanelContainer['border'] = false;
             $attributesPanelContainer['bodyBorder'] = false;
             $attributesPanelContainer['layout'] = 'fit';
             $attributesPanelContainer['id'] = 'center_panel';
             $this->addPanel('center', $attributesPanelContainer);
             break;
         case afPortalStatePeer::TYPE_TABBED:
             $attributesTabPanel = array_merge($attributes, array('enableTabScroll' => true, 'deferredRender' => true, 'resizeTabs' => true, 'minTabWidth' => 115, 'tabWidth' => 135, 'frame' => false, 'collapsible' => false, 'afterLayoutOnceEvent' => false));
             /**
              * ticket #74, tickets.appflower.com
              * 
              * assign activeTab to the current #<tab-name> or to first tab if no hash is added in URI
              */
             $attributesTabPanel['listeners']['afterLayout'] = $this->afExtjs->asMethod(array('parameters' => 'tabPanel,layout', 'source' => "if(tabPanel.getActiveTab())tabPanel.getActiveTab().doLayout();\n\t\t\t\t          \t      \ttabPanel.setHeight(tabPanel.ownerCt.getInnerHeight()-1);\n\t\t\t\t          \t      \tif(tabPanel.afterLayoutOnceEvent==false){new Portals().onTabChange(tabPanel);}\n\t\t\t\t          \t      \t"));
             $attributesTabPanel['listeners']['tabchange'] = $this->afExtjs->asMethod(array('parameters' => 'tabPanel,tab', 'source' => "tabPanel.doLayout();if(tabPanel.getActiveTab().items){tabPanel.getActiveTab().items.items[0].afterLayoutEvent=false;tabPanel.getActiveTab().items.items[0].onPortalAfterLayout(tabPanel.getActiveTab().items.items[0]);}afApp.changeTabHash(tab);"));
             $attributesPanel['title'] = $attributesTabPanel['title'];
             unset($attributesTabPanel['title']);
             if (isset($this->attributes['tools'])) {
                 if (!afExtjs::getInstance()->isDesktop()) {
                     $attributesPanel['tools'] = $this->attributes['tools']->end();
                 } else {
                     $attributesTabPanel['winTools'] = $this->attributes['tools']->end();
                     unset($attributes['tools']);
                 }
             }
             if (afExtjs::getInstance()->isDesktop()) {
                 $attributesTabPanel['winTitle'] = $attributes['title'];
             }
             //$attributesTabPanel['id']='center_panel_first_panel';
             $this->afExtjs->private['center_panel_first_panel'] = $this->afExtjs->TabPanel($attributesTabPanel);
             $attributesPanel['items'][] = $this->afExtjs->asVar('center_panel_first_panel');
             $attributesPanel['border'] = true;
             $attributesPanel['bodyBorder'] = true;
             $attributesPanel['layout'] = 'fit';
             $attributesPanel['id'] = 'center_panel_first';
             $this->afExtjs->privateAttributes['container'] = $attributesPanel;
             $this->afExtjs->private['center_panel_first'] = $this->afExtjs->Panel($attributesPanel);
             $attributesPanelContainer['items'][] = $this->afExtjs->asVar('center_panel_first');
             $attributesPanelContainer['style'] = 'padding-right:5px;';
             $attributesPanelContainer['border'] = false;
             $attributesPanelContainer['bodyBorder'] = false;
             $attributesPanelContainer['layout'] = 'fit';
             $attributesPanelContainer['id'] = 'center_panel';
             $this->addPanel('center', $attributesPanelContainer);
             break;
     }
 }
コード例 #13
0
    public function __construct($containerObject, $attributes = array(), $parsedData = array())
    {
        $this->attributes['triggerAction'] = 'all';
        $this->attributes['minChars'] = isset($attributes['minChars']) ? $attributes['minChars'] : 1;
        $this->afExtjs = afExtjs::getInstance();
        /**
         * if isset button, then xtype will become combowbutton
         */
        if (isset($attributes['button'])) {
            $this->attributes['buttonConfig'] = $attributes['button'];
            $this->attributes['xtype'] = 'combowbutton';
            unset($attributes['button']);
            if (isset($attributes['window'])) {
                //				if(isset($attributes['window']['component'])&&is_object($attributes['window']['component']))
                //				{
                //					$this->attributes['windowConfig']['items'][]=$attributes['window']['component']->privateName;
                //
                //
                //
                //					unset($attributes['window']['component']);
                //				}
                $this->attributes['windowConfig'] = array_merge(isset($this->attributes['windowConfig']) ? $this->attributes['windowConfig'] : array(), $attributes['window']);
                unset($attributes['window']);
            }
            $this->attributes['width'] = '250';
            if (empty($attributes['options'])) {
                $this->attributes['store'] = '[[0,"No options available.."]]';
            }
        } else {
            $this->afExtjs->setAddons(array('js' => array($this->afExtjs->getPluginsDir() . 'form/Ext.ux.form.Combo.js')));
            $this->attributes['xtype'] = 'combowcolors';
            if (isset($attributes['proxy']) && isset($attributes['template'])) {
                /**
                 * autocomplete combo config
                 */
                $storePrivateName = 'store_' . Util::makeRandomKey();
                $readerPrivateName = 'reader_' . Util::makeRandomKey();
                $proxyPrivateName = 'proxy_' . Util::makeRandomKey();
                $templatePrivateName = 'tpl_' . Util::makeRandomKey();
                $xtemplatePrivateName = 'xtpl_' . Util::makeRandomKey();
                $attributes[$readerPrivateName]['totalProperty'] = 'totalCount';
                $attributes[$readerPrivateName]['root'] = 'rows';
                foreach ($attributes['proxy']['fields'] as $field) {
                    $attributes[$readerPrivateName]['fields'][] = $this->afExtjs->asAnonymousClass(array('name' => $field));
                }
                $attributes[$readerPrivateName]['fields'][] = $this->afExtjs->asAnonymousClass(array('name' => 'url'));
                $this->afExtjs->private[$readerPrivateName] = $this->afExtjs->JsonReader($attributes[$readerPrivateName]);
                unset($attributes[$readerPrivateName]);
                $attributes[$proxyPrivateName]['url'] = $attributes['proxy']['url'];
                $this->afExtjs->private[$proxyPrivateName] = $this->afExtjs->HttpProxy($attributes[$proxyPrivateName]);
                unset($attributes[$proxyPrivateName]);
                $attributes[$storePrivateName]['reader'] = $this->afExtjs->asVar($readerPrivateName);
                $attributes[$storePrivateName]['proxy'] = $this->afExtjs->asVar($proxyPrivateName);
                $this->afExtjs->private[$storePrivateName] = $this->afExtjs->Store($attributes[$storePrivateName]);
                unset($attributes[$storePrivateName]);
                $this->afExtjs->private[$templatePrivateName] = '<tpl for="."><div class="search-item">' . $attributes['template'] . '</div></tpl>';
                $this->afExtjs->private[$xtemplatePrivateName] = $this->afExtjs->XTemplate(array($this->afExtjs->asVar($templatePrivateName)));
                $this->attributes['typeAhead'] = false;
                $this->attributes['loadingText'] = 'Searching...';
                $this->attributes['width'] = '250';
                $this->attributes['pageSize'] = $attributes['proxy']['limit'];
                $this->attributes['hideTrigger'] = true;
                $this->attributes['itemSelector'] = 'div.search-item';
                $this->attributes['tpl'] = $this->afExtjs->asVar($xtemplatePrivateName);
                $this->attributes['store'] = $this->afExtjs->asVar($storePrivateName);
                $this->attributes['minChars'] = $attributes['proxy']['minChars'];
                if (isset($attributes['proxy']['selectedIndex'])) {
                    $this->attributes['onSelect'] = $this->afExtjs->asMethod(array("parameters" => "record", "source" => "if(record.data." . $attributes['proxy']['selectedIndex'] . "){var selectedValue=record.data." . $attributes['proxy']['selectedIndex'] . ";this.setRawValue(record.data." . $attributes['proxy']['selectedIndex'] . ");this.setValue(record.data." . $attributes['proxy']['selectedIndex'] . ");this.collapse();}"));
                }
                unset($attributes['proxy']);
                unset($attributes['template']);
            } else {
                /**
                 * normal combo config
                 */
                $this->attributes['forceSelection'] = true;
                $this->attributes['disableKeyFilter'] = true;
                $this->attributes['mode'] = 'local';
                $this->attributes['triggerAction'] = 'all';
                $this->attributes['width'] = '250';
            }
        }
        /**
         * the options attribute, an assoc array for now
         */
        if (isset($attributes['options']) && count($attributes['options']) > 0 && (!isset($attributes['plugin']) || isset($attributes['plugin']) && $attributes['plugin'] != 'autocompleter')) {
            $options = array();
            foreach ($attributes['options'] as $key => $value) {
                $tarray = null;
                $tarray[] = $key;
                if (is_array($value)) {
                    foreach ($value as $k => $v) {
                        $tarray[] = $v;
                    }
                } else {
                    $tarray[] = $value;
                    $tarray[] = '#FFFFFF';
                }
                $options[] = $tarray;
            }
            /**
             * options will be an array of arrays like ($key,$text,$color)
             */
            $this->attributes['store'] = $this->afExtjs->asVar(json_encode($options));
            unset($attributes['options']);
        } elseif (empty($attributes['options'])) {
            $this->attributes['store'] = '[[0,"No options available.."]]';
        }
        /**
         * selected attribute is the same as the value attribute, you can use either of them
         */
        if (isset($attributes['selected'])) {
            $this->attributes['value'] = $attributes['selected'];
            unset($attributes['selected']);
        }
        if (isset($attributes['name'])) {
            $this->attributes['hiddenName'] = substr($attributes['name'], -1) == ']' ? substr_replace($attributes['name'], '_value]', -1) : $attributes['name'] . '_value';
        }
        /*
         * Set plugins and default attributes
         */
        if (isset($attributes['plugin'])) {
            if ($attributes['plugin'] == 'extended_combo_box') {
                $this->afExtjs->setAddons(array('js' => array($this->afExtjs->getPluginsDir() . 'form/Ext.ux.plugins.ExtendedComboBox.js')));
                $this->attributes['plugins'][] = "Ext.ux.plugins.ExtendedComboBox";
                $this->attributes['resizable'] = true;
                $this->attributes['triggerAction'] = 'all';
                $this->attributes['forceSelection'] = true;
                $this->attributes['selectOnFocus'] = true;
                $this->attributes['hideLabel'] = true;
                $this->attributes['editable'] = false;
            }
            if ($attributes['plugin'] == 'autocompleter') {
                $this->afExtjs->setAddons(array('js' => array($this->afExtjs->getPluginsDir() . 'form/Ext.ux.plugins.RemoteComboAutoSuggest.js')));
                //$this->attributes['plugins'][]="Ext.ux.RemoteComboAutoSuggest";
                $this->attributes['resizable'] = true;
                $this->attributes['triggerAction'] = 'all';
                $this->attributes['forceSelection'] = true;
                $this->attributes['selectOnFocus'] = true;
                $this->attributes['mode'] = 'remote';
                $this->attributes['xtype'] = "remotecomboautosuggest";
                $this->attributes['enableKeyEvents'] = true;
                $this->attributes['disableKeyFilter'] = true;
                if (isset($attributes['url'])) {
                    $this->attributes['url'] = $attributes['url'];
                } else {
                    $this->attributes['url'] = '/appFlower/autocompleter';
                }
                $this->attributes['store'] = '[]';
                /**
                * example of i:value for autocompleter
                * <i:value type="orm">
                                            <i:class>ModelCriteriaFetcher</i:class>
                                            <i:method name="getDataForComboWidget">
                                                <i:param name="modelName">TicketType</i:param>
                                                <i:param name="lookupIn">Name</i:param>
                                            </i:method>
                                        </i:value>
                */
                if (isset($parsedData['value'])) {
                    $this->attributes['storeParams'] = $parsedData['value'];
                }
            }
            if ($attributes['plugin'] == 'fontfield') {
                $this->attributes['tpl'] = 'new Ext.XTemplate(
				       \'<tpl for="."><div class="x-combo-list-item" style="margin-bottom:10px;">{text}<br><span style="font-family:\\\'{text}\\\';font-size:15px;">A quick brown fox</span></div></tpl>\'
				    )';
            }
            if ($attributes['plugin'] == 'checkcombo') {
                $this->afExtjs->setAddons(array('js' => array($this->afExtjs->getPluginsDir() . 'form/lovcombo-1.0/js/Ext.ux.form.LovCombo.js')));
                $this->afExtjs->setAddons(array('css' => array($this->afExtjs->getPluginsDir() . 'form/lovcombo-1.0/css/Ext.ux.form.LovCombo.css')));
                //$this->attributes['plugins'][]="Ext.ux.RemoteComboAutoSuggest";
                $this->attributes['xtype'] = "lovcombo";
                $this->attributes['triggerAction'] = 'all';
                $this->attributes['editable'] = false;
                $this->attributes['mode'] = 'local';
            }
            unset($attributes['plugin']);
        }
        $this->attributes['listWidth'] = $this->attributes['width'];
        //print_r($this->attributes);die();
        parent::__construct($containerObject, $attributes);
    }
コード例 #14
0
 public function __construct($containerObject, $attributes = array())
 {
     $this->afExtjs = afExtjs::getInstance();
     if ($this->privateName == null) {
         $this->privateName = 'field_' . Util::makeRandomKey();
     }
     if (isset($attributes['break'])) {
         unset($attributes['break']);
     }
     $this->containerObject = $containerObject;
     $this->afExtjs->setAddons(array('js' => array($this->afExtjs->getPluginsDir() . 'form/Ext.ux.plugins.HelpText.js')));
     $this->attributes['plugins'][] = "Ext.ux.plugins.HelpText";
     if (@$attributes['vtype']) {
         $this->attributes['vtype'] = $attributes['vtype'];
     }
     //$this->attributes['labelStyle']='width:100px;font-size:11px;font-weight:bold;padding:0 3px 3px 0;';
     if (isset($attributes['state'])) {
         switch ($attributes['state']) {
             case "readonly":
                 $this->attributes['readOnly'] = true;
                 break;
             case "disabled":
                 $this->attributes['disabled'] = true;
                 break;
             case "editable":
                 $this->attributes['disabled'] = false;
                 $this->attributes['readOnly'] = false;
                 break;
         }
         unset($attributes['state']);
     }
     if (isset($attributes['name'])) {
         $this->attributes['name'] = $attributes['name'];
     }
     if (isset($attributes['label'])) {
         $this->attributes['fieldLabel'] = $attributes['label'];
         unset($attributes['label']);
     }
     if (isset($attributes['value']) && $attributes['value'] != null) {
         $this->attributes['value'] = $attributes['value'];
         unset($attributes['value']);
     }
     if (isset($attributes['handlers']) && $attributes['handlers'] != '') {
         if (isset($this->attributes['listeners'])) {
             foreach ($this->attributes['listeners'] as $type => $type_params) {
                 /**
                  * if listener function source is not an array then the string is used directly
                  */
                 if (isset($type_params['parameters']) && $type_params['parameters'] != '' && isset($type_params['source']) && !is_array($type_params['source'])) {
                     $this->attributes['listeners'][$type] = array('parameters' => $type_params['parameters'], 'source' => $type_params['source'] . (isset($attributes['handlers'][$type]) ? $attributes['handlers'][$type]['source'] : ""));
                 }
             }
         } else {
             $this->attributes['listeners'] = $attributes['handlers'];
         }
         unset($attributes['handlers']);
     }
     if (isset($attributes['help']) && $attributes['help'] != '') {
         if (!isset($this->attributes['listeners']['render']['source'])) {
             $this->attributes['listeners']['render']['source'] = '';
         }
         if (!isset($this->attributes['listeners']['render']['parameters'])) {
             $this->attributes['listeners']['render']['parameters'] = 'field';
         }
         $this->attributes['listeners']['render']['source'] .= "new Ext.ToolTip({target: field.getEl(),html: '" . $attributes['help'] . "'});";
         unset($attributes['help']);
     }
     /**
      * TYPES:
      * comment || inline
      */
     $this->attributes['helpType'] = isset($attributes['helpType']) ? $attributes['helpType'] : 'comment';
     if (isset($attributes['comment']) && $attributes['comment'] != '') {
         $this->attributes['helpText'] = '<i>' . $attributes['comment'] . '</i>';
         unset($attributes['comment']);
     }
     if (count($attributes) > 0) {
         $this->attributes = array_merge($this->attributes, $attributes);
     }
     //process the field and attach it to the current containerObject
     $this->end();
 }
コード例 #15
0
 /**
  * File fields processing
  *
  * @example <i:field label="File" name="file" type="file">
  *              <i:value type="orm">
  *                  <i:class>ModelCriteriaFetcher</i:class>
  *                  <i:method name="configureFileField">
  *                      <i:param name="fields">[path:file_path_field]</i:param>
  *                  </i:method>
  *              </i:value>
  *          </i:field>
  *          
  *          if multiple files for table should be added <i:param name="glue_model">ForeignModelName</i:param>
  *          
  * @param BaseObject $model 
  * @return void
  * @author Sergey Startsev
  */
 public function processFileFields(BaseObject $model)
 {
     $model_name = $this->object->getPeer()->getOMClass(false);
     $upload_dir = sfConfig::get('sf_upload_dir');
     $web_upload_dir = str_replace(sfConfig::get('sf_web_dir'), '', $upload_dir);
     if (!file_exists($upload_dir)) {
         mkdir($upload_dir);
     }
     foreach ($this->dom_xml_xpath->query('//i:fields/i:field[@type="file"]') as $field) {
         $name = $field->getAttribute('name');
         $params = array();
         $class = $field->getElementsByTagName('class');
         $method = $field->getElementsByTagName('method');
         if (!$class || !$method) {
             continue;
         }
         $classNode = $class->item(0);
         $methodNode = $method->item(0);
         if ($classNode->nodeValue != 'ModelCriteriaFetcher' || $methodNode->getAttribute('name') != 'configureFileField') {
             continue;
         }
         foreach ($methodNode->getElementsByTagName('param') as $param) {
             $params[$param->getAttribute('name')] = $param->nodeValue;
         }
         $is_foreign = false;
         $hashes = array();
         if (!array_key_exists('fields', $params)) {
             continue;
         }
         foreach (explode(',', str_replace(array('[', ']'), '', $params['fields'])) as $def) {
             list($key, $value) = explode(':', $def);
             $hashes[$key] = $value;
         }
         if (array_key_exists('glue_model', $params)) {
             $glue_model = $params['glue_model'];
             $is_foreign = true;
         }
         if (array_key_exists('upload_dir', $params)) {
             $web_upload_dir = '/' . trim($params['upload_dir'], '/');
             $upload_dir = sfConfig::get('sf_web_dir') . $web_upload_dir;
             if (!file_exists($upload_dir)) {
                 @mkdir($upload_dir, 0775, true);
             }
         }
         if (!isset($_FILES['edit']['name']['0'][$name]) || !$_FILES['edit']['size']['0'][$name]) {
             continue;
         }
         $file_native_name = $_FILES['edit']['name']['0'][$name];
         $file_size = $_FILES['edit']['size']['0'][$name];
         $file_name = Util::makeRandomKey() . '.' . pathinfo($file_native_name, PATHINFO_EXTENSION);
         $file_path = "{$upload_dir}/{$file_name}";
         $tmp_name = $_FILES['edit']['tmp_name']['0'][$name];
         if (!move_uploaded_file($tmp_name, $file_path)) {
             continue;
         }
         if ($is_foreign) {
             $glue = new $glue_model();
             call_user_func(array($glue, "set" . get_class($model)), $model);
         } else {
             $glue = $model;
         }
         if (array_key_exists('path', $hashes)) {
             $glue->setByName($hashes['path'], "{$web_upload_dir}/{$file_name}", BasePeer::TYPE_FIELDNAME);
         }
         if (array_key_exists('original_name', $hashes)) {
             $glue->setByName($hashes['original_name'], $file_native_name, BasePeer::TYPE_FIELDNAME);
         }
         if (array_key_exists('name', $hashes)) {
             $glue->setByName($hashes['name'], $file_name, BasePeer::TYPE_FIELDNAME);
         }
         if (array_key_exists('size', $hashes)) {
             $glue->setByName($hashes['size'], $file_size, BasePeer::TYPE_FIELDNAME);
         }
         $glue->save();
     }
 }
コード例 #16
0
 public function end()
 {
     $this->privateName = 'grid_actions_' . Util::makeRandomKey();
     $this->afExtjs->private[$this->privateName] = $this->afExtjs->GridRowActions($this->attributes);
 }
コード例 #17
0
 public function end()
 {
     $this->privateName = 'filetree_' . Util::makeRandomKey();
     $this->afExtjs->private[$this->privateName] = $this->afExtjs->FileTreePanel($this->attributes);
 }
コード例 #18
0
 public function __construct($containerObject, $attributes = array())
 {
     $this->attributes['triggerAction'] = 'all';
     $this->afExtjs = afExtjs::getInstance();
     $this->afExtjs->setAddons(array('js' => array($this->afExtjs->getPluginsDir() . 'superboxselect/SuperBoxSelect.js'), 'css' => array($this->afExtjs->getPluginsDir() . 'superboxselect/superboxselect.css')));
     $this->attributes['xtype'] = 'superboxselect';
     $this->attributes['resizable'] = true;
     $this->attributes['anchor'] = '95%';
     $this->attributes['allowAddNewData'] = true;
     $this->attributes['mode'] = 'remote';
     $this->attributes['displayField'] = 'name';
     $this->attributes['minChars'] = 1;
     $this->attributes['valueField'] = 'id';
     $template = '<tpl for="."><div class="x-combo-list-item">{name} <span style="color:#888;margin-left:5px;font-size:11px">{description}</span></div></tpl>';
     $this->attributes['tpl'] = $this->afExtjs->asVar("new Ext.XTemplate('" . $template . "')");
     if (isset($attributes['url'])) {
         /**
          * autocomplete combo config
          */
         $storePrivateName = 'store_' . Util::makeRandomKey();
         $readerPrivateName = 'reader_' . Util::makeRandomKey();
         $proxyPrivateName = 'proxy_' . Util::makeRandomKey();
         $attributes[$readerPrivateName]['totalProperty'] = 'totalCount';
         $attributes[$readerPrivateName]['root'] = 'rows';
         $attributes[$readerPrivateName]['fields'][] = $this->afExtjs->asAnonymousClass(array('name' => "id"));
         $attributes[$readerPrivateName]['fields'][] = $this->afExtjs->asAnonymousClass(array('name' => "name"));
         $attributes[$readerPrivateName]['fields'][] = $this->afExtjs->asAnonymousClass(array('name' => "description"));
         $attributes[$readerPrivateName]['fields'][] = $this->afExtjs->asAnonymousClass(array('name' => 'url'));
         $this->afExtjs->private[$readerPrivateName] = $this->afExtjs->JsonReader($attributes[$readerPrivateName]);
         unset($attributes[$readerPrivateName]);
         $attributes[$proxyPrivateName]['url'] = $attributes['url'];
         $this->afExtjs->private[$proxyPrivateName] = $this->afExtjs->HttpProxy($attributes[$proxyPrivateName]);
         unset($attributes[$proxyPrivateName]);
         $attributes[$storePrivateName]['reader'] = $this->afExtjs->asVar($readerPrivateName);
         $attributes[$storePrivateName]['proxy'] = $this->afExtjs->asVar($proxyPrivateName);
         $this->afExtjs->private[$storePrivateName] = $this->afExtjs->Store($attributes[$storePrivateName]);
         unset($attributes[$storePrivateName]);
         $this->attributes['loadingText'] = 'Searching...';
         $this->attributes['store'] = $this->afExtjs->asVar($storePrivateName);
     }
     /**
      * the options attribute, an assoc array for now
      */
     if (isset($attributes['options']) && count($attributes['options']) > 0) {
         $options = array();
         foreach ($attributes['options'] as $key => $value) {
             $tarray = null;
             $tarray[] = $key;
             if (is_array($value)) {
                 foreach ($value as $k => $v) {
                     $tarray[] = $v;
                 }
             } else {
                 $tarray[] = $value;
                 $tarray[] = '#FFFFFF';
             }
             $options[] = $tarray;
         }
         /**
          * options will be an array of arrays like ($key,$text,$color)
          */
         $this->attributes['store'] = $this->afExtjs->asVar(json_encode($options));
         unset($attributes['options']);
     }
     /**
      * selected attribute is the same as the value attribute, you can use either of them
      */
     if (isset($attributes['selected'])) {
         $this->attributes['value'] = $attributes['selected'];
         unset($attributes['selected']);
     }
     if (isset($attributes['name'])) {
         $this->attributes['hiddenName'] = substr($attributes['name'], -1) == ']' ? substr_replace($attributes['name'], '_value]', -1) : $attributes['name'] . '_value';
     }
     parent::__construct($containerObject, $attributes);
 }