mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Cfg: Add defaults loader
This commit is contained in:
parent
c10e34d26e
commit
f1396e13c7
@ -16,15 +16,19 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.apps.cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*;
|
||||
import gplx.dbs.*; import gplx.xowa.addons.apps.cfgs.mgrs.*;
|
||||
import gplx.xowa.addons.apps.cfgs.types.*;
|
||||
import gplx.dbs.*; import gplx.xowa.addons.apps.cfgs.mgrs.caches.*; import gplx.xowa.addons.apps.cfgs.mgrs.dflts.*; import gplx.xowa.addons.apps.cfgs.mgrs.types.*;
|
||||
public class Xocfg_mgr {
|
||||
private final Xocfg_cache_mgr cache_mgr = new Xocfg_cache_mgr();
|
||||
public Xocfg_mgr() {
|
||||
this.dflt_mgr = new Xocfg_dflt_mgr(cache_mgr);
|
||||
}
|
||||
public Xocfg_type_mgr Type_mgr() {return type_mgr;} private final Xocfg_type_mgr type_mgr = new Xocfg_type_mgr();
|
||||
public Xocfg_dflt_mgr Dflt_mgr() {return dflt_mgr;} private final Xocfg_dflt_mgr dflt_mgr;
|
||||
public void Init_by_app(Xoa_app app) {
|
||||
cache_mgr.Init_by_app // SECTION_EDIT
|
||||
cache_mgr.Init_by_app
|
||||
( gplx.xowa.addons.apps.cfgs.dbs.Xocfg_db_app.New_conn(app)
|
||||
, app.User().User_db_mgr().Conn());
|
||||
dflt_mgr.Init_by_app(app);
|
||||
}
|
||||
public void Clear() {
|
||||
cache_mgr.Clear();
|
||||
|
@ -17,15 +17,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.apps.cfgs.enums; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*;
|
||||
public class Xoitm_gui_tid { // SERIALIZED
|
||||
public static final int Tid__checkbox = 1, Tid__numeric = 2, Tid__select = 3, Tid__textbox = 4, Tid__fs_file = 5, Tid__fs_dir = 6, Tid__memo = 7, Tid__button = 8, Tid__label = 9;
|
||||
public static final int Tid__checkbox = 1, Tid__numeric = 2, Tid__select = 3, Tid__textbox = 4, Tid__memo = 5, Tid__io_file = 6, Tid__io_dir = 7, Tid__io_process = 8, Tid__button = 10, Tid__label = 11;
|
||||
public static final String
|
||||
Str__checkbox = "checkbox"
|
||||
, Str__numeric = "numeric"
|
||||
, Str__select = "select"
|
||||
, Str__textbox = "textbox"
|
||||
, Str__fs_file = "fs_file"
|
||||
, Str__fs_dir = "fs_dir"
|
||||
, Str__memo = "memo"
|
||||
, Str__io_file = "io.file"
|
||||
, Str__io_dir = "io.dir"
|
||||
, Str__io_process = "io.process"
|
||||
, Str__button = "button"
|
||||
, Str__label = "label"
|
||||
;
|
||||
@ -35,9 +36,10 @@ public class Xoitm_gui_tid { // SERIALIZED
|
||||
else if (String_.Eq(str, Str__numeric)) return Tid__numeric;
|
||||
else if (String_.Eq(str, Str__select)) return Tid__select;
|
||||
else if (String_.Eq(str, Str__textbox)) return Tid__textbox;
|
||||
else if (String_.Eq(str, Str__fs_file)) return Tid__fs_file;
|
||||
else if (String_.Eq(str, Str__fs_dir)) return Tid__fs_dir;
|
||||
else if (String_.Eq(str, Str__memo)) return Tid__memo;
|
||||
else if (String_.Eq(str, Str__io_file)) return Tid__io_file;
|
||||
else if (String_.Eq(str, Str__io_dir)) return Tid__io_dir;
|
||||
else if (String_.Eq(str, Str__io_process)) return Tid__io_process;
|
||||
else if (String_.Eq(str, Str__button)) return Tid__button;
|
||||
else if (String_.Eq(str, Str__label)) return Tid__label;
|
||||
else throw Err_.new_unhandled_default(str);
|
||||
@ -47,6 +49,8 @@ public class Xoitm_gui_tid { // SERIALIZED
|
||||
return Xoitm_gui_tid.Str__checkbox;
|
||||
else if (String_.Eq(db_type, "memo"))
|
||||
return Xoitm_gui_tid.Str__memo;
|
||||
else if (String_.Eq(db_type, "io.process"))
|
||||
return Xoitm_gui_tid.Str__io_process;
|
||||
else if (String_.Has_at_bgn(db_type, "list:"))
|
||||
return Xoitm_gui_tid.Str__select;
|
||||
else
|
||||
|
@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.apps.cfgs.mgrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*;
|
||||
package gplx.xowa.addons.apps.cfgs.mgrs.caches; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.mgrs.*;
|
||||
class Xocfg_cache_grp {
|
||||
private final Hash_adp vals = Hash_adp_.New();
|
||||
private final Ordered_hash subs = Ordered_hash_.New();
|
||||
@ -24,7 +24,8 @@ class Xocfg_cache_grp {
|
||||
this.dflt = dflt;
|
||||
}
|
||||
public String Key() {return key;} private final String key;
|
||||
public String Dflt() {return dflt;} private final String dflt;
|
||||
public String Dflt() {return dflt;} private String dflt;
|
||||
public void Dflt_(String v) {this.dflt = v;}
|
||||
public String Get(String ctx) {
|
||||
// exact match; EX: "en.w|key_1"
|
||||
Xocfg_cache_itm rv = (Xocfg_cache_itm)vals.Get_by(ctx);
|
@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.apps.cfgs.mgrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*;
|
||||
package gplx.xowa.addons.apps.cfgs.mgrs.caches; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.mgrs.*;
|
||||
class Xocfg_cache_itm {
|
||||
public Xocfg_cache_itm(String ctx, String key, String val) {
|
||||
this.ctx = ctx;
|
@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.apps.cfgs.mgrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*;
|
||||
package gplx.xowa.addons.apps.cfgs.mgrs.caches; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.mgrs.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.addons.apps.cfgs.dbs.*; import gplx.xowa.addons.apps.cfgs.dbs.tbls.*;
|
||||
public class Xocfg_cache_mgr {
|
||||
@ -51,6 +51,10 @@ public class Xocfg_cache_mgr {
|
||||
Xocfg_cache_grp grp = Grps__get_or_load(key);
|
||||
grp.Sub(sub, ctx, evt);
|
||||
}
|
||||
public void Dflt(String key, String val) {
|
||||
Xocfg_cache_grp grp = Grps__get_or_load(key);
|
||||
grp.Dflt_(val);
|
||||
}
|
||||
private Xocfg_cache_grp Grps__get_or_load(String key) {
|
||||
Xocfg_cache_grp grp = (Xocfg_cache_grp)grps.Get_by(key);
|
||||
if (grp == null) {
|
@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.apps.cfgs.mgrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*;
|
||||
package gplx.xowa.addons.apps.cfgs.mgrs.caches; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.mgrs.*;
|
||||
import org.junit.*; import gplx.core.tests.*; import gplx.dbs.*;
|
||||
import gplx.xowa.addons.apps.cfgs.dbs.*; import gplx.xowa.addons.apps.cfgs.specials.maints.services.*;
|
||||
public class Xocfg_cache_mgr__tst {
|
@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.apps.cfgs.mgrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*;
|
||||
package gplx.xowa.addons.apps.cfgs.mgrs.caches; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.mgrs.*;
|
||||
class Xocfg_cache_sub {
|
||||
public Xocfg_cache_sub(Gfo_invk sub, String ctx, String evt, String key) {
|
||||
this.ctx = ctx;
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.apps.cfgs.mgrs.dflts; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.mgrs.*;
|
||||
public interface Xocfg_dflt_itm {
|
||||
String Get_str(String key);
|
||||
}
|
||||
class Xocfg_dflt_itm__static implements Xocfg_dflt_itm {
|
||||
private final String val;
|
||||
public Xocfg_dflt_itm__static(String val) {
|
||||
this.val = val;
|
||||
}
|
||||
public String Get_str(String key) {
|
||||
return val;
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.apps.cfgs.mgrs.dflts; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.mgrs.*;
|
||||
import gplx.langs.jsons.*;
|
||||
class Xocfg_dflt_loader {
|
||||
public void Load_by_file(Xocfg_dflt_mgr dflt_mgr, Io_url url) {
|
||||
byte[] src = Io_mgr.Instance.LoadFilBryOrNull(url);
|
||||
if (src == null) return;
|
||||
Json_parser parser = new Json_parser();
|
||||
Json_doc doc = parser.Parse(src);
|
||||
Json_ary ary = doc.Root_ary();
|
||||
int len = ary.Len();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Json_nde nde = ary.Get_at_as_nde(i);
|
||||
String key = nde.Get_as_str_or("key", null);
|
||||
String val = nde.Get_as_str_or("val", null);
|
||||
dflt_mgr.Add(key, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
[
|
||||
{"key":"abcd", "val":"abcde\nbdfdfd"}
|
||||
, {"key":"abcd", "val":"abcde\nbdfdfd"}
|
||||
]
|
||||
*/
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.apps.cfgs.mgrs.dflts; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.mgrs.*;
|
||||
import gplx.xowa.addons.apps.cfgs.mgrs.caches.*;
|
||||
public class Xocfg_dflt_mgr {
|
||||
private final Xocfg_cache_mgr cache_mgr;
|
||||
private final Ordered_hash hash = Ordered_hash_.New();
|
||||
public Xocfg_dflt_mgr(Xocfg_cache_mgr cache_mgr) {
|
||||
this.cache_mgr = cache_mgr;
|
||||
}
|
||||
public void Init_by_app(Xoa_app app) {
|
||||
Xocfg_dflt_loader loader = new Xocfg_dflt_loader();
|
||||
loader.Load_by_file(this, app.Fsys_mgr().Bin_plat_dir().GenSubFil_nest("cfg", "xo.cfg.dflt.json"));
|
||||
}
|
||||
public String Get_or(String key, String or) {
|
||||
Xocfg_dflt_itm itm = (Xocfg_dflt_itm)hash.Get_by(key);
|
||||
return (itm == null) ? or : itm.Get_str(key);
|
||||
}
|
||||
public void Add(String key, String val) {
|
||||
cache_mgr.Dflt(key, val);
|
||||
}
|
||||
public void Add(String key, Xocfg_dflt_itm itm) {
|
||||
hash.Add(key, itm);
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.apps.cfgs.types; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*;
|
||||
package gplx.xowa.addons.apps.cfgs.mgrs.types; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.mgrs.*;
|
||||
public class Xocfg_type_mgr {
|
||||
private final Ordered_hash list_hash = Ordered_hash_.New();
|
||||
public Xocfg_type_mgr() {
|
@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.addons.apps.cfgs.specials.edits.objs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.specials.*; import gplx.xowa.addons.apps.cfgs.specials.edits.*;
|
||||
import gplx.langs.mustaches.*;
|
||||
import gplx.core.gfobjs.*; import gplx.langs.jsons.*;
|
||||
import gplx.xowa.addons.apps.cfgs.types.*;
|
||||
import gplx.xowa.addons.apps.cfgs.mgrs.types.*;
|
||||
public class Xoedit_itm implements Xoedit_nde, Mustache_doc_itm {
|
||||
private int gui_type;
|
||||
private boolean edited;
|
||||
|
@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.apps.cfgs.specials.edits.objs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.specials.*; import gplx.xowa.addons.apps.cfgs.specials.edits.*;
|
||||
import gplx.xowa.addons.apps.cfgs.enums.*;
|
||||
import gplx.xowa.addons.apps.cfgs.types.*;
|
||||
import gplx.xowa.addons.apps.cfgs.mgrs.types.*;
|
||||
public class Xoedit_itm_html {
|
||||
public void Build_html(Bry_bfr bfr, Xocfg_type_mgr type_mgr, String key, String name, String data_type, int gui_type, String gui_args, String data) {
|
||||
switch (gui_type) {
|
||||
@ -44,8 +44,16 @@ public class Xoedit_itm_html {
|
||||
}
|
||||
bfr.Add_str_u8_fmt("</select>");
|
||||
break;
|
||||
case Xoitm_gui_tid.Tid__fs_file:
|
||||
bfr.Add_str_u8_fmt("<input id=\"{0}\" data-xocfg=\"0\" type=\"text\" accesskey=\"d\" class=\"xocfg_fs_file\" value=\"{1}\"></input>", key, data);
|
||||
case Xoitm_gui_tid.Tid__io_process:
|
||||
String[] fields = String_.Split(data, "\n");
|
||||
String exe = fields.length > 1 ? fields[0] : "exe";
|
||||
String arg = fields.length > 2 ? fields[1] : "args";
|
||||
bfr.Add_str_u8_fmt
|
||||
( "<input class=\"xocfg__io_process__exe__txt\" id=\"{0}\" data-xocfg=\"0\" type=\"text\" accesskey=\"d\" value=\"{1}\"></input>\n"
|
||||
+ "<button class=\"xocfg__io_process__exe__btn\" onclick='xowa_io_select(\"file\", \"{0}\", \"Please select a file.\");'>...</button><br/>\n"
|
||||
, key + "-exe", exe);
|
||||
bfr.Add_str_u8_fmt
|
||||
( "<input class=\"xocfg__io_process__arg__txt\" id=\"{0}\" data-xocfg=\"0\" type=\"text\" accesskey=\"d\" value='{1}'>\n", key + "-arg", arg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -41,7 +41,7 @@ public class Xoedit_root implements Mustache_doc_itm {
|
||||
}
|
||||
public Mustache_doc_itm[] Mustache__subs(String key) {
|
||||
if (String_.Eq(key, "grps")) return grps;
|
||||
else if (String_.Eq(key, "nav_exists")) return Mustache_doc_itm_.Ary__bool(nav_mgr.Itms().length > 0);
|
||||
else if (String_.Eq(key, "nav_exists")) return Mustache_doc_itm_.Ary__bool(nav_mgr.Itms().length > 1); // NOTE: do not show combo if 0 or 1 item
|
||||
else if (String_.Eq(key, "itms")) return nav_mgr.Itms();
|
||||
return Mustache_doc_itm_.Ary__empty;
|
||||
}
|
||||
|
@ -18,15 +18,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.addons.apps.cfgs.specials.edits.services; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.specials.*; import gplx.xowa.addons.apps.cfgs.specials.edits.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.addons.apps.cfgs.dbs.*; import gplx.xowa.addons.apps.cfgs.dbs.tbls.*;
|
||||
import gplx.xowa.addons.apps.cfgs.specials.edits.objs.*; import gplx.xowa.addons.apps.cfgs.types.*;
|
||||
import gplx.xowa.addons.apps.cfgs.specials.edits.objs.*;
|
||||
import gplx.xowa.addons.apps.cfgs.mgrs.*; import gplx.xowa.addons.apps.cfgs.mgrs.dflts.*; import gplx.xowa.addons.apps.cfgs.mgrs.types.*;
|
||||
public class Xocfg_edit_loader {
|
||||
private final Xocfg_db_app db_app;
|
||||
private final Xocfg_db_usr db_usr;
|
||||
private final Xocfg_type_mgr type_mgr;
|
||||
public Xocfg_edit_loader(Xocfg_db_app db_app, Xocfg_db_usr db_usr, Xocfg_type_mgr type_mgr) {
|
||||
private final Xocfg_dflt_mgr dflt_mgr;
|
||||
public Xocfg_edit_loader(Xocfg_db_app db_app, Xocfg_db_usr db_usr, Xocfg_type_mgr type_mgr, Xocfg_dflt_mgr dflt_mgr) {
|
||||
this.db_app = db_app;
|
||||
this.db_usr = db_usr;
|
||||
this.type_mgr = type_mgr;
|
||||
this.dflt_mgr = dflt_mgr;
|
||||
}
|
||||
public Xoedit_root Load_root(String grp_key, String ctx, String lang) {
|
||||
// create lists
|
||||
@ -157,8 +160,10 @@ public class Xocfg_edit_loader {
|
||||
|
||||
Db_rdr rdr = db_app.Conn().Stmt_sql(sql).Exec_select__rls_auto();
|
||||
while (rdr.Move_next()) {
|
||||
Xoedit_itm edit_itm = (Xoedit_itm)itm_list.Get_by_or_fail(rdr.Read_str("itm_key"));
|
||||
edit_itm.Load_by_meta(rdr.Read_int("itm_scope_id"), rdr.Read_str("itm_data_type"), rdr.Read_int("itm_gui_type"), rdr.Read_str("itm_gui_args"), rdr.Read_str("itm_dflt"));
|
||||
String key = rdr.Read_str("itm_key");
|
||||
Xoedit_itm edit_itm = (Xoedit_itm)itm_list.Get_by_or_fail(key);
|
||||
String dflt = dflt_mgr.Get_or(key, rdr.Read_str("itm_dflt"));
|
||||
edit_itm.Load_by_meta(rdr.Read_int("itm_scope_id"), rdr.Read_str("itm_data_type"), rdr.Read_int("itm_gui_type"), rdr.Read_str("itm_gui_args"), dflt);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -236,6 +241,6 @@ public class Xocfg_edit_loader {
|
||||
}
|
||||
public static Xocfg_edit_loader New(Xoa_app app) {
|
||||
Xocfg_db_app db_app = Xocfg_db_app.New(app);
|
||||
return new Xocfg_edit_loader(db_app, new Xocfg_db_usr(db_app, app.User().User_db_mgr().Conn()), app.Cfg().Type_mgr());
|
||||
return new Xocfg_edit_loader(db_app, new Xocfg_db_usr(db_app, app.User().User_db_mgr().Conn()), app.Cfg().Type_mgr(), app.Cfg().Dflt_mgr());
|
||||
}
|
||||
}
|
||||
|
@ -77,12 +77,6 @@ public class Xop_hdr_wkr implements Xop_ctx_wkr {
|
||||
if (dirty)
|
||||
hdr.Init_by_parse(hdr_len, bgn_manual, end_manual);
|
||||
|
||||
// section-editable
|
||||
// if ( ctx.Wiki().Parser_mgr().Hdr__section_editable__enabled()
|
||||
// && Bry_.Eq(src, cur_pos, cur_pos + Xop_section_mgr.Len__meta, Xop_section_mgr.Bry__meta)) {
|
||||
// ctx.Wiki().Parser_mgr().Hdr__section_editable__mgr().Parse(hdr, ctx.Page().Ttl().Full_db(), src, cur_pos, src_len); // SECTION_EDIT
|
||||
// }
|
||||
|
||||
// gobble ws; hdr gobbles up trailing ws; EX: "==a== \n\t \n \nb" gobbles up all 3 "\n"s; otherwise para_wkr will process <br/>
|
||||
cur_pos = Find_fwd_while_ws_hdr_version(src, cur_pos, src_len);
|
||||
ctx.Para().Process_block__bgn_n__end_y(Xop_xnde_tag_.Tag__h2);
|
||||
|
@ -32,7 +32,7 @@ public class Xop_section_mgr implements Gfo_invk {
|
||||
public void Init_by_wiki(Xowe_wiki wiki) {
|
||||
this.app = wiki.Appe();
|
||||
this.wiki = wiki;
|
||||
this.enabled = wiki.App().Cfg().Bind_bool(wiki, gplx.xowa.htmls.core.wkrs.hdrs.Xoh_section_editable_.Cfg__section_editing__enabled, this); // SECTION_EDIT
|
||||
this.enabled = wiki.App().Cfg().Bind_bool(wiki, gplx.xowa.htmls.core.wkrs.hdrs.Xoh_section_editable_.Cfg__section_editing__enabled, this);
|
||||
this.tidy_mgr = wiki.Html_mgr().Tidy_mgr();
|
||||
}
|
||||
public byte[] Slice_section(Xoa_url url, Xoa_ttl ttl, byte[] src) {
|
||||
|
@ -53,11 +53,11 @@ public class Xow_cache_mgr {
|
||||
public void Free_mem_all() {this.Free_mem_all(Bool_.Y);}
|
||||
public void Free_mem_all(boolean free_page_cache) {
|
||||
if (free_page_cache) {
|
||||
page_cache.Free_mem_all();
|
||||
commons_cache.Clear();
|
||||
ifexist_cache.Clear();
|
||||
wiki.Appe().Wiki_mgr().Wdata_mgr().Clear(); // moved from ctx.Clear(); DATE:2016-07-21
|
||||
}
|
||||
page_cache.Free_mem_all();
|
||||
wiki.Ctg__catpage_mgr().Free_mem_all();
|
||||
tmpl_result_cache.Clear();
|
||||
defn_cache.Free_mem_all();
|
||||
|
Loading…
Reference in New Issue
Block a user