コード例 #1
0
ファイル: Dpl_xnde.java プロジェクト: gnosygnu/xowa_android
  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);
  }
コード例 #2
0
 public Xol_interval_itm[] Get_duration_intervals(long seconds, Xol_duration_itm[] intervals) {
   if (intervals == null) intervals = Xol_duration_itm_.Ary_default;
   Array_.Sort(intervals, Xol_duration_itm_sorter.Instance);
   int intervals_len = intervals.length;
   long val = seconds;
   List_adp rv = List_adp_.New();
   for (int i = 0; i < intervals_len; i++) {
     Xol_duration_itm itm = intervals[i];
     long itm_seconds = itm.Seconds();
     val = seconds / itm_seconds;
     if (val > 0
         || (i == intervals_len - 1
             && rv.Count()
                 == 0) // always add one seg; EX: 40 seconds, but minutes requested -> 0 minutes;
                       // DATE:2014-05-10
     ) {
       seconds -= val * itm_seconds;
       rv.Add(new Xol_interval_itm(itm, val));
     }
   }
   return (Xol_interval_itm[]) rv.To_ary(Xol_interval_itm.class);
 }
コード例 #3
0
ファイル: Pf_func_.java プロジェクト: gnosygnu/xowa_android
 public static int[] Ary_get(Xow_domain_itm domain_itm, boolean wmf) {
   if (wmf && domain_itm != null && domain_itm.Domain_type().Tid() != Xow_domain_tid_.Tid__home)
     return Ary_wmf;
   if (Ary_nonwmf == null) {
     List_adp list = List_adp_.New();
     int len = Ary_wmf.length;
     for (int i = 0; i < len; ++i) {
       list.Add(Ary_wmf[i]);
     }
     list.Add_many(
         Xol_kwd_grp_.Id_strx_len,
         Xol_kwd_grp_.Id_strx_pos,
         Xol_kwd_grp_.Id_strx_rpos,
         Xol_kwd_grp_.Id_strx_sub,
         Xol_kwd_grp_.Id_strx_count,
         Xol_kwd_grp_.Id_strx_replace,
         Xol_kwd_grp_.Id_strx_explode,
         Xol_kwd_grp_.Id_strx_urldecode,
         Xol_kwd_grp_.Id_new_window_link);
     Ary_nonwmf = (int[]) list.To_ary_and_clear(int.class);
   }
   return Ary_nonwmf;
 }
コード例 #4
0
ファイル: Dpl_xnde.java プロジェクト: gnosygnu/xowa_android
public class Dpl_xnde implements Xox_xnde {
  private Dpl_itm itm = new Dpl_itm();
  private List_adp pages = List_adp_.New();

  public void Xatr__set(
      Xowe_wiki wiki,
      byte[] src,
      Mwh_atr_itm xatr,
      Object xatr_id_obj) {} // NOTE: <dynamicPageList> has no attributes

  public void Xtn_parse(
      Xowe_wiki wiki, Xop_ctx ctx, Xop_root_tkn root, byte[] src, Xop_xnde_tkn xnde) {
    itm.Parse(wiki, ctx, ctx.Page().Ttl().Full_txt_w_ttl_case(), src, xnde);
    Dpl_page_finder.Find_pages(pages, wiki, itm);
    if (itm.Sort_ascending() != Bool_.__byte) pages.Sort_by(new Dpl_page_sorter(itm));
  }

  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();
    }
  }

  private static byte[] Bry_nofollow = Bry_.new_a7(" rel=\"nofollow\"");
}