示例#1
0
文件: delete.php 项目: NickMitin/P-W
 public function execute()
 {
     if ($this->application->user->type < 100) {
         echo 'Недостаточно прав доступа';
         exit;
     }
     if ($this->dataObjectMapId != 0) {
         $dataObjectMap = new bmDataObjectMap($this->application, array('identifier' => $this->dataObjectMapId));
         $dataObjectMap->delete();
     }
     unset($dataObjectMap);
     parent::execute();
 }
示例#2
0
 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();
     }
 }
示例#3
0
文件: save.php 项目: NickMitin/P-W
 public function execute()
 {
     foreach ($this->dataObjectNames as $dataObjectMapId => $dataObjectName) {
         if ($dataObjectMapId != 0 || $dataObjectName != '') {
             $dataObjectName = trim($dataObjectName);
             $pattern = '/^[a-zA-Z][a-zA-Z0-9]+$/';
             if (preg_match($pattern, $dataObjectName)) {
                 $dataObjectMap = new bmDataObjectMap($this->application, array('identifier' => $dataObjectMapId));
                 $dataObjectMap->beginUpdate();
                 if ($dataObjectMap->type != 1) {
                     $dataObjectMap->name = $dataObjectName;
                 }
                 $dataObjectMap->endUpdate();
                 $dataObjectMap->save();
                 // $dataObjectMap->generateFiles(C_ADMIN_ANCESTOR_PAGE);
                 unset($dataObjectMap);
             } else {
                 echo 'Ошибка: имя объекта может состоять из строчных и прописных латинских букв и цифр и должно начинаться с буквы';
             }
         }
     }
     parent::execute();
 }
示例#4
0
 public function deleteDataObjectMap($name)
 {
     if (!$this->application->dataLink->tableExists($name)) {
         if ($this->isLogMode) {
             echo 'DB table "' . $name . '" does not exist.' . "\n";
         }
     }
     $dataObjectMapId = $this->application->getObjectIdByFieldName('dataObjectMap', 'name', $name);
     if ($dataObjectMapId) {
         $dataObjectMap = new bmDataObjectMap($this->application, array('identifier' => $dataObjectMapId));
         $dataObjectMap->delete();
         if ($this->isLogMode !== true) {
             $this->log('$application->api->deleteDataObjectMap(\'' . $name . '\');');
         }
     } else {
         if ($this->isLogMode) {
             echo 'DataObject "' . $name . '" does not exist.' . "\n";
         }
     }
 }
示例#5
0
文件: save.php 项目: NickMitin/P-W
 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();
 }