mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.8.5.1
This commit is contained in:
@@ -19,9 +19,9 @@ package gplx.xowa.specials; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.users.history.*;
|
||||
import gplx.xowa.specials.*;
|
||||
import gplx.xowa.specials.allPages.*; import gplx.xowa.specials.search.*; import gplx.xowa.specials.nearby.*; import gplx.xowa.specials.randoms.*; import gplx.xowa.specials.statistics.*; import gplx.xowa.xtns.translates.*; import gplx.xowa.specials.movePage.*;
|
||||
import gplx.xowa.specials.xowa.system_data.*; import gplx.xowa.specials.xowa.default_tab.*; import gplx.xowa.specials.xowa.popup_history.*; import gplx.xowa.specials.xowa.file_browsers.*; import gplx.xowa.specials.xowa.bookmarks.*; import gplx.xowa.specials.xowa.diags.*;
|
||||
import gplx.xowa.specials.xowa.system_data.*; import gplx.xowa.specials.xowa.default_tab.*; import gplx.xowa.specials.xowa.popup_history.*; import gplx.xowa.specials.xowa.file_browsers.*; import gplx.xowa.specials.xowa.diags.*;
|
||||
import gplx.xowa.xtns.wdatas.specials.*;
|
||||
import gplx.xowa.users.data.*;
|
||||
import gplx.xowa.users.data.*; import gplx.xowa.users.bmks.*;
|
||||
public class Xows_mgr {
|
||||
private final Hash_adp_bry hash;
|
||||
public Xows_mgr(Xowe_wiki wiki, Xol_lang lang) {
|
||||
|
||||
@@ -95,7 +95,7 @@ public class Xows_page_allpages implements GfoInvkAble, Bry_fmtr_arg, Xows_page
|
||||
rslt_list_ttls[i] = null;
|
||||
rslt_list_len = 0;
|
||||
rslt_nxt = rslt_prv = null;
|
||||
Xoa_ttl from_ttl = Xoa_ttl.parse_(wiki, from_val); if (from_ttl == null) return false;
|
||||
Xoa_ttl from_ttl = Xoa_ttl.parse(wiki, from_val); if (from_ttl == null) return false;
|
||||
if (!from_ttl.Ns().Id_main()) { // ns specified in title
|
||||
init_ns = from_ttl.Ns();
|
||||
arg_hash.Set_val_by_int(Bry_arg_ns, init_ns.Id());
|
||||
@@ -139,7 +139,7 @@ public class Xows_page_allpages implements GfoInvkAble, Bry_fmtr_arg, Xows_page
|
||||
public static Xoa_ttl ttl_(Xowe_wiki wiki, Xow_ns ns, Xowd_page_itm itm) {
|
||||
byte[] ttl_bry = itm.Ttl_page_db();
|
||||
if (!ns.Id_main()) ttl_bry = Bry_.Add(ns.Name_db_w_colon(), ttl_bry);
|
||||
return Xoa_ttl.parse_(wiki, ttl_bry);
|
||||
return Xoa_ttl.parse(wiki, ttl_bry);
|
||||
}
|
||||
public void XferAry(Bry_bfr bfr, int idx) {
|
||||
int len = rslt_list_ttls.length;
|
||||
|
||||
@@ -200,5 +200,5 @@ class Xows_page_allpages_fxt {
|
||||
Xoa_ttl init_ttl = Make_init_ttl();
|
||||
allpages.Build_data(init_url, init_ttl);
|
||||
}
|
||||
private Xoa_ttl Make_init_ttl() {return Xoa_ttl.parse_(wiki, Bry_.new_u8(Xows_special_meta_.Itm__all_pages.Ttl_str() + init_ttl_leaf));}
|
||||
private Xoa_ttl Make_init_ttl() {return Xoa_ttl.parse(wiki, Bry_.new_u8(Xows_special_meta_.Itm__all_pages.Ttl_str() + init_ttl_leaf));}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class Move_page implements Xows_page {
|
||||
public void Special_gen(Xowe_wiki wiki, Xoae_page page, Xoa_url url, Xoa_ttl ttl) {
|
||||
args.Parse(url);
|
||||
byte[] src_ttl_bry = args.Src_ttl();
|
||||
src_ttl = Xoa_ttl.parse_(wiki, src_ttl_bry);
|
||||
src_ttl = Xoa_ttl.parse(wiki, src_ttl_bry);
|
||||
if (args.Submitted()) {
|
||||
Exec_rename(wiki, page);
|
||||
return;
|
||||
@@ -40,7 +40,7 @@ public class Move_page implements Xows_page {
|
||||
int trg_ns_id = args.Trg_ns();
|
||||
Xow_ns trg_ns = wiki.Ns_mgr().Ids_get_or_null(trg_ns_id); if (trg_ns == null) throw Err_.new_wo_type("unknown ns", "ns", trg_ns_id);
|
||||
byte[] trg_ttl_bry = args.Trg_ttl();
|
||||
Xoa_ttl trg_ttl = Xoa_ttl.parse_(wiki, trg_ns_id, trg_ttl_bry);
|
||||
Xoa_ttl trg_ttl = Xoa_ttl.parse(wiki, trg_ns_id, trg_ttl_bry);
|
||||
Xowd_page_itm src_page = new Xowd_page_itm();
|
||||
wiki.Db_mgr().Load_mgr().Load_by_ttl(src_page, src_ttl.Ns(), src_ttl.Page_db());
|
||||
page.Revision_data().Id_(src_page.Id());
|
||||
@@ -167,7 +167,7 @@ class Move_url_args {
|
||||
private void Clear() {
|
||||
submitted = false;
|
||||
src_ttl = trg_ttl = null;
|
||||
trg_ns = Int_.MinValue;
|
||||
trg_ns = Int_.Min_value;
|
||||
create_redirect = false;
|
||||
}
|
||||
private static final byte Key_submitted = 1, Key_src_ttl = 2, Key_trg_ns = 3, Key_trg_ttl = 4, Key_create_redirect = 5;
|
||||
|
||||
@@ -68,8 +68,8 @@ public class Nearby_mgr implements Xows_page {
|
||||
Ordered_hash src_pool = Ordered_hash_.new_bry_();
|
||||
public List_adp Find_from_to(Xowe_wiki wiki, byte[] src_bry, byte[] trg_bry, Hash_adp_bry excluded) {
|
||||
this.wiki = wiki; this.excluded = excluded;
|
||||
Xoa_ttl src_ttl = Xoa_ttl.parse_(wiki, src_bry); if (src_ttl == null) return List_adp_.Noop;
|
||||
trg_ttl = Xoa_ttl.parse_(wiki, trg_bry); if (trg_ttl == null) return List_adp_.Noop;
|
||||
Xoa_ttl src_ttl = Xoa_ttl.parse(wiki, src_bry); if (src_ttl == null) return List_adp_.Noop;
|
||||
trg_ttl = Xoa_ttl.parse(wiki, trg_bry); if (trg_ttl == null) return List_adp_.Noop;
|
||||
trg = trg_ttl.Page_db();
|
||||
trail.Clear();
|
||||
results.Clear();
|
||||
|
||||
@@ -21,7 +21,7 @@ public class Xop_randomRootPage_page implements Xows_page {
|
||||
public void Special_gen(Xowe_wiki wiki, Xoae_page page, Xoa_url url, Xoa_ttl ttl) {
|
||||
Xow_ns ns = wiki.Ns_mgr().Names_get_or_main(ttl.Rest_txt());
|
||||
byte[] random_ttl_bry = wiki.Db_mgr().Load_mgr().Find_random_ttl(ns);
|
||||
byte[] root_bry = Xoa_ttl.parse_(wiki, random_ttl_bry).Root_txt();
|
||||
byte[] root_bry = Xoa_ttl.parse(wiki, random_ttl_bry).Root_txt();
|
||||
wiki.Data_mgr().Redirect(page, ns.Gen_ttl(root_bry));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ class Xop_randomRootPage_page_fxt {
|
||||
Xoae_page page = wiki.Ctx().Cur_page();
|
||||
Xoa_url url = wiki.Utl__url_parser().Parse(Bry_.new_u8(special_url));
|
||||
page.Url_(url);
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, Bry_.new_a7(special_url));
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, Bry_.new_a7(special_url));
|
||||
page.Ttl_(ttl);
|
||||
special_page.Special_gen(wiki, page, url, ttl);
|
||||
return page;
|
||||
|
||||
@@ -54,7 +54,7 @@ class Xog_search_suggest_cmd implements GfoInvkAble, Cancelable {
|
||||
}
|
||||
private boolean Search_by_all_pages_v2() {
|
||||
rslts_2.Clear();
|
||||
Xoa_ttl search_ttl = Xoa_ttl.parse_(wiki, search_bry); if (search_ttl == null) return false;
|
||||
Xoa_ttl search_ttl = Xoa_ttl.parse(wiki, search_bry); if (search_ttl == null) return false;
|
||||
byte[] search_ttl_bry = search_ttl.Page_db();
|
||||
wiki.Db_mgr().Load_mgr().Load_ttls_for_search_suggest(this, rslts_2, search_ttl.Ns(), search_ttl_bry, max_results, all_pages_min, all_pages_extend, true, false);
|
||||
return true;
|
||||
@@ -63,7 +63,7 @@ class Xog_search_suggest_cmd implements GfoInvkAble, Cancelable {
|
||||
rslts_2.Clear();
|
||||
Xowd_page_itm rslt_nxt = new Xowd_page_itm();
|
||||
Xowd_page_itm rslt_prv = new Xowd_page_itm();
|
||||
Xoa_ttl search_ttl = Xoa_ttl.parse_(wiki, search_bry); if (search_ttl == null) return false;
|
||||
Xoa_ttl search_ttl = Xoa_ttl.parse(wiki, search_bry); if (search_ttl == null) return false;
|
||||
byte[] search_ttl_bry = search_ttl.Page_db();
|
||||
List_adp page_list = List_adp_.new_();
|
||||
wiki.Db_mgr().Load_mgr().Load_ttls_for_all_pages(this, page_list, rslt_nxt, rslt_prv, Int_obj_ref.zero_(), wiki.Ns_mgr().Ns_main(), search_ttl_bry, max_results, all_pages_min, all_pages_extend, true, false);
|
||||
|
||||
@@ -188,7 +188,7 @@ public class Xosrh_core_tst {
|
||||
// public void Test_html_by_url(String ttl_str, String args_str, String expd_html) {
|
||||
// wiki.Init_needed_(false);
|
||||
// byte[] ttl_bry = Bry_.new_a7(ttl_str);
|
||||
// Xoa_ttl ttl = Xoa_ttl.parse_(wiki, ttl_bry);
|
||||
// Xoa_ttl ttl = Xoa_ttl.parse(wiki, ttl_bry);
|
||||
// Xoae_page page = Xoae_page.test_(wiki, ttl);
|
||||
// byte[] url_bry = Bry_.new_a7("http://en.wikipedia.org/wiki/Special:Search/" + ttl_str + args_str);
|
||||
// Xoa_url url = wiki.Appe().Url_parser().Parse(url_bry);
|
||||
@@ -200,7 +200,7 @@ public class Xosrh_core_tst {
|
||||
// Xoa_url_parser_old url_parser = new Xoa_url_parser_old();
|
||||
// byte[] url_raw = Bry_.new_a7("Special:Search/" + ttl_str + ((match_tid == Xows_page__search.Match_tid_all) ? "" : "*") + "?fulltext=y" + Xosrh_rslt_itm_sorter.Xto_url_arg(sort_tid) + "&xowa_page_size=1&xowa_page_index=" + page_idx);
|
||||
// Xoa_url url = url_parser.Parse(url_raw);
|
||||
// Xoa_ttl ttl = Xoa_ttl.parse_(wiki, url_raw);
|
||||
// Xoa_ttl ttl = Xoa_ttl.parse(wiki, url_raw);
|
||||
// Xoae_page page = wiki.Ctx().Cur_page();
|
||||
// search_mgr.Special_gen(url, page, wiki, ttl);
|
||||
// Xosrh_rslt_grp cur_grp = search_mgr.Cur_grp();
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Xosrh_rslt_itm_sorter implements gplx.lists.ComparerAble {
|
||||
}
|
||||
}
|
||||
public static final byte Tid_none = 0, Tid_len_dsc = 1, Tid_ttl_asc = 2, Tid_id = 3;
|
||||
public static byte parse_(String v) {
|
||||
public static byte parse(String v) {
|
||||
if (String_.Eq(v, "none")) return Tid_none;
|
||||
else if (String_.Eq(v, "len_desc")) return Tid_len_dsc;
|
||||
else if (String_.Eq(v, "title_asc")) return Tid_ttl_asc;
|
||||
|
||||
@@ -36,7 +36,7 @@ class Xow_domain_sorter__manual implements gplx.lists.ComparerAble {
|
||||
}
|
||||
private int Get_sort_idx_or_neg1(Xow_domain_itm domain) {
|
||||
int sort_idx = domain.Sort_idx(); if (sort_idx != -1) return sort_idx;
|
||||
sort_idx = Int_.MaxValue;
|
||||
sort_idx = Int_.Max_value;
|
||||
for (int i = 0; i < ary_len; ++i) {
|
||||
Xow_domain_crt_itm crt = ary[i];
|
||||
if (crt.Matches(cur_domain, domain)) {sort_idx = i; break;}
|
||||
|
||||
@@ -45,7 +45,7 @@ class Xows_arg_mgr {
|
||||
switch (((Byte_obj_val)tid).Val()) {
|
||||
case Arg_search: this.search_bry = Bry_.Replace(arg.Val_bry(), Byte_ascii.Plus, Byte_ascii.Space); break;
|
||||
case Arg_page_idx: this.paging_idx = Bry_.To_int_or(arg.Val_bry(), 0); break;
|
||||
case Arg_sort: this.sort_tid = Xosrh_rslt_itm_sorter.parse_(String_.new_a7(arg.Val_bry())); break;
|
||||
case Arg_sort: this.sort_tid = Xosrh_rslt_itm_sorter.parse(String_.new_a7(arg.Val_bry())); break;
|
||||
case Arg_cancel: this.cancel = arg.Val_bry(); break;
|
||||
case Arg_paging: this.paging_itms = paging_parser.Parse(arg.Val_bry()); break;
|
||||
default: break;
|
||||
|
||||
@@ -44,7 +44,7 @@ class Xows_core {
|
||||
qry.Cmds__add(cmd);
|
||||
} catch (Exception e) {Xoa_app_.Usr_dlg().Warn_many("", "", "search:wiki failed; wiki=~{0} err=~{1}", domain.Domain_str(), Err_.Message_lang(e));} // handle bad wikis, like "en.wikipedia.org-old"; DATE:2015-04-24
|
||||
}
|
||||
qry.Page_max_(Int_.MaxValue);
|
||||
qry.Page_max_(Int_.Max_value);
|
||||
// do search and generate html
|
||||
html_wkr.Init_by_wiki(search_wiki, search_wiki.Lang().Num_mgr(), qry);
|
||||
int cmds_len = qry.Cmds__len();
|
||||
|
||||
@@ -52,7 +52,7 @@ class Xows_db_wkr {
|
||||
if (word.Rslts_done()) continue; // last db_search for word returned 0 results; don't search again;
|
||||
int offset = word.Rslts_offset();
|
||||
Xoa_app_.Usr_dlg().Prog_many("", "", "searching; wiki=~{0} total=~{1} offset=~{2} index=~{3} word=~{4}", wiki.Domain_str(), word_ary_len, offset, i, word.Text());
|
||||
String sql = String_.Format(Search_sql, link_tbl.Tbl_name(), link_tbl.Fld_page_id(), link_tbl.Fld_word_id(), word.Id(), "page_len", "DESC", Int_.MaxValue, offset); // need to return enough results to fill qry.Page_len() as many results may be discarded below; DATE:2015-04-24
|
||||
String sql = String_.Format(Search_sql, link_tbl.Tbl_name(), link_tbl.Fld_page_id(), link_tbl.Fld_word_id(), word.Id(), "page_len", "DESC", Int_.Max_value, offset); // need to return enough results to fill qry.Page_len() as many results may be discarded below; DATE:2015-04-24
|
||||
int rslts_found = Search_pages(cmd, qry, rslt, cache, wiki, page_tbl, attach_rdr, sql, word, matcher, rslts_wanted);
|
||||
total_found += rslts_found;
|
||||
if (rslts_found == -1) return; // canceled
|
||||
|
||||
@@ -22,9 +22,9 @@ import gplx.xowa.wikis.data.tbls.*;
|
||||
public class Xows_html_wkr_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xows_html_wkr_fxt fxt = new Xows_html_wkr_fxt();
|
||||
@Test public void Paging() {
|
||||
fxt.Test_paging(Bool_.Y, 1, "<a href='/site/en.wikipedia.org/wiki/Special:Search/A%3Ffulltext%3Dy%26xowa_page_index%3D2' title='Next'>Next<img src='file:///mem/xowa/user/anonymous/app/img/window/paging/go_fwd.png' width='16' height='16'/></a>");
|
||||
fxt.Test_paging(Bool_.N, 1, "<a href='/site/en.wikipedia.org/wiki/Special:Search/A%3Ffulltext%3Dy%26xowa_page_index%3D0' title='Previous'><img src='file:///mem/xowa/user/anonymous/app/img/window/paging/go_bwd.png' width='16' height='16'/>Previous</a>");
|
||||
fxt.Test_paging(Bool_.Y, 2, "<a href='/site/en.wikipedia.org/wiki/Special:Search/A%3Ffulltext%3Dy%26xowa_page_index%3D3' title='Next'>Next<img src='file:///mem/xowa/user/anonymous/app/img/window/paging/go_fwd.png' width='16' height='16'/></a>");
|
||||
fxt.Test_paging(Bool_.Y, 1, "<a href='/site/en.wikipedia.org/wiki/Special:Search/A%3Ffulltext%3Dy%26xowa_page_index%3D2' title='Next'>Next<img src='file:///mem/xowa/bin/any/xowa/file/app.general/go_fwd.png' width='16' height='16'/></a>");
|
||||
fxt.Test_paging(Bool_.N, 1, "<a href='/site/en.wikipedia.org/wiki/Special:Search/A%3Ffulltext%3Dy%26xowa_page_index%3D0' title='Previous'><img src='file:///mem/xowa/bin/any/xowa/file/app.general/go_bwd.png' width='16' height='16'/>Previous</a>");
|
||||
fxt.Test_paging(Bool_.Y, 2, "<a href='/site/en.wikipedia.org/wiki/Special:Search/A%3Ffulltext%3Dy%26xowa_page_index%3D3' title='Next'>Next<img src='file:///mem/xowa/bin/any/xowa/file/app.general/go_fwd.png' width='16' height='16'/></a>");
|
||||
fxt.Test_paging(Bool_.N, 0, " ");
|
||||
}
|
||||
@Test public void Rows() {
|
||||
|
||||
@@ -50,8 +50,8 @@ public class Xows_ns_mgr {
|
||||
if (key_len == 3 && key[2] == Byte_ascii.Star) // translate ns* as ns_all
|
||||
ns_all = true;
|
||||
else {
|
||||
int ns_id = Bry_.To_int_or(key, 2, key_len, Int_.MinValue);
|
||||
if (ns_id != Int_.MinValue) { // ignore invalid ints; EX: &nsabc=1;
|
||||
int ns_id = Bry_.To_int_or(key, 2, key_len, Int_.Min_value);
|
||||
if (ns_id != Int_.Min_value) { // ignore invalid ints; EX: &nsabc=1;
|
||||
Add_by_id(ns_id);
|
||||
ns_main = ns_all = false;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class Xows_page__search implements Xows_page, GfoInvkAble, GfoEvObj {
|
||||
search_bry = Bry_.Add(search_bry, Byte_ascii.Star);
|
||||
// url.Page_bry_(Bry_.Add(Xows_special_meta_.Itm__search.Ttl_bry(), Byte_ascii.Slash_bry, search_bry));// HACK: need to re-set Page b/c href_parser does not eliminate qargs; DATE:2013-02-08
|
||||
// search wiki
|
||||
Xoa_ttl search_ttl = Xoa_ttl.parse_(wiki, search_bry);
|
||||
Xoa_ttl search_ttl = Xoa_ttl.parse(wiki, search_bry);
|
||||
Xoae_page search_page = page;
|
||||
if (!Bry_.Eq(search_bry, Xows_special_meta_.Itm__search.Ttl_bry())) // do not lookup page else stack overflow; happens when going directly to Special:Search (from history)
|
||||
search_page = wiki.Data_mgr().Get_page(search_ttl, false); // try to find page; EX:Special:Search?search=Earth -> en.w:Earth; needed for search suggest
|
||||
|
||||
@@ -1,125 +0,0 @@
|
||||
/*
|
||||
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.specials.xowa.bookmarks; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*; import gplx.xowa.specials.xowa.*;
|
||||
import gplx.core.json.*; import gplx.html.*;
|
||||
import gplx.xowa.users.data.*; import gplx.xowa.users.bmks.*;
|
||||
import gplx.xowa.html.bridges.*; import gplx.xowa.html.bridges.dbuis.*; import gplx.xowa.html.bridges.dbuis.tbls.*; import gplx.xowa.html.bridges.dbuis.fmtrs.*;
|
||||
public class Dbui_tbl_itm__bmk implements Dbui_tbl_itm {
|
||||
private final Xoa_app app; private final Xoud_bmk_itm_tbl tbl;
|
||||
private final Dbui_tbl_fmtr tbl_fmtr = new Dbui_tbl_fmtr();
|
||||
private final Dbui_cells_fmtr cells_fmtr = new Dbui_cells_fmtr(); private final Dbui_val_fmtr edit_val_fmtr = Dbui_val_fmtr_.new_edit(); private final Dbui_val_fmtr view_val_fmtr = Dbui_val_fmtr_.new_view();
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr.new_(255);
|
||||
private final Bridge_msg_bldr msg_bldr;
|
||||
public Dbui_tbl_itm__bmk(Xoa_app app, Xoud_bmk_itm_tbl tbl) {this.app = app; this.tbl = tbl; this.msg_bldr = app.Html__bridge_mgr().Msg_bldr();}
|
||||
public byte[] Key() {return key;} private static final byte[] key = Bry_.new_a7("bmk");
|
||||
public Dbui_btn_itm[] View_btns() {return view_btns;}
|
||||
public Dbui_btn_itm[] Edit_btns() {return edit_btns;}
|
||||
public Dbui_col_itm[] Cols() {return cols;}
|
||||
public void Reg(Bridge_cmd_mgr bridge_mgr) {
|
||||
Dbui_cmd_mgr dbui_mgr = Dbui_cmd_mgr.I;
|
||||
dbui_mgr.Init_by_bridge(bridge_mgr);
|
||||
dbui_mgr.Add(this);
|
||||
}
|
||||
public void Select(Bry_bfr bfr, int owner) {
|
||||
Xoud_bmk_itm_row[] db_rows = tbl.Select_grp(owner);
|
||||
byte[] option_link = app.Html__lnki_bldr().Href_(Bry_.new_a7("home"), app.User().Wikii().Ttl_parse(Bry_.new_a7("Help:Options/Bookmarks"))).Img_16x16(gplx.xowa.html.wtrs.Xoh_img_path.Img_option).Bld_to_bry();
|
||||
byte[] delete_confirm_msg = app.Api_root().Usr().Bookmarks().Delete_confirm() ? Msg__delete_confirm : Bry_.Empty;
|
||||
tbl_fmtr.Write(bfr, this, option_link, delete_confirm_msg, To_ui_rows(db_rows));
|
||||
} private static final byte[] Msg__delete_confirm = Bry_.new_a7(" data-dbui-delete_confirm_msg='Are you sure you want to delete this bookmark?'");
|
||||
public String Del(byte[] row_id, byte[] row_pkey) {
|
||||
Xoud_bmk_itm_row db_row = Get_db_row(row_pkey); if (db_row == null) return Fail_missing_row(row_pkey);
|
||||
tbl.Delete(db_row.Id());
|
||||
return msg_bldr.To_json_str__empty();
|
||||
}
|
||||
public String Edit(byte[] row_id, byte[] row_pkey) {
|
||||
Xoud_bmk_itm_row db_row = Get_db_row(row_pkey); if (db_row == null) return Fail_missing_row(row_pkey);
|
||||
Dbui_row_itm ui_row = Get_ui_row(db_row);
|
||||
return Write_cells(edit_val_fmtr, edit_btns, row_id, ui_row);
|
||||
}
|
||||
public String Save(byte[] row_id, byte[] row_pkey, Dbui_val_hash vals) {
|
||||
Xoud_bmk_itm_row db_row = Get_db_row(row_pkey); if (db_row == null) return Fail_missing_row(row_pkey);
|
||||
byte[] new_name = vals.Get_val_as_bry("name");
|
||||
byte[] new_url_bry = vals.Get_val_as_bry("url");
|
||||
byte[] new_comment = vals.Get_val_as_bry("comment");
|
||||
Xoa_url new_url = app.User().Wikii().Utl__url_parser().Parse(new_url_bry);
|
||||
if (new_url.Page_bry() == null) return msg_bldr.Clear().Notify_fail_(Err_msg.To_str("Url is invalid", "url", new_url.Raw())).To_json_str();
|
||||
tbl.Update(db_row.Id(), db_row.Owner(), db_row.Sort(), new_name, new_url.Wiki_bry(), new_url_bry, new_comment);
|
||||
Dbui_row_itm ui_row = Get_ui_row(row_pkey, new_name, new_url_bry, new_comment);
|
||||
return Write_cells(view_val_fmtr, view_btns, row_id, ui_row);
|
||||
}
|
||||
public String Reorder(byte[][] pkeys, int owner) {
|
||||
Xoud_bmk_itm_row[] db_rows = tbl.Select_grp(Xoud_bmk_mgr.Owner_root);
|
||||
int len = db_rows.length; if (len != pkeys.length) return msg_bldr.Clear().Notify_fail_(Err_msg.To_str("Rows have changed")).Notify_hint_("Please reload the page").To_json_str();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
int old_pkey = db_rows[i].Id();
|
||||
int new_pkey = Bry_.To_int_or_neg1(pkeys[i]);
|
||||
if (old_pkey == new_pkey) continue; // order hasn't changed; EX: 5 in list; 4th moved to 5th; 1 through 3 will have same sort order;
|
||||
tbl.Update_sort(new_pkey, i);
|
||||
}
|
||||
return msg_bldr.To_json_str__empty();
|
||||
}
|
||||
public Dbui_row_itm[] To_ui_rows(Xoud_bmk_itm_row[] db_rows) {
|
||||
int len = db_rows.length;
|
||||
Dbui_row_itm[] rv = new Dbui_row_itm[len];
|
||||
for (int i = 0; i < len; ++i)
|
||||
rv[i] = Get_ui_row(db_rows[i]);
|
||||
return rv;
|
||||
}
|
||||
private String Write_cells(Dbui_val_fmtr val_fmtr, Dbui_btn_itm[] btns, byte[] row_id, Dbui_row_itm row) {
|
||||
cells_fmtr.Ctor(val_fmtr, btns);
|
||||
cells_fmtr.Init(row_id, row);
|
||||
cells_fmtr.XferAry(tmp_bfr, 0);
|
||||
return app.Html__bridge_mgr().Msg_bldr().Clear().Data("html", tmp_bfr.Xto_bry_and_clear()).To_json_str();
|
||||
}
|
||||
private Xoud_bmk_itm_row Get_db_row(byte[] pkey) {
|
||||
int bmk_id = Bry_.To_int(pkey);
|
||||
return tbl.Select_or_null(bmk_id);
|
||||
}
|
||||
private Dbui_row_itm Get_ui_row(Xoud_bmk_itm_row row) {return Get_ui_row(Int_.Xto_bry(row.Id()), row.Name(), row.Url(), row.Comment());}
|
||||
private Dbui_row_itm Get_ui_row(byte[] pkey, byte[] name, byte[] url, byte[] comment) {
|
||||
Dbui_val_itm[] vals = new Dbui_val_itm[3];
|
||||
vals[0] = new Dbui_val_itm(name, Html_utl.Escape_html_as_bry(tmp_bfr, name));
|
||||
vals[1] = new Dbui_val_itm(url, url_fmtr.Bld_bry_many(tmp_bfr, Html_utl.Escape_for_atr_val_as_bry(tmp_bfr, Byte_ascii.Apos, url)));
|
||||
vals[2] = new Dbui_val_itm(comment, Html_utl.Escape_html_as_bry(comment));
|
||||
return new Dbui_row_itm(this, pkey, vals);
|
||||
}
|
||||
private String Fail_missing_row(byte[] row_pkey) {
|
||||
return msg_bldr.Clear().Notify_fail_(Err_msg.To_str("Item has been deleted", "key", row_pkey)).Notify_hint_("Please reload the page").To_json_str();
|
||||
}
|
||||
private static final Dbui_col_itm[] cols = new Dbui_col_itm[]
|
||||
{ new Dbui_col_itm(Dbui_col_itm.Type_id_str , 150, "name" , "Name")
|
||||
, new Dbui_col_itm(Dbui_col_itm.Type_id_str , 300, "url" , "Url")
|
||||
, new Dbui_col_itm(Dbui_col_itm.Type_id_text , 300, "comment" , "Comment")
|
||||
};
|
||||
private static final Dbui_btn_itm[] view_btns = new Dbui_btn_itm[]
|
||||
{ new Dbui_btn_itm("rows__edit" , "edit.png" , "edit")
|
||||
, new Dbui_btn_itm("rows__delete" , "delete.png" , "delete")
|
||||
};
|
||||
private static final Dbui_btn_itm[] edit_btns = new Dbui_btn_itm[]
|
||||
{ new Dbui_btn_itm("rows__save" , "save.png" , "save")
|
||||
, new Dbui_btn_itm("rows__cancel" , "cancel.png" , "cancel")
|
||||
};
|
||||
private static final Bry_fmtr url_fmtr = Bry_fmtr.new_("<a href='/site/~{url}'>~{url}</a>", "url");
|
||||
public static Dbui_tbl_itm__bmk get_or_new(Xoa_app app, Xoud_bmk_itm_tbl db_tbl) {
|
||||
if (I == null) {
|
||||
I = new Dbui_tbl_itm__bmk(app, db_tbl);
|
||||
I.Reg(app.Html__bridge_mgr().Cmd_mgr());
|
||||
}
|
||||
return I;
|
||||
} private static Dbui_tbl_itm__bmk I;
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
/*
|
||||
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.specials.xowa.bookmarks; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*; import gplx.xowa.specials.xowa.*;
|
||||
import gplx.core.json.*; import gplx.html.*;
|
||||
import gplx.xowa.users.data.*; import gplx.xowa.users.bmks.*;
|
||||
import gplx.xowa.html.bridges.*; import gplx.xowa.html.bridges.dbuis.*; import gplx.xowa.html.bridges.dbuis.tbls.*; import gplx.xowa.html.bridges.dbuis.fmtrs.*;
|
||||
public class Dbui_tbl_itm__history implements Dbui_tbl_itm {
|
||||
private final Xoa_app app; private final Xoud_history_tbl tbl;
|
||||
private final Dbui_tbl_fmtr tbl_fmtr = new Dbui_tbl_fmtr();
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr.new_(255);
|
||||
private final Bridge_msg_bldr msg_bldr;
|
||||
public Dbui_tbl_itm__history(Xoa_app app, Xoud_history_tbl tbl) {this.app = app; this.tbl = tbl; this.msg_bldr = app.Html__bridge_mgr().Msg_bldr();}
|
||||
public byte[] Key() {return key;} private static final byte[] key = Bry_.new_a7("history");
|
||||
public Dbui_btn_itm[] View_btns() {return view_btns;}
|
||||
public Dbui_btn_itm[] Edit_btns() {return Dbui_btn_itm.Ary_empty;}
|
||||
public Dbui_col_itm[] Cols() {return cols;}
|
||||
public void Reg(Bridge_cmd_mgr bridge_mgr) {
|
||||
Dbui_cmd_mgr dbui_mgr = Dbui_cmd_mgr.I;
|
||||
dbui_mgr.Init_by_bridge(bridge_mgr);
|
||||
dbui_mgr.Add(this);
|
||||
}
|
||||
private final List_adp select_list = List_adp_.new_();
|
||||
public void Select(Bry_bfr bfr, int top) {
|
||||
tbl.Select_by_top(select_list, 100);
|
||||
Xoud_history_row[] db_rows = (Xoud_history_row[])select_list.To_ary_and_clear(Xoud_history_row.class);
|
||||
byte[] option_link = app.Html__lnki_bldr().Href_(Bry_.new_a7("home"), app.User().Wikii().Ttl_parse(Bry_.new_a7("Help:Options/PageHistory"))).Img_16x16(gplx.xowa.html.wtrs.Xoh_img_path.Img_option).Bld_to_bry();
|
||||
byte[] delete_confirm_msg = app.Api_root().Usr().Bookmarks().Delete_confirm() ? Msg__delete_confirm : Bry_.Empty;
|
||||
tbl_fmtr.Write(bfr, this, option_link, delete_confirm_msg, To_ui_rows(db_rows));
|
||||
} private static final byte[] Msg__delete_confirm = Bry_.new_a7(" data-dbui-delete_confirm_msg='Are you sure you want to delete this row?'");
|
||||
public String Del(byte[] row_id, byte[] row_pkey) {
|
||||
Xoud_history_row db_row = Get_db_row(row_pkey); if (db_row == null) return Fail_missing_row(row_pkey);
|
||||
tbl.Delete(db_row.Id());
|
||||
return msg_bldr.To_json_str__empty();
|
||||
}
|
||||
public String Edit(byte[] row_id, byte[] row_pkey) {throw Err_.new_unimplemented();}
|
||||
public String Save(byte[] row_id, byte[] row_pkey, Dbui_val_hash vals) {throw Err_.new_unimplemented();}
|
||||
public String Reorder(byte[][] pkeys, int owner) {throw Err_.new_unimplemented();}
|
||||
public Dbui_row_itm[] To_ui_rows(Xoud_history_row[] db_rows) {
|
||||
int len = db_rows.length;
|
||||
Dbui_row_itm[] rv = new Dbui_row_itm[len];
|
||||
for (int i = 0; i < len; ++i)
|
||||
rv[i] = Get_ui_row(db_rows[i]);
|
||||
return rv;
|
||||
}
|
||||
private Xoud_history_row Get_db_row(byte[] pkey) {
|
||||
int id = Bry_.To_int(pkey);
|
||||
return tbl.Select_or_null(id);
|
||||
}
|
||||
private Dbui_row_itm Get_ui_row(Xoud_history_row row) {return Get_ui_row(Int_.Xto_bry(row.Id()), row.Wiki(), row.Url(), row.Count(), row.Time());}
|
||||
private Dbui_row_itm Get_ui_row(byte[] pkey, byte[] wiki, byte[] url, int count, DateAdp time) {
|
||||
Dbui_val_itm[] vals = new Dbui_val_itm[4];
|
||||
vals[0] = new Dbui_val_itm(url, url_fmtr.Bld_bry_many(tmp_bfr, Html_utl.Escape_for_atr_val_as_bry(tmp_bfr, Byte_ascii.Apos, url)));
|
||||
vals[1] = new Dbui_val_itm(wiki, wiki);
|
||||
byte[] count_bry = Int_.Xto_bry(count);
|
||||
vals[2] = new Dbui_val_itm(count_bry, count_bry);
|
||||
byte[] time_bry = Bry_.new_u8(time.XtoStr_fmt_yyyy_MM_dd_HH_mm_ss());
|
||||
vals[3] = new Dbui_val_itm(time_bry, time_bry);
|
||||
return new Dbui_row_itm(this, pkey, vals);
|
||||
}
|
||||
private String Fail_missing_row(byte[] row_pkey) {
|
||||
return msg_bldr.Clear().Notify_fail_(Err_msg.To_str("Item has been deleted", "key", row_pkey)).Notify_hint_("Please reload the page").To_json_str();
|
||||
}
|
||||
private static final Dbui_col_itm[] cols = new Dbui_col_itm[]
|
||||
{ new Dbui_col_itm(Dbui_col_itm.Type_id_str , 300, "page" , "Page")
|
||||
, new Dbui_col_itm(Dbui_col_itm.Type_id_str , 150, "wiki" , "Wiki")
|
||||
, new Dbui_col_itm(Dbui_col_itm.Type_id_int , 80, "views" , "Views")
|
||||
, new Dbui_col_itm(Dbui_col_itm.Type_id_datetime, 100, "time" , "Time")
|
||||
};
|
||||
private static final Dbui_btn_itm[] view_btns = new Dbui_btn_itm[]
|
||||
{ new Dbui_btn_itm("rows__delete" , "delete.png" , "delete")
|
||||
};
|
||||
private static final Bry_fmtr url_fmtr = Bry_fmtr.new_("<a href='/site/~{url}'>~{url}</a>", "url");
|
||||
public static Dbui_tbl_itm__history get_or_new(Xoa_app app, Xoud_history_tbl db_tbl) {
|
||||
if (I == null) {
|
||||
I = new Dbui_tbl_itm__history(app, db_tbl);
|
||||
I.Reg(app.Html__bridge_mgr().Cmd_mgr());
|
||||
}
|
||||
return I;
|
||||
} private static Dbui_tbl_itm__history I;
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
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.specials.xowa.bookmarks; import gplx.*; import gplx.xowa.*; import gplx.xowa.specials.*; import gplx.xowa.specials.xowa.*;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.xowa.html.bridges.dbuis.tbls.*;
|
||||
import gplx.xowa.users.data.*; import gplx.xowa.users.bmks.*;
|
||||
public class Xows_bmk_page implements Xows_page {
|
||||
public Xows_special_meta Special_meta() {return Xows_special_meta_.Itm__bookmarks;}
|
||||
public void Special_gen(Xowe_wiki wiki, Xoae_page page, Xoa_url url, Xoa_ttl ttl) {
|
||||
Xoa_app app = wiki.App();
|
||||
Dbui_tbl_itm__bmk ui_tbl = Dbui_tbl_itm__bmk.get_or_new(app, app.User().User_db_mgr().Bmk_mgr().Tbl__itm());
|
||||
page.Html_data().Head_mgr().Itm__dbui().Init(app).Enabled_y_();
|
||||
Bry_bfr bfr = wiki.Utl__bfr_mkr().Get_m001();
|
||||
ui_tbl.Select(bfr, Xoud_bmk_mgr.Owner_root);
|
||||
page.Hdump_data().Body_(bfr.To_bry_and_rls());
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,7 @@ class Xows_cmd__file_check {
|
||||
int rows_len = rows.length;
|
||||
for (int i = 0; i < rows_len; ++i) {
|
||||
Object[] row = rows[i];
|
||||
int file_id = Int_.cast_(row[0]);
|
||||
int file_id = Int_.cast(row[0]);
|
||||
String sql = sql_mkr.Thm_by_id(file_id);
|
||||
Write_sect(bfr, "fsdb.thm.select", sql);
|
||||
Object[][] thm_rows = Db_rdr_utl.Load(atr_main.Conn(), sql);
|
||||
@@ -77,9 +77,9 @@ class Xows_cmd__file_check {
|
||||
int rows_len = rows.length;
|
||||
for (int i = 0; i < rows_len; ++i) {
|
||||
Object[] row = rows[i];
|
||||
int bin_db_id = Int_.cast_(row[bin_db_id_ordinal]); if (bin_db_id == -1) continue;
|
||||
int bin_db_id = Int_.cast(row[bin_db_id_ordinal]); if (bin_db_id == -1) continue;
|
||||
Fsm_bin_fil bin_db = mnt_itm.Bin_mgr().Dbs__get_at(bin_db_id);
|
||||
int owner_id = Int_.cast_(row[owner_id_ordinal]);
|
||||
int owner_id = Int_.cast(row[owner_id_ordinal]);
|
||||
String sql = sql_mkr.Bin_by_id(owner_id);
|
||||
Write_sect(bfr, "fsdb.bin.select", sql);
|
||||
Object[][] bin_rows = Db_rdr_utl.Load(bin_db.Conn(), sql);
|
||||
@@ -92,7 +92,7 @@ class Xows_cmd__file_check {
|
||||
Bry_bfr tmp_bfr = Bry_bfr.new_();
|
||||
for (int i = 0; i < rows_len; ++i) {
|
||||
Object[] row = rows[i];
|
||||
int owner_id = Int_.cast_(row[owner_id_ordinal]);
|
||||
int owner_id = Int_.cast(row[owner_id_ordinal]);
|
||||
byte[] bin_data = (byte[])row[bin_data_ordinal];
|
||||
file_bry = gplx.xowa.files.repos.Xof_repo_itm_.Ttl_invalid_fsys_chars(tmp_bfr, file_bry);
|
||||
Io_url bin_url = tmp_dir.GenSubFil(String_.new_u8(file_bry));
|
||||
|
||||
Reference in New Issue
Block a user