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']; }
/** * Check if object is extended component * @param string $objectName * @return boolean */ public function isExtendedObject($objectName) { return $this->_project->getObject($objectName)->isExtendedComponent(); }