Example #1
0
 public function proc_upd()
 {
     if (system::issetUrl(2)) {
         $obj = new ormField();
         $obj->setGroupId(system::url(2));
     } else {
         if (system::action() == "proc_upd") {
             $obj = new ormField($_POST['obj_id']);
         } else {
             if (system::action() == "proc_add") {
                 $obj = new ormField();
                 $obj->setGroupId($_POST['obj_id']);
             }
         }
     }
     if (!empty($_POST['fname'])) {
         $obj->setName($_POST['fname']);
     }
     if (!empty($_POST['max_size'])) {
         $obj->setMaxSize($_POST['max_size']);
     } else {
         $obj->setMaxSize(0);
     }
     $obj->setType(0);
     $obj->setInherit(1);
     $obj_id = $obj->save();
     if ($obj_id === false) {
         echo json_encode(array('error' => 1, 'data' => $obj->getErrorListText(' ')));
     } else {
         $tree = new ormFieldsTree();
         $forUpd = system::action() == "proc_add" ? 0 : 1;
         echo json_encode(array('error' => 0, 'data' => $tree->getFieldHTML($obj, $forUpd)));
     }
     system::stop();
 }
Example #2
0
 public function proc_upd()
 {
     if (system::action() == "proc_upd") {
         $obj = new ormFieldsGroup($_POST['obj_id']);
     } else {
         if (system::action() == "proc_add") {
             $obj = new ormFieldsGroup();
             $obj->setClassId($_POST['obj_id']);
         }
     }
     $obj->setName(system::POST('group_name'));
     $obj->setSName(system::POST('group_sname'));
     $obj->setView(system::POST('group_view'));
     $obj->setSystem(system::POST('group_system'));
     $obj_id = $obj->save();
     if ($obj_id === false) {
         echo json_encode(array('error' => 1, 'data' => $obj->getErrorListText(' ')));
     } else {
         $tree = new ormFieldsTree();
         $forUpd = system::action() == "proc_add" ? 0 : 1;
         echo json_encode(array('error' => 0, 'data' => $tree->getGroupHTML($obj, $forUpd)));
     }
     system::stop();
 }
Example #3
0
 public function proc_upd()
 {
     if (system::action() == "proc_upd") {
         $obj = new ormField($_POST['obj_id']);
     } else {
         if (system::action() == "proc_add") {
             $obj = new ormField();
             $obj->setGroupId($_POST['obj_id']);
         }
     }
     $obj->setName(system::POST('fname'));
     $obj->setSName(system::POST('fsname'));
     $obj->setHint(system::POST('hint'));
     $obj->setType(system::POST('type'));
     $obj->setView(system::POST('view'));
     $obj->setSearch(system::POST('search'));
     $obj->setInherit(system::POST('inherit'));
     $obj->setFilter(system::POST('filter'));
     $obj->setRequired(system::POST('required'));
     $obj->setSystem(system::POST('system'));
     $obj->setUniqum(system::POST('uniqum'));
     $obj->setMaxSize(system::POST('max_size'));
     $obj->setQuickAdd(system::POST('quick_add'));
     $obj->setRelType(system::POST('reltype'));
     $obj->setSpec(system::POST('spec'));
     // Работа с привязанным справочником
     if (system::POST('type') == 95 || system::POST('type') == 90 || system::POST('type') == 97) {
         $list_id = system::POST('list_id');
         // Если не был указан справочник, то автоматически создаем новый
         if (empty($list_id)) {
             $class_name = 'list_' . system::POST('fsname', isVarName);
             if ($class = ormClasses::get($class_name)) {
                 $list_id = $class->id();
             } else {
                 $class = new ormClass();
                 $class->setParentId(29);
                 $class->setName('Для поля "' . system::POST('fname', isString) . '"');
                 $class->setSName($class_name);
                 $class->setSystem(0);
                 $class->setIsList(1);
                 $list_id = $class->save();
                 if ($list_id === false) {
                     $list_id = 0;
                 }
             }
         }
         $obj->setListId($list_id);
     } else {
         $obj->setListId(0);
     }
     $obj_id = $obj->save();
     if ($obj_id === false) {
         echo json_encode(array('error' => 1, 'data' => $obj->getErrorListText(' ')));
     } else {
         $tree = new ormFieldsTree();
         $forUpd = system::action() == "proc_add" ? 0 : 1;
         echo json_encode(array('error' => 0, 'data' => $tree->getFieldHTML($obj, $forUpd)));
     }
     system::stop();
 }
Example #4
0
 public function upd()
 {
     $is_page = false;
     if (file_exists(MODUL_DIR . '/constructor/template/class.tpl')) {
         include MODUL_DIR . '/constructor/template/class.tpl';
     }
     if (system::action() == "upd") {
         // форма обновления информации
         $class = new ormClass(system::url(2));
         if ($class->id() == '') {
             system::redirect('/constructor/tree');
         }
         page::assign('obj.class_name', $class->getName());
         page::assign('obj.sname', $class->getSName());
         page::assign('obj.text', $class->getPadej());
         page::assign('obj.id', $class->id());
         $system = $class->isSystem();
         $is_list = $class->isList();
         $is_page = $class->isPage();
         $is_user = $class->isInheritor('user');
         $base_class = $class->getBaseClass();
         page::assign('right', 'class_proc_upd');
         // Выводим дерево для отображения структуры класса
         $tree = new ormFieldsTree();
         page::assign('fields', $tree->getHTML($class));
     } else {
         if (system::action() == "add") {
             // форма добавления информации
             $system = $is_list = $uniqum = $base_class = 0;
             // Проверяем существует ли родитель?
             if (system::issetUrl(2)) {
                 $parent = new ormClass(system::url(2));
                 if ($parent->id() == '') {
                     system::redirect('/constructor/tree');
                 }
                 $is_list = $parent->isList();
                 $is_page = $parent->isPage();
                 $is_user = $parent->isInheritor('user');
             } else {
                 $is_user = false;
             }
             page::assign('obj.id', system::url(2));
             page::assign('right', 'class_proc_add');
         }
     }
     if ($is_page) {
         ui::SelectBox('class_list', ormClasses::getPagesClassList(), $base_class, 400, ' ');
         ui::SelectBox('template_list1', templates::getByDestination(0, true), isset($class) ? $class->getDefTemplate(0) : 0, 400, ' ');
         ui::SelectBox('template_list2', templates::getByDestination(1, true), isset($class) ? $class->getDefTemplate(1) : 0, 400, ' ');
         page::fParse('page_fields', $TEMPLATE['page_fields']);
     } else {
         if ($is_user) {
             page::fParse('page_fields', $TEMPLATE['user_fields']);
         } else {
             page::assign('page_fields', '');
         }
     }
     if (system::action() == "add" || !$class->isSystem()) {
         ui::newButton(lang::get('BTN_SAVE'), "javascript:sendForm('save');");
         ui::newButton(lang::get('BTN_APPLY'), "javascript:sendForm('apply');");
         ui::setCancelButton('/constructor');
     } else {
         ui::setBackButton('/constructor');
     }
     page::assignArray(lang::get('CONSTR_FORM_FIELD'));
     page::assignSavingPost();
     ui::CheckBox('system', 1, $system, lang::get('CONSTR_FORM_FIELD', 3));
     ui::CheckBox('is_list', 1, $is_list, lang::get('CONSTR_FORM_FIELD', 4));
     return page::parse($TEMPLATE['frame'], 1);
 }