Loading plugins/template/template.cpp +39 −3 Changes for plugins/template/template.cpp: 39 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -506,11 +506,38 @@ namespace blogi { json_object *f_layer = json_object_new_object(); json_object_object_add(f_layer, "key", json_object_new_string("layer")); json_object_object_add(f_layer, "label", json_object_new_string(tr(_lang,"Layer (Element ID)").c_str())); json_object_object_add(f_layer, "type", json_object_new_string("text")); json_object_object_add(f_layer, "required", json_object_new_boolean(1)); json_object_object_add(f_layer, "placeholder", json_object_new_string("content")); json_object_object_add(f_layer, "type", json_object_new_string("select")); json_object *layer_opts = json_object_new_array(); json_object *custom_opt = json_object_new_object(); json_object_object_add(custom_opt, "value", json_object_new_string("__custom__")); json_object_object_add(custom_opt, "label", json_object_new_string(tr(_lang,"Custom layer...").c_str())); json_object_array_add(layer_opts, custom_opt); try { dbpp::SQL sql; dbpp::DBResult res; sql << "SELECT DISTINCT layer FROM templates WHERE layer IS NOT NULL AND layer<>'' ORDER BY layer"; int count = Args->database[tid]->exec(sql, res); for (int i = 0; i < count; ++i) { if (!res[i][0]) continue; json_object *opt = json_object_new_object(); json_object_object_add(opt, "value", json_object_new_string(res[i][0])); json_object_object_add(opt, "label", json_object_new_string(res[i][0])); json_object_array_add(layer_opts, opt); } } catch (...) {} json_object_object_add(f_layer, "options", layer_opts); json_object_array_add(fields, f_layer); json_object *f_layer_custom = json_object_new_object(); json_object_object_add(f_layer_custom, "key", json_object_new_string("layer_custom")); json_object_object_add(f_layer_custom, "label", json_object_new_string(tr(_lang,"Custom Layer (Element ID)").c_str())); json_object_object_add(f_layer_custom, "type", json_object_new_string("text")); json_object_object_add(f_layer_custom, "placeholder", json_object_new_string("content")); json_object_array_add(fields, f_layer_custom); json_object *f_type = json_object_new_object(); json_object_object_add(f_type, "key", json_object_new_string("type")); json_object_object_add(f_type, "label", json_object_new_string(tr(_lang,"Device Type").c_str())); Loading Loading @@ -538,6 +565,7 @@ namespace blogi { std::string _lang = getLang(*Args->database[tid]); std::string layer; std::string layerCustom; int type = 0; if (params) { Loading @@ -546,6 +574,10 @@ namespace blogi { const char *v = json_object_get_string(val_obj); if (v) layer = v; } if (json_object_object_get_ex(params, "layer_custom", &val_obj)) { const char *v = json_object_get_string(val_obj); if (v) layerCustom = v; } if (json_object_object_get_ex(params, "type", &val_obj)) { if (json_object_is_type(val_obj, json_type_string)) { type = atoi(json_object_get_string(val_obj)); Loading @@ -555,6 +587,10 @@ namespace blogi { } } if (layer == "__custom__") { layer = layerCustom; } if (layer.empty()) { json_object_object_add(response, "status", json_object_new_string("error")); json_object_object_add(response, "message", json_object_new_string(tr(_lang,"Layer is required.").c_str())); Loading Loading
plugins/template/template.cpp +39 −3 Changes for plugins/template/template.cpp: 39 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -506,11 +506,38 @@ namespace blogi { json_object *f_layer = json_object_new_object(); json_object_object_add(f_layer, "key", json_object_new_string("layer")); json_object_object_add(f_layer, "label", json_object_new_string(tr(_lang,"Layer (Element ID)").c_str())); json_object_object_add(f_layer, "type", json_object_new_string("text")); json_object_object_add(f_layer, "required", json_object_new_boolean(1)); json_object_object_add(f_layer, "placeholder", json_object_new_string("content")); json_object_object_add(f_layer, "type", json_object_new_string("select")); json_object *layer_opts = json_object_new_array(); json_object *custom_opt = json_object_new_object(); json_object_object_add(custom_opt, "value", json_object_new_string("__custom__")); json_object_object_add(custom_opt, "label", json_object_new_string(tr(_lang,"Custom layer...").c_str())); json_object_array_add(layer_opts, custom_opt); try { dbpp::SQL sql; dbpp::DBResult res; sql << "SELECT DISTINCT layer FROM templates WHERE layer IS NOT NULL AND layer<>'' ORDER BY layer"; int count = Args->database[tid]->exec(sql, res); for (int i = 0; i < count; ++i) { if (!res[i][0]) continue; json_object *opt = json_object_new_object(); json_object_object_add(opt, "value", json_object_new_string(res[i][0])); json_object_object_add(opt, "label", json_object_new_string(res[i][0])); json_object_array_add(layer_opts, opt); } } catch (...) {} json_object_object_add(f_layer, "options", layer_opts); json_object_array_add(fields, f_layer); json_object *f_layer_custom = json_object_new_object(); json_object_object_add(f_layer_custom, "key", json_object_new_string("layer_custom")); json_object_object_add(f_layer_custom, "label", json_object_new_string(tr(_lang,"Custom Layer (Element ID)").c_str())); json_object_object_add(f_layer_custom, "type", json_object_new_string("text")); json_object_object_add(f_layer_custom, "placeholder", json_object_new_string("content")); json_object_array_add(fields, f_layer_custom); json_object *f_type = json_object_new_object(); json_object_object_add(f_type, "key", json_object_new_string("type")); json_object_object_add(f_type, "label", json_object_new_string(tr(_lang,"Device Type").c_str())); Loading Loading @@ -538,6 +565,7 @@ namespace blogi { std::string _lang = getLang(*Args->database[tid]); std::string layer; std::string layerCustom; int type = 0; if (params) { Loading @@ -546,6 +574,10 @@ namespace blogi { const char *v = json_object_get_string(val_obj); if (v) layer = v; } if (json_object_object_get_ex(params, "layer_custom", &val_obj)) { const char *v = json_object_get_string(val_obj); if (v) layerCustom = v; } if (json_object_object_get_ex(params, "type", &val_obj)) { if (json_object_is_type(val_obj, json_type_string)) { type = atoi(json_object_get_string(val_obj)); Loading @@ -555,6 +587,10 @@ namespace blogi { } } if (layer == "__custom__") { layer = layerCustom; } if (layer.empty()) { json_object_object_add(response, "status", json_object_new_string("error")); json_object_object_add(response, "message", json_object_new_string(tr(_lang,"Layer is required.").c_str())); Loading