Exemple #1
0
 public static boolean Eq(
     Xop_ctx ctx,
     byte[] lhs,
     byte[]
         rhs) { // PATCH.PHP: php allows "003" == "3.0"; ASSUME: numbers are either int or int-like
   // decimal; long, float, decimal not supported
   int lhs_len = lhs.length, rhs_len = rhs.length;
   boolean rv = true;
   if (lhs_len == rhs_len) {
     for (int i = 0; i < lhs_len; i++) {
       if (lhs[i] != rhs[i]) {
         rv = false;
         break;
       }
     }
     if (rv) return true;
   } else if (lhs_len == 0
       || rhs_len == 0) // one side is empty String and the other side is String; return false;
   return false;
   Gfo_number_parser lhs_parser = ctx.Tmp_mgr().Pfunc_num_parser_0();
   Gfo_number_parser rhs_parser = ctx.Tmp_mgr().Pfunc_num_parser_1();
   lhs_parser.Parse(lhs, 0, lhs_len);
   if (lhs_parser.Has_err()) return false;
   rhs_parser.Parse(rhs, 0, rhs_len);
   if (rhs_parser.Has_err()) return false;
   return lhs_parser.Has_frac() || rhs_parser.Has_frac()
       ? lhs_parser.Rv_as_dec().Eq(rhs_parser.Rv_as_dec())
       : lhs_parser.Rv_as_int() == rhs_parser.Rv_as_int();
 }
 public void Write_hdump(Bry_bfr bfr, Xop_ctx ctx, Xoh_wtr_ctx hctx, Xoae_page wpg) {
   if (wpg.Html_data().Xtn_pgbnr() != null) {
     ctx.Wiki()
         .Xtn_mgr()
         .Xtn_pgbnr()
         .Write_html(wpg, ctx, hctx)
         .Bfr_arg__add(bfr); // if pgbnr exists, write to top of html
   }
   this.Write_body(bfr, ctx, hctx, wpg);
 }
 public byte[] Format_durations(Xop_ctx ctx, long seconds, Xol_duration_itm[] ary) {
   if (interval_msgs == null) Format_durations_init();
   Xol_interval_itm[] intervals = Get_duration_intervals(seconds, ary);
   int intervals_len = intervals.length;
   byte[][] msgs_ary = new byte[intervals_len][];
   for (int i = 0; i < intervals_len; i++) {
     Xol_interval_itm interval = intervals[i];
     Xol_msg_itm msg_itm = interval_msgs[interval.Duration_itm().Tid()];
     byte[] msg_bry = msg_itm.Fmt(tmp_bfr, tmp_fmtr, interval.Val());
     msg_bry = ctx.Wiki().Parser_mgr().Main().Parse_text_to_html(ctx, msg_bry);
     msgs_ary[i] = msg_bry;
   }
   return List_to_str(msgs_ary);
 }
 public void Write_page(Bry_bfr rv, Xoae_page page, Xop_ctx ctx) {
   synchronized (thread_lock_1) {
     this.page = page;
     this.wiki = page.Wikie();
     this.app = wiki.Appe();
     ctx.Page_(page); // HACK: must update page for toc_mgr; WHEN: Xoae_page rewrite
     Bry_fmtr fmtr = null;
     if (mgr.Html_capable()) {
       wdata_lang_wtr.Page_(page);
       byte view_mode = page_mode;
       switch (page_mode) {
         case Xopg_page_.Tid_edit:
           fmtr = mgr.Page_edit_fmtr();
           break;
         case Xopg_page_.Tid_html:
           fmtr = mgr.Page_read_fmtr();
           view_mode = Xopg_page_.Tid_read;
           break; // set view_mode to read, so that "read" is highlighted in HTML
         case Xopg_page_.Tid_read:
           fmtr = mgr.Page_read_fmtr();
           // ctx.Page().Redlink_list().Clear();	// not sure if this is the best place to put it,
           // but redlinks (a) must only fire once; (b) must fire before html generation; (c)
           // cannot fire during edit (preview will handle separately); NOTE: probably put in to
           // handle reusable redlink lists; redlink lists are now instantiated per page, so clear
           // is not useful
           break;
       }
       Bry_bfr page_bfr =
           wiki.Utl__bfr_mkr()
               .Get_m001(); // NOTE: get separate page rv to output page; do not reuse tmp_bfr b/c
                            // it will be used inside Fmt_do
       Xoh_wtr_ctx hctx = null;
       if (page_mode == Xopg_page_.Tid_html
           && wiki.App().Api_root().Wiki().Hdump().Html_mode().Tid_is_hdump_save()) {
         hctx = Xoh_wtr_ctx.Hdump;
         Write_body(page_bfr, ctx, hctx, page);
         Write_page_by_tid(
             ctx,
             hctx,
             page_mode,
             rv,
             mgr.Page_html_fmtr(),
             Gfh_utl.Escape_html_as_bry(page_bfr.To_bry_and_clear()));
       } else {
         hctx = Xoh_wtr_ctx.Basic;
         Write_body(page_bfr, ctx, hctx, page);
         Write_page_by_tid(ctx, hctx, view_mode, rv, fmtr, page_bfr.To_bry_and_rls());
         new gplx.xowa.addons.apps.scripts.Xoscript_mgr().Write(rv, wiki, page);
         if (page_mode
             == Xopg_page_
                 .Tid_html) // if html, write page again, but wrap it in html skin this time
         Write_page_by_tid(
               ctx,
               hctx,
               page_mode,
               rv,
               mgr.Page_html_fmtr(),
               Gfh_utl.Escape_html_as_bry(rv.To_bry_and_clear()));
         wdata_lang_wtr.Page_(null);
       }
     } else Write_body(rv, ctx, Xoh_wtr_ctx.Basic, page);
     this.page = null;
   }
 }