public function upd() { if (file_exists(MODUL_DIR . '/constructor/template/separator.tpl')) { include MODUL_DIR . '/constructor/template/separator.tpl'; } if (system::action() == "upd") { // форма обновления информации $obj = new ormField(system::url(2)); if ($obj->id() == '') { system::stop(); } page::assign('obj.fname', $obj->getName()); $max_size = $obj->getMaxSize() != '' ? $obj->getMaxSize() : 0; page::assign('obj.max_size', $max_size); page::assign('obj.id', $obj->id()); page::assign('right', 'separator_proc_upd'); } else { if (system::action() == "add") { // форма добавления информации if (system::issetUrl(2)) { // Проверяем существует ли родитель? $group = new ormFieldsGroup(system::url(2)); if ($group->id() == '') { system::stop(); } } page::assign('obj.id', system::url(2)); page::assign('right', 'separator_proc_add'); page::assign('obj.max_size', 0); } } page::assignArray(lang::get('CONSTR_FORM_FIELD3')); page::assignSavingPost(); echo page::parse($TEMPLATE['frame'], 1); system::stop(); }
private function createClass() { $sql = 'SELECT count(c_id) FROM <<classes>> WHERE c_sname = "' . $this->sname . '";'; if (db::q($sql, value) == 0) { $nul = $this->base_class == NULL ? '' : 'c_base_class = "' . $this->base_class . '",'; $nul .= $this->parent_id == NULL ? '' : 'c_parent_id = "' . $this->parent_id . '",'; $parent = $this->getParent(); $this->is_page = $parent instanceof ormClass ? $parent->isPage() : 0; $sql = 'INSERT INTO <<classes>> SET c_name = "' . $this->name . '", c_sname = "' . $this->sname . '", ' . $nul . ' c_text = "' . $this->padej . '", c_system = "' . $this->system . '", c_is_list = "' . $this->is_list . '", c_is_page = "' . $this->is_page . '";'; $this->id = db::q($sql); if ($this->id !== false) { $sql = 'CREATE TABLE <<__' . $this->sname . '>> ( `obj_id` INT( 11 ) NOT NULL ) ENGINE=InnoDB;'; if (db::q($sql) !== false) { db::q('ALTER TABLE <<__' . $this->sname . '>> ADD CONSTRAINT <<__' . $this->sname . '_fk_obj_id>> FOREIGN KEY (`obj_id`) REFERENCES <<objects>> (`o_id`) ON DELETE CASCADE ON UPDATE CASCADE'); // Регистрация класса в коллекции ormClasses::registration($this); // Наследует все поля родительского класса if ($parent instanceof ormClass) { $groups = $parent->getAllGroups(); if (!empty($groups)) { while (list($key, $gval) = each($groups)) { $parentGroup = new ormFieldsGroup($gval['fg_id']); $group = clone $parentGroup; $group->setClassId($this->id); $gid = $group->save(); if ($gid !== false) { $fields = $parentGroup->getAllFields(1); while (list($key, $fval) = each($fields)) { $field = clone new ormField($fval['f_id']); $field->setGroupId($gid); $field->save(); } } } } } else { // Класс сам по себе, создаем группу и поле по умолчанию $group = new ormFieldsGroup(); $group->setName('Основное'); $group->setSName('base'); $group->setView(1); $group->setSystem(1); $group->setClassId($this->id); $gid = $group->save(); if ($gid !== false) { $field = new ormField(); $field->setName('Название'); $field->setSName('name'); $field->setType(10); $field->setView(1); $field->setSearch(0); $field->setInherit(1); $field->setFilter(0); $field->setRequired(1); $field->setSystem(0); $field->setUniqum(0); $field->setGroupId($gid); $field->save(); } } return $this->id; } else { $this->newError(27, 'Невозможно создать таблицу данных класса!'); return false; } } else { $this->newError(12, 'Ошибка в SQL запросе!'); return false; } } else { $this->newError(26, 'Класс с указанным системным именем уже существует в системе!'); return false; } }
public function moveto() { $obj = new ormFieldsGroup(system::url(2)); $obj->setPosition(system::url(3)); if ($obj->save()) { echo "ok"; } else { echo "error"; } system::stop(); }
public function upd() { if (file_exists(MODUL_DIR . '/constructor/template/field.tpl')) { include MODUL_DIR . '/constructor/template/field.tpl'; } if (system::action() == "upd") { // форма обновления информации $obj = new ormField(system::url(2)); if ($obj->id() == '') { system::stop(); } page::assign('obj.fname', $obj->getName()); page::assign('obj.fsname', $obj->getSName()); page::assign('obj.hint', $obj->getHint()); page::assign('obj.max_size', $obj->getMaxSize()); page::assign('obj.id', $obj->id()); $view = $obj->getView(); $inherit = $obj->getInherit(); $search = $obj->getSearch(); $filter = $obj->getFilter(); $required = $obj->getRequired(); $system = $obj->getSystem(); $type = $obj->getType(); $list_id = $obj->getListId(); $uniqum = $obj->getUniqum(); $quick_add = $obj->getQuickAdd(); $relation = $obj->getRelType(); $spec = $obj->getSpec(); $fr = $obj->getSName() == 'name' ? '_name' : ''; page::assign('right', 'field_proc_upd'); } else { if (system::action() == "add") { // форма добавления информации if (system::issetUrl(2)) { // Проверяем существует ли родитель? $group = new ormFieldsGroup(system::url(2)); if ($group->id() == '') { system::stop(); } } $view = $inherit = 1; $search = $filter = $required = $system = $type = $list_id = $uniqum = $spec = $quick_add = $relation = 0; $fr = ''; page::assign('obj.id', system::url(2)); page::assign('right', 'field_proc_add'); } } page::assignArray(lang::get('CONSTR_FORM_FIELD3')); page::assignSavingPost(); ui::CheckBox('view', 1, $view, lang::get('CONSTR_FORM_FIELD3', 6)); ui::CheckBox('inherit', 1, $inherit, lang::get('CONSTR_FORM_FIELD3', 7)); ui::CheckBox('search', 1, $search, lang::get('CONSTR_FORM_FIELD3', 8)); ui::CheckBox('filter', 1, $filter, lang::get('CONSTR_FORM_FIELD3', 9)); ui::CheckBox('required', 1, $required, lang::get('CONSTR_FORM_FIELD3', 10)); ui::CheckBox('system', 1, $system, lang::get('CONSTR_FORM_FIELD3', 11)); ui::CheckBox('uniqum', 1, $uniqum, lang::get('CONSTR_FORM_FIELD3', 13)); ui::CheckBox('quick_add', 1, $quick_add, lang::get('CONSTR_FORM_FIELD3', 14)); ui::CheckBox('spec', 1, $spec, lang::get('CONSTR_FORM_FIELD3', 16)); ui::SelectBox('reltype', lang::get('CONSTR_RELTYPE'), $relation, 300); ui::SelectBox('type', lang::get('CONSTR_TYPE_LIST' . $fr), $type, 300); $list = ormClasses::getHandbooks(); ui::SelectBox('list_id', $list, $list_id, 300, ' '); page::assign('sh', !empty($list_id) ? '' : 'style="display:none;"'); page::assign('sh2', $type > 69 && $type < 86 ? '' : 'style="display:none;"'); page::assign('sh3', $type == 90 || $type == 95 || $type == 100 ? '' : 'style="display:none;"'); page::assign('sh4', $type == 55 || $type == 60 ? '' : 'style="display:none;"'); echo page::parse($TEMPLATE['frame' . $fr], 1); system::stop(); }