private static void Find_pages_in_ctg( Ordered_hash rv, Xowe_wiki wiki, Xodb_load_mgr load_mgr, Xowd_page_itm tmp_page, Int_obj_ref tmp_id, byte[] ctg_ttl) { Xoctg_catpage_ctg ctg = wiki.Ctg__catpage_mgr() .Get_or_load_or_null( Xoctg_catpage_url.New__blank(), wiki.Ttl_parse(gplx.xowa.wikis.nss.Xow_ns_.Tid__category, ctg_ttl), -1); if (ctg == null) return; // loop grps to get grp for (byte ctg_tid = 0; ctg_tid < Xoa_ctg_mgr.Tid___max; ++ctg_tid) { Xoctg_catpage_grp ctg_grp = ctg.Grp_by_tid(ctg_tid); int itms_len = ctg_grp.Itms__len(); // loop itms in grp and add to hash for (int i = 0; i < itms_len; ++i) { Xoctg_catpage_itm ctg_itm = ctg_grp.Itms__get_at(i); int itm_page_id = ctg_itm.Page_id(); if (rv.Has(tmp_id.Val_(itm_page_id))) continue; rv.Add(Int_obj_ref.New(itm_page_id), ctg_itm); // DELETE: recurse subcategories; PAGE:en.b:XML DATE:2016-09-18 // if (ctg_tid == Xoa_ctg_mgr.Tid__subc) { // load_mgr.Load_by_id(tmp_page, itm_page_id); // Find_pages_in_ctg(rv, wiki, load_mgr, tmp_page, tmp_id, tmp_page.Ttl_page_db()); // } } } }
public void Test_category_v2(String ctg_name_str, int... expd) { Xowe_wiki wiki = bldr_fxt.Wiki(); byte[] ctg_name_bry = Bry_.new_a7(ctg_name_str); Xoctg_data_ctg ctg = new Xoctg_data_ctg(ctg_name_bry); wiki.Db_mgr_as_sql().Load_mgr().Load_ctg_v2(ctg, ctg_name_bry); Tfds.Eq_ary(expd, Xto_int_ary(ctg)); }
public static void Find_pages(List_adp rv, Xowe_wiki wiki, Dpl_itm itm) { rv.Clear(); List_adp includes = itm.Ctg_includes(); if (includes == null) return; int includes_len = includes.Count(); Ordered_hash old_regy = Ordered_hash_.New(), new_regy = Ordered_hash_.New(), cur_regy = Ordered_hash_.New(); Xodb_load_mgr load_mgr = wiki.Db_mgr().Load_mgr(); Xowd_page_itm tmp_page = new Xowd_page_itm(); Int_obj_ref tmp_id = Int_obj_ref.New_zero(); List_adp del_list = List_adp_.New(); int ns_filter = itm.Ns_filter(); Ordered_hash exclude_pages = Ordered_hash_.New(); Find_excludes(exclude_pages, wiki, load_mgr, tmp_page, tmp_id, itm.Ctg_excludes()); for (int i = 0; i < includes_len; i++) { // loop over includes byte[] include = (byte[]) includes.Get_at(i); cur_regy.Clear(); del_list.Clear(); Find_pages_in_ctg(cur_regy, wiki, load_mgr, tmp_page, tmp_id, include); Del_old_pages_not_in_cur(i, tmp_id, old_regy, cur_regy, del_list); Add_cur_pages_also_in_old(i, tmp_id, old_regy, cur_regy, new_regy, exclude_pages, ns_filter); old_regy = new_regy; new_regy = Ordered_hash_.New(); } int pages_len = old_regy.Count(); for (int i = 0; i < pages_len; i++) { // loop over old and create pages Int_obj_ref old_id = (Int_obj_ref) old_regy.Get_at(i); rv.Add(new Xowd_page_itm().Id_(old_id.Val())); } wiki.Db_mgr().Load_mgr().Load_by_ids(Cancelable_.Never, rv, 0, pages_len); rv.Sort_by(Xowd_page_itm_sorter.IdAsc); }
public void Test_search(String search_word_str, int... expd) { Xowe_wiki wiki = bldr_fxt.Wiki(); List_adp rv = List_adp_.new_(); byte[] search_word_bry = Bry_.new_a7(search_word_str); wiki.Db_mgr_as_sql().Load_mgr().Load_search(Cancelable_.Never, rv, search_word_bry, 100); Tfds.Eq_ary(expd, Xto_int_ary(rv)); }
public void Init_db_sqlite() { Xowe_wiki wiki = this.Wiki(); Db_conn_pool.I.Clear(); Db_conn_bldr.I.Reg_default_sqlite(); Io_mgr.I.DeleteDir_cmd(wiki.Fsys_mgr().Root_dir()).MissingIgnored_().Exec(); wiki.Db_mgr_create_as_sql() .Core_data_mgr() .Init_by_make(Xowd_core_db_props.Test, Xob_info_session.Test); Io_mgr.I.SaveFilStr(wiki.Import_cfg().Src_dir().GenSubFil("a.xml"), "<test/>"); }
public void Test_load_ttl(int ns_id, String ttl_str, Xowd_page_itm expd) { Xowe_wiki wiki = bldr_fxt.Wiki(); Xow_ns ns = wiki.Ns_mgr().Ids_get_or_null(ns_id); byte[] ttl_bry = Bry_.new_a7(ttl_str); wiki.Db_mgr_as_sql().Load_mgr().Load_by_ttl(actl, ns, ttl_bry); Tfds.Eq(expd.Id(), actl.Id()); Tfds.Eq_date(expd.Modified_on(), actl.Modified_on()); Tfds.Eq(expd.Redirected(), actl.Redirected()); Tfds.Eq(expd.Text_len(), actl.Text_len()); }
public Xobldr__fsdb_db__create_data(Xob_bldr bldr, Xowe_wiki wiki) { super(bldr, wiki); if (bldr != null) { this.poll_mgr = new Xobu_poll_mgr(bldr.App()); wiki.File__fsdb_mode().Tid__v2__bld__y_(); this.src_bin_mgr = new Xof_bin_mgr( new Fsm_mnt_mgr(), wiki.File__repo_mgr(), app.File__img_mgr().Wkr_resize_img(), app.Wmf_mgr().Download_wkr().Download_xrg().Download_fmt()); } }
public void Init_page_insert(Int_obj_ref page_id_next, int ns_id, String[] ttls) { Xowe_wiki wiki = this.Wiki(); int len = ttls.length; DateAdp modified_on = Tfds.Now_time0_add_min(0); Xowd_page_tbl tbl_page = wiki.Db_mgr_as_sql().Core_data_mgr().Tbl__page(); tbl_page.Insert_bgn(); for (int i = 0; i < len; i++) { String ttl = ttls[i]; int page_id = page_id_next.Val(); tbl_page.Insert_cmd_by_batch( page_id, ns_id, Bry_.new_u8(ttl), false, modified_on, 0, page_id, 0, 0); page_id_next.Val_add(1); } tbl_page.Insert_end(); }
public void Xtn_write( Bry_bfr bfr, Xoae_app app, Xop_ctx ctx, Xoh_html_wtr html_wtr, Xoh_wtr_ctx hctx, Xoae_page wpg, Xop_xnde_tkn xnde, byte[] src) { Xowe_wiki wiki = ctx.Wiki(); Dpl_html_data html_mode = Dpl_html_data.new_(Dpl_itm_keys.Key_unordered); int itms_len = pages.Count(); if (itms_len == 0) { if (!itm.Suppress_errors()) bfr.Add_str_a7("No pages meet these criteria."); return; } int itms_bgn = 0; if (itm.Offset() != Int_.Min_value) { itms_bgn = itm.Offset(); } if (itm.Count() != Int_.Min_value && itms_bgn + itm.Count() < itms_len) { itms_len = itms_bgn + itm.Count(); } boolean show_ns = itm.Show_ns(); Bry_bfr tmp_bfr = Bry_bfr_.Get(); Xop_amp_mgr amp_mgr = wiki.Appe().Parser_amp_mgr(); try { bfr.Add(html_mode.Grp_bgn()).Add_byte_nl(); for (int i = itms_bgn; i < itms_len; i++) { Xowd_page_itm page = (Xowd_page_itm) pages.Get_at(i); Xoa_ttl ttl = Xoa_ttl.Parse(wiki, page.Ns_id(), page.Ttl_page_db()); byte[] ttl_page_txt = show_ns ? ttl.Full_txt_w_ttl_case() : ttl.Page_txt(); if (ttl_page_txt == null) continue; // NOTE: apparently DynamicPageList allows null pages; DATE:2013-07-22 switch (html_mode.Tid()) { case Dpl_html_data.Tid_list_ul: case Dpl_html_data.Tid_list_ol: bfr.Add(Xoh_consts.Space_2).Add(html_mode.Itm_bgn()).Add(Gfh_bldr_.Bry__a_lhs_w_href); bfr.Add_str_a7("/wiki/") .Add(Gfo_url_encoder_.Href.Encode(ttl.Full_db())) .Add_byte_quote(); // NOTE: Full_db to encode spaces as underscores; // PAGE:en.q:Wikiquote:Speedy_deletions DATE:2016-01-19 Gfh_atr_.Add( bfr, Gfh_atr_.Bry__title, Xoh_html_wtr_escaper.Escape( amp_mgr, tmp_bfr, ttl .Full_txt_w_ttl_case())); // NOTE: Full_txt b/c title always includes ns, // even if show_ns is off; // PAGE:en.b:Wikibooks:WikiProject DATE:2016-01-20 if (itm.No_follow()) bfr.Add(Bry_nofollow); bfr.Add_byte(Byte_ascii.Gt); Xoh_html_wtr_escaper.Escape( amp_mgr, bfr, ttl_page_txt, 0, ttl_page_txt.length, false, false); bfr.Add(Gfh_bldr_.Bry__a_rhs).Add(html_mode.Itm_end()).Add_byte_nl(); // TODO_OLD: // lnki_wtr.Clear().Href_wiki_(ttl).Title_(ttl).Nofollow_().Write_head(bfr).Write_text(bfr).Write_tail(bfr) break; default: break; } } bfr.Add(html_mode.Grp_end()).Add_byte_nl(); } finally { tmp_bfr.Mkr_rls(); } }
public void Test_load_page(int ns_id, int page_id, String expd) { Xowe_wiki wiki = bldr_fxt.Wiki(); Xow_ns ns = wiki.Ns_mgr().Ids_get_or_null(ns_id); wiki.Db_mgr_as_sql().Load_mgr().Load_page(actl.Id_(page_id), ns, false); Tfds.Eq(expd, String_.new_a7(actl.Text())); }