public function execute() { $sql = "SHOW TABLES"; $qTables = $this->application->dataLink->select($sql); while ($table = $qTables->nextRow()) { $dataObjectName = $table[0]; if (!$this->testException($dataObjectName)) { $identifier = $this->getObjectIdByField('dataObjectMap', 'name', $dataObjectName); $dataObjectMap = new bmDataObjectMap($this->application, array('identifier' => $identifier)); if ($identifier == 0) { $dataObjectMap->name = $dataObjectName; $dataObjectMap->generateFields(); } $dataObjectMap->generateFiles(C_ADMIN_ANCESTOR_PAGE); unset($dataObjectField); } parent::execute(); } }
public function execute() { $dataLink = $this->application->dataLink; if ($this->dataObjectId != 0) { $dataObjectMap = new bmDataObjectMap($this->application, array('identifier' => $this->dataObjectId)); foreach ($this->dataFields as &$item) { if ($item->action != 'delete') { $inflectionNames = array('nominative', 'genitive', 'dative', 'accusive', 'creative', 'prepositional'); if ($item->localName != '') { $inflections = file_get_contents('http://export.yandex.ru/inflect.xml?name=' . urlencode($item->localName)); $xml = simplexml_load_string($inflections); $inflections = array(); if (count($xml->inflection) == 6) { $i = 0; foreach ($xml->inflection as $inflection) { $inflections[$inflectionNames[$i]] = (string) $inflection; $i++; } } else { foreach ($inflectionNames as $i => $inflection) { $inflections[$inflectionNames[$i]] = (string) $xml->inflection; } } } else { $inflections = array(); foreach ($inflectionNames as $i => $inflection) { $inflections[$inflectionNames[$i]] = $item->propertyName; } } $item->localName = serialize($inflections); if ($item->dataType == BM_VT_DATETIME) { if (!preg_match('/^\\d{4}-\\d{2}-\\d{2}\\s+\\d{2}:\\d{2}:\\d{2}$/', $item->defaultValue)) { $item->defaultValue = '0000-01-01 00:00:00'; } } $dataField = new bmDataObjectField($this->application, array('identifier' => $item->identifier)); $dataField->propertyName = $item->propertyName; $dataField->fieldName = $item->fieldName; $dataField->dataType = $item->dataType; $dataField->defaultValue = $item->defaultValue; $dataField->localName = $item->localName; $dataField->store(); $item->identifier = $dataField->identifier; } $dataObjectMap->beginUpdate(); switch ($item->action) { case 'add': $dataObjectMap->addField($item->identifier, $item->dataType); break; case 'delete': $dataObjectMap->removeField($item->identifier); break; case 'change': $dataObjectMap->renameField($item->identifier, $item->oldFieldName); break; } $dataObjectMap->endUpdate(); } } $dataObjectMap->save(); $dataObjectMap->generateFiles(); unset($dataObjectMap); parent::execute(); }