private function set_required_modules() { $options = []; $stubs = glob(core_dir . '/db/structures/*.json'); foreach ($stubs as $stub) { $base = pathinfo($stub, PATHINFO_FILENAME); try { $json = \core\db\stub\module::create($base); if ($json->required) { $options[] = $base; } } catch (\Exception $e) { } } \core::$inline_script[] = ' var required = ' . json_encode($options) . '; $("#cms_builder_field_modules input").each(function(cnt, input) { if($.inArray($(input).val(), required) != -1) { $(input).addClass("readonly"); $(input).prop("checked", true); } });'; }
protected function set_default_fields($module) { try { $json = module::create($module); $_module = $_field = db::select('_cms_module')->retrieve(['mid'])->filter(['table_name=:table_name'], ['table_name' => $json->tablename])->execute()->fetchObject(); if ($json && $_module) { $fields = $json->fieldset; $previous_key = false; foreach ($fields as $key => $row) { $format = db::get_column_type_json($row); if ($format) { if (!db::column_exists($json->tablename, $key)) { db::add_column($json->tablename, $key, $format, $previous_key ? ' AFTER `' . $previous_key . '`' : ' FIRST'); } else { db::move_column($json->tablename, $key, $format, $previous_key ? ' AFTER `' . $previous_key . '`' : ' FIRST'); } } if (!$row->is_default) { $_field = db::select('_cms_field')->retrieve(['fid'])->filter(['mid=:mid', 'field_name=:key'], ['mid' => $_module->mid, 'key' => $key])->execute(); if (!$_field->rowCount()) { $this->create_field_base($_module, $key, $row); } } $previous_key = $key; } } } catch (\Exception $e) { } }