Exemplo n.º 1
0
    public function __toString()
    {
        $this->_convertListeners();
        $combo = Ext_Factory::object('Form_Field_Combobox');
        $combo->setName($this->getName());
        Ext_Factory::copyProperties($this, $combo);
        if ($this->isValidProperty('dictionary') && strlen($this->dictionary)) {
            $dM = new Dictionary_Manager();
            if ($dM->isValidDictionary($this->dictionary)) {
                $allowBlank = false;
                if ($this->_config->allowBlank && !$this->_config->showAll) {
                    $allowBlank = true;
                }
                if ($this->_config->isValidProperty('showAll') && !empty($this->_config->showAllText)) {
                    $allText = $this->_config->showAllText;
                } else {
                    $allText = false;
                }
                $data = Dictionary::getInstance($this->dictionary)->__toJs($this->_config->showAll, $allowBlank, $allText);
                if (strlen($data)) {
                    $combo->store = 'Ext.create("Ext.data.Store",{
					        model:"app.comboStringModel",
					        data: ' . $data . '
						 })';
                }
            }
        }
        return $combo->getConfig()->__toString();
    }
Exemplo n.º 2
0
 /**
  * Conver field from ORM format and add to the project
  * @param string $name
  * @param Db_Object_Config $importObject
  */
 protected function _importOrmField($name, $importObjectConfig)
 {
     $tabName = $this->_object->getName() . '_generalTab';
     if (!$this->_project->objectExists($tabName)) {
         $tab = Ext_Factory::object('Panel');
         $tab->setName($tabName);
         $tab->frame = false;
         $tab->border = false;
         $tab->layout = 'anchor';
         $tab->bodyPadding = 3;
         $tab->bodyCls = 'formBody';
         $tab->anchor = '100%';
         $tab->autoScroll = true;
         $tab->title = Lang::lang()->GENERAL;
         $tab->fieldDefaults = "{\n\t\t\t            labelAlign: 'right',\n\t\t\t            labelWidth: 160,\n\t\t\t            anchor: '100%'\n\t\t\t     }";
         $this->_project->addObject($this->_object->getName(), $tab);
     }
     $tabsArray = array('Component_Field_System_Medialibhtml', 'Component_Field_System_Related', 'Component_Field_System_Objectslist');
     $newField = Backend_Designer_Import::convertOrmFieldToExtField($name, $importObjectConfig->getFieldConfig($name));
     if ($newField !== false) {
         $fieldClass = $newField->getClass();
         if ($fieldClass == 'Component_Field_System_Objectslist' || $fieldClass == 'Component_Field_System_Objectlink') {
             $newField->controllerUrl = $this->_object->controllerUrl;
         }
         $newField->setName($this->_object->getName() . '_' . $name);
         if (in_array($fieldClass, $tabsArray, true)) {
             $this->_project->addObject($this->_object->getName(), $newField);
         } else {
             $this->_project->addObject($tabName, $newField);
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Lazy loading for events
  */
 protected function _initEvents()
 {
     if ($this->_events !== false) {
         return;
     }
     if (is_null($this->_class)) {
         $this->_class = str_replace('Ext_Property_', '', get_class($this->_properties));
     }
     $this->_events = Ext_Factory::getEvents($this->_class);
 }
Exemplo n.º 4
0
 /**
  * Add store field
  * @param Ext_Virtual | array $object
  * @return boolean
  */
 public function addField($object)
 {
     if ($object instanceof Ext_Virtual && $object->getClass() == 'Data_Field') {
         if (empty($object->name)) {
             return false;
         }
     } elseif (is_array($object)) {
         if (!isset($object['name'])) {
             return false;
         }
         $object = Ext_Factory::object('Data_Field', $object);
     } else {
         return false;
     }
     $this->_fields[$object->name] = $object;
     return true;
 }
Exemplo n.º 5
0
 /**
  * Change field type
  */
 public function changetypeAction()
 {
     $this->_checkLoaded();
     $object = $this->_getObject();
     $column = $this->_getColumn();
     $type = Request::post('type', 'string', false);
     $adapter = Request::post('adapter', 'string', false);
     $dictionary = Request::post('dictionary', 'string', false);
     if ($type === 'Form_Field_Adapter') {
         $newObject = Ext_Factory::object($adapter);
         /*
          * Invalid adapter
          */
         if (!$adapter || !strlen($adapter) || !class_exists($adapter)) {
             Response::jsonError($this->_lang->INVALID_VALUE, array('adapter' => $this->_lang->INVALID_VALUE));
         }
         if ($adapter === 'Ext_Component_Field_System_Dictionary') {
             /*
              * Inavalid dictionary
              */
             if (!$dictionary || !strlen($dictionary)) {
                 Response::jsonError($this->_lang->INVALID_VALUE, array('dictionary' => $this->_lang->INVALID_VALUE));
             }
             $newObject->dictionary = $dictionary;
         }
     } else {
         $newObject = Ext_Factory::object($type);
         /*
          * No changes
          */
         if ($type === $object->getClass()) {
             Response::jsonSuccess();
         }
     }
     Ext_Factory::copyProperties($object, $newObject);
     $newObject->setName($object->getName());
     $this->_getProject()->getEventManager()->removeObjectEvents($newObject->getName());
     $this->_setEditor($newObject);
     $this->_storeProject();
     Response::jsonSuccess();
 }
Exemplo n.º 6
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();
 }
Exemplo n.º 7
0
 public function createModule($object, $projectFile, $actionFile)
 {
     $lang = Lang::lang();
     //prepare class name
     $name = Utils_String::formatClassName($object);
     $jsName = str_replace('_', '', $name);
     $runNamespace = 'app' . $jsName . 'Run';
     $classNamespace = 'app' . $jsName . 'Classes';
     $objectConfig = Db_Object_Config::getInstance($object);
     $primaryKey = $objectConfig->getPrimaryKey();
     $appConfig = Registry::get('main', 'config');
     $designerConfig = Config::factory(Config::File_Array, $appConfig->get('configs') . 'designer.php');
     $objectFieldsConfig = $objectConfig->getFieldsConfig(false);
     $objectFields = array();
     $searchFields = array();
     $linkedObjects = array();
     /*
      * Skip text fields
      */
     foreach ($objectFieldsConfig as $key => $item) {
         if ($objectConfig->isObjectLink($key) || $objectConfig->isMultiLink($key)) {
             $linkedObjects[] = $objectConfig->getLinkedObject($key);
         }
         if (in_array($item['db_type'], Db_Object_Builder::$textTypes, true)) {
             continue;
         }
         $objectFields[] = $key;
         if (isset($item['is_search']) && $item['is_search']) {
             $searchFields[] = $key;
         }
     }
     $dataFields = array();
     foreach ($objectConfig->getFieldsConfig(true) as $key => $item) {
         if (in_array($item['db_type'], Db_Object_Builder::$textTypes, true)) {
             continue;
         }
         $dataFields[] = $key;
     }
     array_unshift($objectFields, $primaryKey);
     $controllerContent = '<?php ' . "\n" . 'class Backend_' . $name . '_Controller extends Backend_Controller_Crud{' . "\n" . '	protected $_listFields = array("' . implode('","', $dataFields) . '");' . "\n" . '  protected $_canViewObjects = array("' . implode('","', $linkedObjects) . '");' . "\n" . '} ';
     /*
      * Create controller
      */
     $controllerDir = $appConfig->get('backend_controllers') . str_replace('_', '/', $name);
     $this->_createControllerFile($controllerDir, $controllerContent);
     @chmod($controllerDir . DIRECTORY_SEPARATOR . 'Controller.php', $controllerContent, 0775);
     /*
      * Designer project
      */
     $project = new Designer_Project();
     $project->namespace = $classNamespace;
     $project->runnamespace = $runNamespace;
     /*
      * Project events
      */
     $eventManager = $project->getEventManager();
     $storeFields = Backend_Designer_Import::checkImportORMFields($object, $dataFields);
     $urlTemplates = $designerConfig->get('templates');
     Request::setDelimiter($urlTemplates['urldelimiter']);
     $controllerUrl = Request::url(array($urlTemplates['adminpath'], $object, ''), false);
     $storeUrl = Request::url(array($urlTemplates['adminpath'], $object, 'list'));
     Request::setDelimiter($appConfig->get('urlDelimiter'));
     $dataStore = Ext_Factory::object('Data_Store');
     $dataStore->setName('dataStore');
     $dataStore->autoLoad = true;
     $dataStore->addFields($storeFields);
     $dataProxy = Ext_Factory::object('Data_Proxy_Ajax');
     $dataProxy->type = 'ajax';
     $dataReader = Ext_Factory::object('Data_Reader_Json');
     $dataReader->root = 'data';
     $dataReader->totalProperty = 'count';
     $dataReader->idProperty = $primaryKey;
     $dataReader->type = 'json';
     $dataProxy->reader = $dataReader;
     $dataProxy->url = $storeUrl;
     $dataProxy->startParam = 'pager[start]';
     $dataProxy->limitParam = 'pager[limit]';
     $dataProxy->sortParam = 'pager[sort]';
     $dataProxy->directionParam = 'pager[dir]';
     $dataProxy->simpleSortMode = true;
     $dataStore->proxy = $dataProxy;
     $dataStore->remoteSort = true;
     $project->addObject(0, $dataStore);
     /*
      * Data grid
      */
     $dataGrid = Ext_Factory::object('Grid');
     $dataGrid->setName('dataGrid');
     $dataGrid->store = 'dataStore';
     $dataGrid->columnLines = true;
     $dataGrid->title = $objectConfig->getTitle() . ' :: ' . $lang->HOME;
     $dataGrid->setAdvancedProperty('paging', true);
     $dataGrid->viewConfig = '{enableTextSelection: true}';
     $eventManager->setEvent('dataGrid', 'itemdblclick', 'show' . $jsName . 'EditWindow(record.get("id"));');
     $objectFieldList = Backend_Designer_Import::checkImportORMFields($object, $objectFields);
     if (!empty($objectFieldList)) {
         foreach ($objectFieldList as $fieldConfig) {
             switch ($fieldConfig->type) {
                 case 'boolean':
                     $column = Ext_Factory::object('Grid_Column_Boolean');
                     $column->renderer = 'Ext_Component_Renderer_System_Checkbox';
                     $column->width = 50;
                     $column->align = 'center';
                     break;
                 case 'integer':
                     $column = Ext_Factory::object('Grid_Column');
                     break;
                 case 'float':
                     $column = Ext_Factory::object('Grid_Column_Number');
                     if (isset($objectFieldsConfig[$fieldConfig->name]['db_precision'])) {
                         $column->format = '0,000.' . str_repeat('0', $objectFieldsConfig[$fieldConfig->name]['db_precision']);
                     }
                     break;
                 case 'date':
                     $column = Ext_Factory::object('Grid_Column_Date');
                     if ($objectFieldsConfig[$fieldConfig->name]['db_type'] == 'time') {
                         $column->format = 'H:i:s';
                     }
                     break;
                 default:
                     $column = Ext_Factory::object('Grid_Column');
             }
             if ($objectConfig->fieldExists($fieldConfig->name)) {
                 $cfg = $objectConfig->getFieldConfig($fieldConfig->name);
                 $column->text = $cfg['title'];
             } else {
                 $column->text = $fieldConfig->name;
             }
             $column->dataIndex = $fieldConfig->name;
             $column->setName($fieldConfig->name);
             $column->itemId = $column->getName();
             $dataGrid->addColumn($column->getName(), $column, $parent = 0);
         }
     }
     $project->addObject(0, $dataGrid);
     /*
      * Top toolbar
      */
     $dockObject = Ext_Factory::object('Docked');
     $dockObject->setName($dataGrid->getName() . '__docked');
     $project->addObject($dataGrid->getName(), $dockObject);
     $filters = Ext_Factory::object('Toolbar');
     $filters->setName('filters');
     $project->addObject($dockObject->getName(), $filters);
     /*
      * Top toolbar items
      */
     $addButton = Ext_Factory::object('Button');
     $addButton->setName('addButton');
     $addButton->text = $lang->ADD_ITEM;
     $eventManager->setEvent('addButton', 'click', 'show' . $jsName . 'EditWindow(false);');
     $project->addObject($filters->getName(), $addButton);
     $sep1 = Ext_Factory::object('Toolbar_Separator');
     $sep1->setName('sep1');
     $project->addObject($filters->getName(), $sep1);
     if (!empty($searchFields)) {
         $searchField = Ext_Factory::object('Component_Field_System_Searchfield');
         $searchField->setName('searchField');
         $searchField->width = 200;
         $searchField->store = $dataStore->getName();
         $searchField->fieldNames = json_encode($searchFields);
         $fill = Ext_Factory::object('Toolbar_Fill');
         $fill->setName('fill1');
         $project->addObject($filters->getName(), $fill);
         $project->addObject($filters->getName(), $searchField);
     }
     /*
      * Editor window
      */
     $editWindow = Ext_Factory::object('Component_Window_System_Crud');
     $editWindow->setName('editWindow');
     $editWindow->objectName = $object;
     $editWindow->controllerUrl = $controllerUrl;
     $editWindow->width = 800;
     $editWindow->height = 650;
     $editWindow->modal = true;
     $editWindow->resizable = true;
     $editWindow->extendedComponent(true);
     $eventManager->setEvent('editWindow', 'dataSaved', $runNamespace . '.dataStore.load();');
     if (!$objectConfig->hasHistory()) {
         $editWindow->hideEastPanel = true;
     }
     $project->addObject(0, $editWindow);
     $tab = Ext_Factory::object('Panel');
     $tab->setName($editWindow->getName() . '_generalTab');
     $tab->frame = false;
     $tab->border = false;
     $tab->layout = 'anchor';
     $tab->bodyPadding = 3;
     $tab->bodyCls = 'formBody';
     $tab->anchor = '100%';
     $tab->title = $lang->GENERAL;
     $tab->autoScroll = true;
     $tab->fieldDefaults = "{\n\t\t            labelAlign: 'right',\n\t\t            labelWidth: 160,\n\t\t            anchor: '100%'\n\t\t     }";
     $project->addObject($editWindow->getName(), $tab);
     $objectFieldList = array_keys($objectConfig->getFieldsConfig(false));
     foreach ($objectFieldList as $field) {
         if ($field == $primaryKey) {
             continue;
         }
         $newField = Backend_Designer_Import::convertOrmFieldToExtField($field, $objectConfig->getFieldConfig($field));
         if ($newField === false) {
             continue;
         }
         $newField->setName($editWindow->getName() . '_' . $field);
         $fieldClass = $newField->getClass();
         if ($fieldClass == 'Component_Field_System_Objectslist' || $fieldClass == 'Component_Field_System_Objectlink') {
             $newField->controllerUrl = $controllerUrl;
         }
         if (in_array($fieldClass, $this->tabTypes, true)) {
             $project->addObject($editWindow->getName(), $newField);
         } else {
             $project->addObject($tab->getName(), $newField);
         }
     }
     /*
      * Save designer project
      */
     $designerStorage = Designer_Factory::getStorage($designerConfig);
     $project->actionjs = $actionFile;
     if (!$designerStorage->save($projectFile, $project)) {
         throw new Exception('Can`t create Designer project');
     }
     /*
      * Create ActionJS file
      */
     $this->_createActionJS($runNamespace, $classNamespace, $actionFile, $jsName);
     return true;
 }
Exemplo n.º 8
0
 /**
  * Get Filtesr feature
  * @return Ext_Grid_Filtersfeature
  */
 public function getFiltersFeature()
 {
     if (!$this->_filtersFeature) {
         $this->_filtersFeature = Ext_Factory::object('Grid_Filtersfeature', array('id' => 'filters', 'paramPrefix' => 'filterfeature'));
     }
     return $this->_filtersFeature;
 }
Exemplo n.º 9
0
    /**
     * (non-PHPdoc)
     * @see Backend_Designer_Generator_Component::addComponent()
     */
    public function addComponent(Designer_Project $project, $id, $parentId = false)
    {
        $windowName = $project->uniqueId($id);
        $dockedName = $project->uniqueId($windowName . '__docked');
        $toolbarName = $project->uniqueId($windowName . '_bottom_toolbar');
        $fillName = $project->uniqueId($windowName . '_footer_fill');
        $saveName = $project->uniqueId($windowName . '_footer_saveBtn');
        $cancelName = $project->uniqueId($windowName . '_footer_cancelBtn');
        $formName = $project->uniqueId($windowName . '_form');
        $editWindow = Ext_Factory::object('Window');
        $editWindow->setName($windowName);
        $editWindow->extendedComponent(true);
        $editWindow->width = 450;
        $editWindow->height = 500;
        $editWindow->modal = false;
        $editWindow->resizable = true;
        $editWindow->layout = 'fit';
        $form = Ext_Factory::object('Form');
        $form->setName($formName);
        $form->bodyCls = 'formBody';
        $form->bodyPadding = 5;
        $form->fieldDefaults = '{anchor:"100%",labelWidth:150}';
        $form->autoScroll = true;
        $dockObject = Ext_Factory::object('Docked');
        $dockObject->setName($dockedName);
        $toolbar = Ext_Factory::object('Toolbar');
        $toolbar->setName($toolbarName);
        $toolbar->dock = 'bottom';
        $toolbar->ui = 'footer';
        $fill = Ext_Factory::object('Toolbar_Fill');
        $fill->setName($fillName);
        $saveBtn = Ext_Factory::object('Button');
        $saveBtn->setName($saveName);
        $saveBtn->minWidth = 80;
        $saveBtn->text = '[js:]appLang.SAVE';
        $cancelBtn = Ext_Factory::object('Button');
        $cancelBtn->setName($cancelName);
        $cancelBtn->minWidth = 80;
        $cancelBtn->text = '[js:]appLang.CANCEL';
        if (!$project->addObject(false, $editWindow)) {
            return false;
        }
        if (!$project->addObject($windowName, $dockObject)) {
            return false;
        }
        if (!$project->addObject($dockedName, $toolbar)) {
            return false;
        }
        if (!$project->addObject($toolbarName, $fill)) {
            return false;
        }
        if (!$project->addObject($toolbarName, $saveBtn)) {
            return false;
        }
        if (!$project->addObject($toolbarName, $cancelBtn)) {
            return false;
        }
        if (!$project->addObject($windowName, $form)) {
            return false;
        }
        /*
         * Project events
         */
        $eventManager = $project->getEventManager();
        $eventManager->setEvent($cancelName, 'click', 'this.close();');
        $eventManager->setEvent($saveName, 'click', 'this.onSaveData();');
        $eventManager->setEvent($windowName, 'dataSaved', '', '', true);
        /*
         * Project methods
         */
        $methodsManager = $project->getMethodManager();
        $m = $methodsManager->addMethod($windowName, 'onSaveData', array(), '
      // remove alert, update submit url, set params
      Ext.Msg.alert(appLang.MESSAGE, "Save button click");

     /*
      // form submit template
      var me = this;
	  this.childObjects.' . $formName . '.getForm().submit({
			clientValidation: true,
			waitMsg:appLang.SAVING,
			method:"post",
			url:"[%wroot%][%admp%][%-%]my_controller[%-%]edit",
			params:{
           
          },
			success: function(form, action) {
   		 		if(!action.result.success){
   		 			Ext.Msg.alert(appLang.MESSAGE, action.result.msg);
   		 		} else{
   		 			me.fireEvent("dataSaved");
   		 			me.close();
   		 		}
   	        },
   	        failure: app.formFailure
   	  });
    */
            ');
        $m->setDescription('Save data');
        return true;
    }
Exemplo n.º 10
0
 /**
  * Convert fields from config property to the local variable
  */
 protected function _convertFields()
 {
     if (!empty($this->_fields)) {
         foreach ($this->_fields as $k => &$v) {
             if ($v instanceof Ext_Model_Field && isset($v->name)) {
                 $v = Ext_Factory::object('Data_Field', get_object_vars($v));
             }
         }
         unset($v);
     }
     if (empty($this->_config->fields)) {
         return;
     }
     if (is_string($this->_config->fields)) {
         $fields = json_decode($this->_config->fields, true);
     }
     if (!empty($fields)) {
         foreach ($fields as $field) {
             if (isset($field['name']) && !isset($this->_fields[$field['name']])) {
                 $this->addField($field);
             }
         }
     }
     $this->fields = '';
 }
Exemplo n.º 11
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();
 }
Exemplo n.º 12
0
    public function editorconfigAction()
    {
        $object = Request::post('object', 'string', false);
        if (!$object || !Db_Object_Config::configExists($object)) {
            Response::jsonError($this->_lang->WRONG_REQUEST);
        }
        $objectConfig = Db_Object_Config::getInstance($object);
        $data = array();
        $tabs = array();
        $tab = Ext_Factory::object('Panel');
        $tab->setName('_generalTab');
        $tab->frame = false;
        $tab->border = false;
        $tab->layout = 'anchor';
        $tab->bodyPadding = 3;
        $tab->autoScroll = true;
        $tab->bodyCls = 'formBody';
        $tab->anchor = '100%';
        $tab->title = $this->_lang->get('GENERAL');
        $tab->fieldDefaults = "{\n\t\t            labelAlign: 'right',\n\t\t            labelWidth: 160,\n\t\t            anchor: '100%'\n\t\t     }";
        $tabs[] = $tab;
        $related = array();
        $objectFieldList = array_keys($objectConfig->getFieldsConfig(false));
        $backendCfg = Registry::get('main', 'config');
        $readOnly = $objectConfig->isReadOnly();
        foreach ($objectFieldList as $field) {
            if (is_string($field) && $field == 'id') {
                continue;
            }
            $fieldCfg = $objectConfig->getFieldConfig($field);
            if ($objectConfig->isMultiLink($field)) {
                $linkedObject = $objectConfig->getLinkedObject($field);
                $linkedCfg = Db_Object_Config::getInstance($linkedObject);
                $related[] = array('field' => $field, 'object' => $linkedObject, 'title' => $fieldCfg['title'], 'titleField' => $linkedCfg->getLinkTitle());
            } elseif ($objectConfig->isObjectLink($field)) {
                if ($objectConfig->getLinkedObject($field) === 'medialib') {
                    $data[] = '{
									xtype:"medialibitemfield",
									resourceType:"all",
									name:"' . $field . '",
									readOnly:' . intval($readOnly) . ',
									fieldLabel:"' . $fieldCfg['title'] . '"
								}';
                } else {
                    $data[] = '
						{
							xtype:"objectfield",
							objectName:"' . $objectConfig->getLinkedObject($field) . '",
							controllerUrl:"' . Request::url(array($backendCfg['adminPath'], 'orm', 'dataview', ''), false) . '",
							fieldLabel:"' . $fieldCfg['title'] . '",
							name:"' . $field . '",
							anchor:"100%",
							readOnly:' . intval($readOnly) . ',
							isVc:' . intval($objectConfig->isRevControl()) . '
						}
					';
                }
            } else {
                $newField = Backend_Designer_Import::convertOrmFieldToExtField($field, $fieldCfg);
                if ($newField !== false) {
                    $newField->setName($field);
                    $fieldClass = $newField->getClass();
                    if ($readOnly && $newField->getConfig()->isValidProperty('readOnly')) {
                        $newField->readOnly = true;
                    }
                    if ($objectConfig->isText($field) && $objectConfig->isHtml($field)) {
                        $tabs[] = $newField->__toString();
                    } else {
                        $data[] = $newField->__toString();
                    }
                }
            }
        }
        $tab->items = '[' . implode(',', $data) . ']';
        Response::jsonSuccess(array('related' => $related, 'fields' => str_replace(array("\n", "\t"), '', '[' . implode(',', $tabs) . ']'), 'readOnly' => intval($readOnly), 'primaryKey' => $objectConfig->getPrimaryKey()));
    }
Exemplo n.º 13
0
 /**
  * Add object instance to the project
  */
 public function addinstanceAction()
 {
     $parent = Request::post('parent', 'alphanum', '');
     $name = Request::post('name', 'alphanum', false);
     $instance = Request::post('instance', 'alphanum', false);
     $errors = array();
     if (empty($name)) {
         $errors['name'] = $this->_lang->get('CANT_BE_EMPTY');
     }
     $project = $this->_getProject();
     if (!$project->objectExists($instance)) {
         $errors['instance'] = $this->_lang->get('INVALID_VALUE');
     }
     $instanceObject = $project->getObject($instance);
     if ($instanceObject->isInstance() || !Designer_Project::isVisibleComponent($instanceObject->getClass())) {
         $errors['instance'] = $this->_lang->get('INVALID_VALUE');
     }
     /*
      * Skip parent for window , store and model
      */
     $rootClasses = array('Window', 'Store', 'Data_Store', 'Data_Store_Tree', 'Model');
     $isWindowComponent = strpos($instanceObject->getClass(), 'Component_Window_') !== false;
     if (in_array($instanceObject->getClass(), $rootClasses, true) || $isWindowComponent) {
         $parent = 0;
     }
     /*
      * Check if parent object exists and can has childs
      */
     if (!$project->objectExists($parent) || !Designer_Project::isContainer($project->getObject($parent)->getClass())) {
         $parent = 0;
     }
     if ($project->objectExists($name)) {
         $errors['name'] = $this->_lang->get('SB_UNIQUE');
     }
     if (!empty($errors)) {
         Response::jsonError($this->_lang->get('FILL_FORM'), $errors);
     }
     $object = Ext_Factory::object('Object_Instance');
     $object->setObject($instanceObject);
     $object->setName($name);
     if (!$project->addObject($parent, $object)) {
         Response::jsonError($this->_lang->get('CANT_EXEC'));
     }
     $this->_storeProject();
     Response::jsonSuccess();
 }
Exemplo n.º 14
0
 /**
  * Convert orm field into ext object
  * 
  * @param string $name            
  * @param array $fieldConfig
  *            - field info from Db_Object_Config
  * @return Ext_Object or false
  */
 public static function convertOrmFieldToExtField($name, $fieldConfig, $controllerUrl = '')
 {
     $type = $fieldConfig['db_type'];
     $newField = false;
     /*
      * Adapter
      */
     if (isset($fieldConfig['type']) && $fieldConfig['type'] === 'link') {
         if ($fieldConfig['link_config']['link_type'] == 'dictionary') {
             $newField = Ext_Factory::object('Component_Field_System_Dictionary');
             if ($fieldConfig['required']) {
                 $newField->forceSelection = true;
             } else {
                 $newField->forceSelection = false;
             }
             $newField->dictionary = $fieldConfig['link_config']['object'];
         } elseif ($fieldConfig['link_config']['link_type'] == Db_Object_Config::LINK_OBJECT && $fieldConfig['link_config']['object'] == 'medialib') {
             $newField = Ext_Factory::object('Ext_Component_Field_System_Medialibitem');
         } elseif ($fieldConfig['link_config']['link_type'] == Db_Object_Config::LINK_OBJECT) {
             $newField = Ext_Factory::object('Ext_Component_Field_System_Objectlink');
             $newField->objectName = $fieldConfig['link_config']['object'];
         } elseif ($fieldConfig['link_config']['link_type'] == Db_Object_Config::LINK_OBJECT_LIST) {
             $newField = Ext_Factory::object('Ext_Component_Field_System_Objectslist');
             $newField->objectName = $fieldConfig['link_config']['object'];
         } else {
             $newField = Ext_Factory::object('Form_Field_Text');
         }
     } elseif ($type === 'boolean') {
         $newField = Ext_Factory::object('Form_Field_Checkbox');
         $newField->inputValue = 1;
         $newField->uncheckedValue = 0;
     } elseif (in_array($type, Db_Object_Builder::$intTypes, true)) {
         $newField = Ext_Factory::object('Form_Field_Number');
         $newField->allowDecimals = false;
     } elseif (in_array($type, Db_Object_Builder::$floatTypes, true)) {
         $newField = Ext_Factory::object('Form_Field_Number');
         $newField->allowDecimals = true;
         $newField->decimalSeparator = ',';
         if (isset($fieldConfig['db_precision'])) {
             $newField->decimalPrecision = $fieldConfig['db_precision'];
         } else {
             $newField->decimalPrecision = 2;
         }
     } elseif (in_array($type, Db_Object_Builder::$charTypes, true)) {
         $newField = Ext_Factory::object('Form_Field_Text');
     } elseif (in_array($type, Db_Object_Builder::$textTypes, true)) {
         if (isset($fieldConfig['allow_html']) && $fieldConfig['allow_html']) {
             $newField = Ext_Factory::object('Component_Field_System_Medialibhtml');
             $newField->editorName = $name;
             $newField->title = $fieldConfig['title'];
             $newField->frame = false;
         } else {
             $newField = Ext_Factory::object('Form_Field_Textarea');
         }
     } elseif (in_array($type, Db_Object_Builder::$dateTypes, true)) {
         switch ($type) {
             case 'date':
                 $newField = Ext_Factory::object('Form_Field_Date');
                 $newField->format = 'Y-m-d';
                 $newField->submitFormat = 'Y-m-d';
                 $newField->altFormats = 'Y-m-d';
                 break;
             case 'datetime':
             case 'timestamp':
                 $newField = Ext_Factory::object('Form_Field_Date');
                 $newField->format = 'Y-m-d H:i:s';
                 $newField->submitFormat = 'Y-m-d H:i:s';
                 $newField->altFormats = 'Y-m-d H:i:s';
                 break;
             case 'time':
                 $newField = Ext_Factory::object('Form_Field_Time');
                 $newField->format = 'H:i:s';
                 $newField->submitFormat = 'H:i:s';
                 $newField->altFormats = 'H:i:s';
                 break;
         }
     } else {
         $newField = Ext_Factory::object('Form_Field_Text');
     }
     $newFieldConfig = $newField->getConfig();
     if ($newFieldConfig->isValidProperty('name')) {
         $newField->name = $name;
     }
     if (isset($fieldConfig['db_default']) && $fieldConfig['db_default'] !== false && $newFieldConfig->isValidProperty('value')) {
         $newField->value = $fieldConfig['db_default'];
     }
     if (in_array($type, Db_Object_Builder::$numTypes, true) && isset($fieldConfig['db_unsigned']) && $fieldConfig['db_unsigned'] && $newFieldConfig->isValidProperty('minValue')) {
         $newField->minValue = 0;
     }
     if ($newField->getClass() != 'Component_Field_System_Medialibhtml' && $newFieldConfig->isValidProperty('fieldLabel')) {
         $newField->fieldLabel = $fieldConfig['title'];
     }
     if ($newField->getClass() === 'Component_Field_System_Objectslist') {
         $newField->title = $fieldConfig['title'];
     }
     if (isset($fieldConfig['required']) && $fieldConfig['required'] && $newFieldConfig->isValidProperty('allowBlank')) {
         $newField->allowBlank = false;
     }
     return $newField;
 }
Exemplo n.º 15
0
 /**
  * Change grid column type
  */
 public function changecoltypeAction()
 {
     $type = Request::post('type', 'string', '');
     $columnId = Request::post('columnId', 'string', false);
     if (!$columnId) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     if (strlen($type)) {
         $name = 'Grid_Column_' . ucfirst($type);
     } else {
         $name = 'Grid_Column';
     }
     $col = Ext_Factory::object($name);
     Ext_Factory::copyProperties($this->_object->getColumn($columnId), $col);
     if (!$this->_object->updateColumn($columnId, $col)) {
         Response::jsonError($this->_lang->WRONG_REQUEST);
     }
     $this->_storeProject();
     Response::jsonSuccess();
 }
Exemplo n.º 16
0
 protected function _initDefaultProperties()
 {
     $this->_viewObject = Ext_Factory::object('Form_Field_Text');
 }
Exemplo n.º 17
0
 /**
  * Change  subproprty object type
  */
 public function changetypeAction()
 {
     $sub = Request::post('sub', 'string', '');
     $type = Request::post('type', 'string', '');
     if (!in_array($sub, array('proxy', 'reader', 'writer')) || !strlen($type)) {
         Response::jsonError($this->_lang->INVALID_REQUEST);
     }
     $config = array();
     if ($sub == 'proxy') {
         $obj = $this->_object->proxy;
     } else {
         $obj = $this->_object->proxy->{$sub};
     }
     if (!empty($obj)) {
         $config = $obj->getConfig()->__toArray();
     }
     if ($sub == 'proxy') {
         $this->_object->proxy = Ext_Factory::object('Data_' . ucfirst($sub) . '_' . ucfirst($type), $config);
         $this->_object->proxy->type = strtolower($type);
         if ($this->_object->proxy->getClass() === 'Data_Proxy_Ajax') {
             $this->_object->proxy->startParam = 'pager[start]';
             $this->_object->proxy->limitParam = 'pager[limit]';
             $this->_object->proxy->sortParam = 'pager[sort]';
             $this->_object->proxy->directionParam = 'pager[dir]';
             $this->_object->proxy->simpleSortMode = true;
         }
     } else {
         $this->_object->proxy->{$sub} = Ext_Factory::object('Data_' . ucfirst($sub) . '_' . ucfirst($type), $config);
         $this->_object->proxy->{$sub}->type = strtolower($type);
         if ($this->_object->proxy->getClass() === 'Data_Reader_Json') {
             $this->_object->proxy->{$sub}->root = 'data';
             $this->_object->proxy->{$sub}->totalProperty = 'count';
             $this->_object->proxy->{$sub}->idProperty = 'id';
         }
     }
     $this->_storeProject();
     Response::jsonSuccess();
 }