public function execute() { if ($this->application->user->type < 100) { echo 'Недостаточно прав доступа'; exit; } if ($this->referenceMapId != 0) { $referenceMap = new bmReferenceMap($this->application, array('identifier' => $this->referenceMapId)); $referenceMap->delete(); } unset($referenceMap); parent::execute(); }
public function execute() { foreach ($this->referenceNames as $referenceMapId => $referenceName) { if ($referenceMapId != 0 || $referenceName != '') { $referenceName = trim($referenceName); $pattern = '/^[a-zA-Z][a-zA-Z0-9_]+$/'; if (preg_match($pattern, $referenceName)) { $referenceMap = new bmReferenceMap($this->application, array('identifier' => $referenceMapId)); $referenceMap->beginUpdate(); if ($referenceMap->type != 1) { $referenceMap->name = $referenceName; } $referenceMap->endUpdate(); $referenceMap->save(); // $referenceMap->generateFiles(C_ADMIN_ANCESTOR_PAGE); unset($referenceMap); } else { echo 'Ошибка: имя связи может состоять из строчных и прописных латинских букв и цифр и должно начинаться с буквы'; } } } parent::execute(); }
public function execute() { $dataLink = $this->application->dataLink; if ($this->referenceId != 0) { $referenceMap = new bmReferenceMap($this->application, array('identifier' => $this->referenceId)); foreach ($this->dataFields as &$item) { if (!in_array('delete', $item->actions)) { $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'; } } $referenceField = new bmReferenceField($this->application, array('identifier' => $item->identifier)); $referenceField->propertyName = $item->propertyName; $referenceField->fieldName = $item->fieldName; $referenceField->dataType = $item->dataType; $referenceField->defaultValue = $item->defaultValue; $referenceField->localName = $item->localName; if ($item->referencedObjectId != 0) { $referenceField->setReferencedObject($item->referencedObjectId); } $referenceField->store(); $item->identifier = $referenceField->identifier; } $referenceMap->beginUpdate(); foreach ($item->actions as $action) { switch ($action) { case 'add': $referenceMap->addField($item->identifier, $item->referencedObjectType); break; case 'delete': $referenceMap->removeField($item->identifier); break; case 'change': $referenceMap->renameField($item->identifier, $item->oldFieldName); break; case 'changeType': $referenceMap->changeFieldType($item->identifier, $item->referencedObjectType); break; } } $referenceMap->endUpdate(); } } $referenceMap->save(); // $referenceMap->generateFiles(C_ADMIN_ANCESTOR_PAGE); // unset($referenceMap); parent::execute(); }