Exemple #1
0
 public function __toString()
 {
     $this->_config->setXType('');
     $this->_config->setFType('filters');
     $this->_config->filters = "[\n\t" . Utils_String::addIndent(implode(",\n", array_values($this->_filters)), 2) . "\n]";
     return parent::__toString();
 }
Exemple #2
0
 /**
  * Copy properties from Ext_Object
  * @param Ext_Object $from
  * @param Ext_Object $to
  */
 public static function copyProperties(Ext_Object $from, Ext_Object $to)
 {
     $properties = $from->getConfig()->__toArray();
     if (empty($properties)) {
         return;
     }
     foreach ($properties as $k => $v) {
         if ($to->isValidProperty($k)) {
             try {
                 $to->{$k} = $v;
             } catch (Exception $e) {
                 /*
                  * ignore wrong properties
                  */
             }
         }
     }
 }
Exemple #3
0
 public function __get($name)
 {
     $this->_convertFields();
     if ($name === 'fields') {
         return array_values($this->getFields());
     } else {
         return parent::__get($name);
     }
 }
Exemple #4
0
 public function __construct()
 {
     parent::__construct();
     $this->_columns = new Tree();
 }
Exemple #5
0
 /**
  * (non-PHPdoc)
  * @see Ext_Object::__toString()
  */
 public function __toString()
 {
     if (!empty($this->_fields) && $this->_config->isValidProperty('fields')) {
         $this->fields = '[' . implode(',', array_values($this->_fields)) . ']';
     }
     return parent::__toString();
 }
Exemple #6
0
 public function __construct($class)
 {
     $this->_class = ucfirst($class);
     parent::__construct();
 }
Exemple #7
0
 /**
  * Add Ext_Object to the project
  * @param string $parent - parant object name or "0" for root
  * @param Ext_Object $object
  * @return boolean - success flag
  */
 public function addObject($parent, Ext_Object $object)
 {
     if (strlen($parent) && $parent !== 0 && !$this->objectExists($parent) || in_array($object->getClass(), self::$_nonDraggable, true)) {
         $parent = 0;
     }
     return $this->_tree->addItem($object->getName(), $parent, $object);
 }
Exemple #8
0
 /**
  * Set default properties for new object
  * @param Ext_Object $object
  * @return void
  */
 protected function _initDefaultProperties(Ext_Object $object)
 {
     $oClass = $object->getClass();
     switch ($oClass) {
         case 'Window':
             $object->width = 300;
             $object->height = 300;
             break;
         case 'Button':
         case 'Button_Split':
             $object->text = $object->getName();
             break;
         case 'Grid':
             $object->columnLines = true;
             break;
     }
     if (strpos($oClass, 'Component_Window_') !== false) {
         $object->width = 700;
         $object->height = 700;
     }
 }
Exemple #9
0
    public function addGridMethods(Designer_Project $project, Ext_Object $grid, $object, $vc = false)
    {
        $methodsManager = $project->getMethodManager();
        $m = $methodsManager->addMethod($grid->getName(), 'initComponent', array(), '
            this.addDesignerItems();
            this.callParent();

            if(!Ext.isEmpty(this.canEdit) && !Ext.isEmpty(this.setCanEdit)){
                this.setCanEdit(this.canEdit);
            }else{
                this.canEdit = false;
            }

            if(!Ext.isEmpty(this.canDelete) && !Ext.isEmpty(this.setCanDelete)){
                this.setCanDelete(this.canDelete);
            }else{
                this.canDelete = false;
            }

            if(!Ext.isEmpty(this.canPublish) && !Ext.isEmpty(this.setCanPublish)){
                this.setCanPublish(this.canPublish);
            }else{
                this.canPublish = false;
            }
        ');
        $urlTemplates = $this->designerConfig->get('templates');
        $deleteUrl = Request::url(array($urlTemplates['adminpath'], $object, 'delete'));
        $m = $methodsManager->addMethod($grid->getName(), 'deleteRecord', array(array('name' => 'record', 'type' => 'Ext.data.record')), '
            Ext.Ajax.request({
                url:"' . $deleteUrl . '",
                method: "post",
                scope:this,
                params:{
                    id: record.get("id")
                },
                success: function(response, request) {
                    response =  Ext.JSON.decode(response.responseText);
                    if(response.success){
                        this.getStore().remove(record);
                    }else{
                        Ext.Msg.alert(appLang.MESSAGE , response.msg);
                    }
                },
                failure:function(){
                    Ext.Msg.alert(appLang.MESSAGE, appLang.MSG_LOST_CONNECTION);
                }
		    });
          ');
        $m->setDescription('Delete record');
        $m = $methodsManager->addMethod($grid->getName(), 'setCanEdit', array(array('name' => 'canEdit', 'type' => 'boolean')), '
        this.canEdit = canEdit;
        if(canEdit){
          this.childObjects.addButton.show();
        }else{
          this.childObjects.addButton.hide();
        }
        this.getView().refresh();
    ');
        $m->setDescription('Set edit permission');
        $m = $methodsManager->addMethod($grid->getName(), 'setCanDelete', array(array('name' => 'canDelete', 'type' => 'boolean')), ' this.canDelete = canDelete;');
        $m->setDescription('Set delete permission');
        if ($vc) {
            $m = $methodsManager->addMethod($grid->getName(), 'setCanPublish', array(array('name' => 'canPublish', 'type' => 'boolean')), 'this.canPublish = canPublish;');
            $m->setDescription('Set publish permission');
        }
        $editCode = '
        var win = Ext.create("' . $project->namespace . '.editWindow", {
  		          dataItemId:id,
  		          canDelete:this.canDelete,';
        if ($vc) {
            $editCode .= '
                  canPublish:this.canPublish,';
        }
        $editCode .= 'canEdit:this.canEdit';
        $editCode .= '
  		    });

            win.on("dataSaved",function(){
                this.getStore().load();
              ';
        if (!$vc) {
            $editCode .= 'win.close();';
        }
        $editCode .= '},this);

            win.show();
    ';
        $m = $methodsManager->addMethod($grid->getName(), 'showEditWindow', array(array('name' => 'id', 'type' => 'integer')), $editCode);
        $m->setDescription('Show editor window');
    }
Exemple #10
0
 public function __toString()
 {
     $this->_config->type = $this->getType();
     return parent::__toString();
 }