/** * @param string $objectName * @throws Exception * @return Ext_Object */ protected function _getObject($objectName) { if (!$this->_project->objectExists($objectName)) { throw new Exception('Designer_Debugger::_getObject nonexistent object ' . $objectName); } return $this->_project->getObject($objectName); }
/** * 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); } } }
/** * Import fields into the form object */ public function importfieldsAction() { $importObject = Request::post('importobject', 'string', false); $importFields = Request::post('importfields', 'array', array()); if (!$importObject || empty($importFields) || $this->_project->objectExists($importObject)) { Response::jsonError($this->_lang->WRONG_REQUEST); } $importObjectConfig = Db_Object_Config::getInstance($importObject); foreach ($importFields as $name) { if ($importObjectConfig->fieldExists($name)) { $this->_importOrmField($name, $importObjectConfig); } } $this->_storeProject(); Response::jsonSuccess(); }
public function allfieldsAction() { $this->_checkLoaded(); $name = Request::post('object', 'string', ''); $project = $this->_getProject(); if (!strlen($name) || !$project->objectExists($name)) { Response::jsonError('Undefined Store object'); } $this->_project = $project; $this->_object = $project->getObject($name); $fields = array(); if ($this->_object->isValidProperty('model') && strlen($this->_object->model) && $this->_project->objectExists($this->_object->model)) { $model = $this->_project->getObject($this->_object->model); if ($model->isValidProperty('fields')) { $fields = $model->fields; if (is_string($fields)) { $fields = json_decode($model->fields, true); } } } if (empty($fields) && $this->_object->isValidProperty('fields')) { $fields = $this->_object->fields; if (empty($fields)) { $fields = array(); } if (is_string($fields)) { $fields = json_decode($fields, true); } } $data = array(); if (!empty($fields)) { foreach ($fields as $item) { if (is_object($item)) { $data[] = array('name' => $item->name, 'type' => $item->type); } else { $data[] = array('name' => $item['name'], 'type' => $item['type']); } } } Response::jsonSuccess($data); }
/** * Get object javascript source code * @param string $name * @return string */ public function getObjectCode($name) { if (!$this->_project->objectExists($name)) { return ''; } $this->applyStoreInstances(); $object = $this->_project->getObject($name); $oClass = $object->getClass(); if (in_array($oClass, Designer_Project::$defines, true) || $object->isExtendedComponent()) { $code = $this->_compileExtendedItem($name, 0); } else { $code = $this->_compileItem($name); } return $code['defines'] . "\n" . $code['layout']; }