Changeset 737 for trunk/Common/Form/Form.php
- Timestamp:
- Apr 14, 2015, 10:16:16 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Form/Form.php
r719 r737 49 49 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) 50 50 { 51 if(!array_key_exists($Index, $this->Values) and isset($Item['Default'])) 51 if(!array_key_exists($Index, $this->Values) and isset($Item['Default'])) 52 52 $this->Values[$Index] = $Item['Default']; 53 53 } … … 85 85 ); 86 86 foreach($this->Definition['Items'] as $Index => $Item) 87 if(!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false)) 87 if(!array_key_exists('Hidden', $Item) or ($Item['Hidden'] == false)) 88 88 if(!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 89 89 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and … … 302 302 $Parameters); 303 303 } 304 } else 304 } else 305 305 { 306 306 if(isset($Item['Default'])) { … … 418 418 unset($this->FormTypes[$Name]); 419 419 } 420 421 function UpdateSQLMeta() 422 { 423 $this->Database->query('DELETE FROM ModelField'); 424 $this->Database->query('DELETE FROM Model'); 425 $this->Database->query('DELETE FROM DataType WHERE Parent IS NOT NULL'); 426 $this->Database->query('DELETE FROM DataType'); 427 428 foreach($this->Type->TypeDefinitionList as $Name => $Type) 429 { 430 $DbResult = $this->Database->select('DataType', 'Id', 'Name="'.$Name.'"'); 431 if($DbResult->num_rows == 0) 432 { 433 $this->Database->insert('DataType', array('Name' => $Name, 434 'Title' => $Type['Class'])); 435 } else 436 { 437 $DbRow = $DbResult->fetch_assoc(); 438 $this->Database->update('DataType', 'Id='.$DbRow['Id'], array('Name' => $Name, 439 'Title' => $Type['Class'])); 440 } 441 } 442 443 foreach($this->Classes as $Class) 444 if(!array_key_exists('SQL', $Class) and ($Class['Table'] != '')) 445 { 446 $DbResult = $this->Database->query('SELECT * FROM information_schema.tables WHERE table_schema = "centrala_big" 447 AND table_name = "'.$Class['Table'].'" LIMIT 1'); 448 if($DbResult->num_rows == 0) continue; 449 450 echo($Class['Table'].'<br>'); 451 $Module = 1; 452 $DbResult = $this->Database->select('Model', 'Id', 'Name="'.$Class['Table'].'"'); 453 if($DbResult->num_rows == 0) 454 { 455 $this->Database->insert('Model', array('Name' => $Class['Table'], 'Title' => $Class['Title'], 'Module' => $Module)); 456 $Model = $this->Database->insert_id; 457 } else 458 { 459 $DbRow = $DbResult->fetch_assoc(); 460 $Model = $DbRow['Id']; 461 $this->Database->update('Model', 'Id='.$DbRow['Id'], array('Name' => $Class['Table'], 462 'Title' => $Class['Title'], 'Module' => $Module)); 463 } 464 465 foreach($Class['Items'] as $Name => $Field) 466 { 467 echo($Name.', '); 468 $DbResult = $this->Database->select('DataType', 'Id', 'Name="'.$Field['Type'].'"'); 469 if($DbResult->num_rows > 0) 470 { 471 $DbRow = $DbResult->fetch_assoc(); 472 $Type = $DbRow['Id']; 473 } else { 474 $Type = $this->FormTypes[$Field['Type']]; 475 476 // Search parent type 477 $DbResult = $this->Database->select('DataType', 'Id', 'Name="'.$Type['Type'].'"'); 478 if($DbResult->num_rows > 0) 479 { 480 $DbRow = $DbResult->fetch_assoc(); 481 $ParentType = $DbRow['Id']; 482 } else $ParentType = null; 483 484 $this->Database->insert('DataType', array('Name' => $Field['Type'], 485 'Title' => '', 'Parent' => $ParentType)); 486 $Type = $this->Database->insert_id; 487 } 488 489 $DbResult = $this->Database->select('ModelField', 'Id', '(Name="'.$Name.'") AND (Model='.$Model.')'); 490 if($DbResult->num_rows == 0) 491 { 492 $this->Database->insert('ModelField', array('Name' => $Name, 493 'Title' => $Field['Caption'], 'Model' => $Model, 'Type' => $Type)); 494 } else 495 { 496 $DbRow = $DbResult->fetch_assoc(); 497 $this->Database->update('ModelField', 'Id='.$DbRow['Id'], array('Name' => $Name, 498 'Title' => $Field['Caption'], 'Model' => $Model, 'Type' => $Type)); 499 } 500 } 501 echo('<br>'); 502 } 503 } 420 504 }
Note:
See TracChangeset
for help on using the changeset viewer.