function loadFormXmlAction()
 {
     $nameSpace = new Sys_Model_Namespace();
     $nameSpaces = $nameSpace->fetchAll();
     foreach ($nameSpaces as $nameSpacObj) {
         $nameSpac = strtolower($nameSpacObj->namespace);
         $config = App_Model_Config::loadXml($nameSpac);
         foreach ($config->classes as $name => $modelconfig) {
             $entity = new Sys_Model_Entity();
             $entity = $entity->fetchRow("model_name='{$name}'");
             $id = $entity->id;
             foreach ($modelconfig->prop as $prop) {
                 $ln = new Sys_Model_Entity_Property();
                 $ln->modelId = $id;
                 $ln->name = $prop->name;
                 $ln->column = $prop->column;
                 $ln->label = $prop->label;
                 $ln->sqltype = $prop->sqltype;
                 $ln->varType = $prop->varType;
                 $ln->input = $prop->input;
                 $ln->isRequired = $prop->required == 'true' ? 1 : 0;
                 $ln->isPk = $prop->pk == 'true' ? 1 : 0;
                 $ln->isAutoincrement = $prop->autoincrement == 'true' ? 1 : 0;
                 $ln->style = $prop->style;
                 $ln->isReadonly = $prop->readonly == 'true' ? 1 : 0;
                 $ln->isEnabled = $prop->enabled == 'true' ? 1 : 0;
                 $ln->cssClass = $prop->class;
                 $ln->save();
             }
         }
     }
     $this->_helper->redirector('index');
     $this->render('blank', null, true);
 }
 public function createXml($modelId = '34')
 {
     //$this->_helper->layout ()->disableLayout ();
     //$table= $this->_request->getParam("table");
     //$conn = App_Env::getDb();
     //$conn = new Zend_Db_Adapter_Sqlsrv($config);;
     $ep = new Sys_Model_Entity_Property();
     $result = $ep->fetchAll("model_id = '{$modelId}' ");
     $doc = new DOMDocument();
     $rootNode = $doc->createElement("App_Code_GenModel");
     $nodeconfig = $doc->createElement("config");
     $nodeui = $doc->createElement("ui");
     $nodedefault = $doc->createElement("default");
     $nodegrid = $doc->createElement("grid");
     $nodeform = $doc->createElement("form");
     $nodegroups = $doc->createElement("groups");
     $nodegroup = $doc->createElement("group");
     $nodegroups->appendChild($nodegroup);
     $nodeform->appendChild($nodegroups);
     $nodedefault->appendChild($nodegrid);
     $nodedefault->appendChild($nodeform);
     $nodeui->appendChild($nodedefault);
     $nodeconfig->appendChild($nodeui);
     //<prop name='groupid' column='groupid' input='select' />
     foreach ($result as $prop) {
         //print_r($coll);
         $collName = $prop->column;
         $propName = $prop->name;
         $type = $prop->sqltype;
         $input = $prop->input;
         //	print_r($coll);
         $propNode = $doc->createElement("prop");
         $formNode = $doc->createElement("field");
         $gridNode = $doc->createElement("field");
         $propNode->setAttribute('name', $propName);
         $propNode->setAttribute('column', $collName);
         $propNode->setAttribute('label', $propName);
         $propNode->setAttribute('sqltype', $type);
         $propNode->setAttribute('type', $type);
         $propNode->setAttribute('input', $input);
         $propNode->setAttribute('required', (int) $prop->isRequired == 1 ? 'true' : 'false');
         $propNode->setAttribute('pk', (int) $prop->isRequired == 1 ? 'true' : 'false');
         // $propNode->setAttribute('form',( (int)$prop->form == 1 )? 'true': 'false' );
         $propNode->setAttribute('autoIncrement', (int) $prop->isAutoincrement == 1 ? 'true' : 'false');
         $propNode->setAttribute('style', $prop->style);
         $propNode->setAttribute('readonly', (int) $prop->isReadonly == 1 ? 'true' : 'false');
         $propNode->setAttribute('enabled', (int) $prop->isEnabled == 1 ? 'true' : 'false');
         $propNode->setAttribute('class', $prop->cssClass);
         $formNode->setAttribute('id', $propName);
         $nodegroup->appendChild($formNode);
         $gridNode->setAttribute('id', $propName);
         $nodegrid->appendChild($gridNode);
         $rootNode->appendChild($propNode);
     }
     $rootNode->appendChild($nodeconfig);
     $doc->appendChild($rootNode);
     return $doc;
 }
Example #3
0
 /**
  * get Singleton  Sys_Model_Entity_Property
  *
  * @return Sys_Model_Entity_Property
  */
 public static function getObjectByID($id)
 {
     $obj = new Sys_Model_Entity_Property();
     $obj->find($id);
     return $obj;
 }