Exemple #1
0
 /**
  * Set object property
  */
 public function setpropertyAction()
 {
     $id = Request::post('id', 'string', false);
     $property = Request::post('name', 'string', false);
     $value = Request::post('value', 'raw', false);
     if (!$id || !$this->_object->getFiltersFeature()->filterExists($id)) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     $object = $this->_object->getFiltersFeature()->getFilter($id);
     if (!$object->isValidProperty($property)) {
         Response::jsonError();
     }
     $object->{$property} = $value;
     $this->_storeProject();
     Response::jsonSuccess();
 }
Exemple #2
0
 public function addactionAction()
 {
     $object = $this->_object;
     $actionName = Request::post('name', 'alphanum', false);
     $column = Request::post('column', 'string', false);
     if ($actionName === false || $column === false) {
         Response::jsonErrot($this->_lang->WRONG_REQUEST . ' code 1');
     }
     if ($object->getClass() !== 'Grid' || !$object->columnExists($column)) {
         Response::jsonError($this->_lang->WRONG_REQUEST . ' code 2');
     }
     $columnObject = $object->getColumn($column);
     if ($columnObject->getClass() !== 'Grid_Column_Action') {
         Response::jsonError($this->_lang->WRONG_REQUEST . ' code 3');
     }
     $actionName = $this->_object->getName() . '_action_' . $actionName;
     if ($columnObject->actionExists($actionName)) {
         Response::jsonError($this->_lang->SB_UNIQUE);
     }
     $newButton = Ext_Factory::object('Grid_Column_Action_Button', array('text' => $actionName));
     $newButton->setName($actionName);
     $columnObject->addAction($actionName, $newButton);
     $this->_storeProject();
     Response::jsonSuccess();
 }
Exemple #3
0
 /**
  * Conver DB column into Ext field
  * @param string $name
  * @param array $config
  */
 protected function _importDbField($name, $config)
 {
     $newField = Backend_Designer_Import::convertDbFieldToExtField($config);
     if ($newField !== false) {
         $newField->setName($this->_object->getName() . '_' . $name);
         $this->_project->addObject($this->_object->getName(), $newField);
     }
 }
Exemple #4
0
 /**
  * Add store field
  */
 public function addfieldAction()
 {
     $this->_checkLoaded();
     $this->_checkObject();
     $id = Request::post('id', 'string', false);
     if (!$id || $this->_object->fieldExists($id)) {
         Response::jsonError($this->_lang->FIELD_EXISTS);
     }
     if ($this->_object->addField(array('name' => $id, 'type' => 'string'))) {
         $o = $this->_object->getField($id);
         $this->_storeProject();
         Response::jsonSuccess(array('name' => $o->name, 'type' => $o->type));
     } else {
         Response::jsonError($this->_lang->CANT_EXEC);
     }
 }
Exemple #5
0
 /**
  * Get advanced properties for grid object
  */
 public function loadadvancedAction()
 {
     Response::jsonSuccess($this->_object->getAdvancedProperties());
 }
Exemple #6
0
 /**
  * Change grid filter type
  */
 public function changefiltertypeAction()
 {
     $type = Request::post('type', 'string', '');
     $filterId = Request::post('filterid', 'pagecode', false);
     if (!$filterId) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     if (strlen($type)) {
         $name = 'Grid_Filter_' . ucfirst($type);
     } else {
         $name = 'Grid_Filter_String';
     }
     $oldFilter = $this->_object->getFiltersFeature()->getFilter($filterId);
     $newFilter = Ext_Factory::object($name);
     Ext_Factory::copyProperties($oldFilter, $newFilter);
     $newFilter->setName($oldFilter->getName());
     switch ($type) {
         case 'date':
             if (empty($newFilter->dateFormat)) {
                 $newFilter->dateFormat = "Y-m-d";
             }
             if (empty($newFilter->afterText)) {
                 $newFilter->afterText = '[js:] appLang.FILTER_AFTER_TEXT';
             }
             if (empty($newFilter->beforeText)) {
                 $newFilter->beforeText = '[js:] appLang.FILTER_BEFORE_TEXT';
             }
             if (empty($newFilter->onText)) {
                 $newFilter->onText = '[js:] appLang.FILTER_ON_TEXT';
             }
             break;
         case 'datetime':
             if (empty($newFilter->dateFormat)) {
                 $newFilter->dateFormat = "Y-m-d";
             }
             $newFilter->date = '{format: "Y-m-d"}';
             $newFilter->time = '{format: "H:i:s",increment:1}';
             if (empty($newFilter->afterText)) {
                 $newFilter->afterText = '[js:] appLang.FILTER_AFTER_TEXT';
             }
             if (empty($newFilter->beforeText)) {
                 $newFilter->beforeText = '[js:] appLang.FILTER_BEFORE_TEXT';
             }
             if (empty($newFilter->onText)) {
                 $newFilter->onText = '[js:] appLang.FILTER_ON_TEXT';
             }
             break;
         case 'list':
             $newFilter->phpMode = true;
             break;
         case 'boolean':
             $newFilter->noText = '[js:] appLang.NO';
             $newFilter->yesText = '[js:] appLang.YES';
             break;
     }
     if (!$this->_object->getFiltersFeature()->setFilter($filterId, $newFilter)) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     $this->_storeProject();
     Response::jsonSuccess();
 }
Exemple #7
0
 /**
  * Add listeners for actioncolumn's
  * @param Ext_Grid $grid
  */
 protected function _applycolumnEvents(Ext_Grid $grid)
 {
     $columns = $grid->getColumns();
     if (empty($columns)) {
         return;
     }
     $eventManager = $this->_project->getEventManager();
     foreach ($columns as $k => $v) {
         if (is_object($v['data']->editor)) {
             $this->_convertColumnEditorActions($v['data']);
         }
         if ($v['data']->getClass() === 'Grid_Column_Action') {
             $this->_convertColumnActions($v['data']);
         }
     }
 }