Wiki: Support curid query argument

pull/620/head
gnosygnu 7 years ago
parent aee0d2a9e0
commit a8fa783c32

@ -27,9 +27,10 @@ public class Xoa_url_ {
public static void Invalid_warn(String url) {Xoa_app_.Usr_dlg().Plog_many("", "", "invalid url; url=~{0}", url);}
public static String Main_page__home_str = gplx.xowa.wikis.domains.Xow_domain_itm_.Str__home + gplx.xowa.htmls.hrefs.Xoh_href_.Str__wiki + gplx.xowa.Xoa_page_.Main_page_str; // EX:home/wiki/Main_Page
public static final byte[]
Qarg__redirect = Bry_.new_a7("redirect")
, Qarg__redirect__no = Bry_.new_a7("no")
, Qarg__action = Bry_.new_a7("action")
, Qarg__action__edit = Bry_.new_a7("edit")
Qarg__redirect = Bry_.new_a7("redirect")
, Qarg__redirect__no = Bry_.new_a7("no")
, Qarg__action = Bry_.new_a7("action")
, Qarg__action__edit = Bry_.new_a7("edit")
, Qarg__curid = Bry_.new_a7("curid")
;
}

@ -135,6 +135,11 @@ public class Xowd_page_tbl implements Db_tbl {
return false;
}
}
public Xowd_page_itm Select_by_id_or_null(int page_id) {
Xowd_page_itm rv = new Xowd_page_itm();
boolean exists = Select_by_id(rv, page_id);
return exists ? rv : null;
}
public boolean Select_by_id(Xowd_page_itm rv, int page_id) {
if (stmt_select_all_by_id == null) stmt_select_all_by_id = conn.Stmt_select(tbl_name, flds_select_all, fld_id);
Db_rdr rdr = stmt_select_all_by_id.Clear().Crt_int(fld_id, page_id).Exec_select__rls_manual();

@ -16,22 +16,46 @@ 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.wikis.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import gplx.core.net.qargs.*;
import gplx.xowa.guis.views.*;
import gplx.xowa.addons.wikis.pages.syncs.core.*;
import gplx.xowa.wikis.data.tbls.*;
public class Xowe_page_mgr {
private final Xowe_wiki wiki;
private final Bry_bfr tmp_bfr = Bry_bfr_.New();
private final Xosync_read_mgr read_mgr = new Xosync_read_mgr();
private final Bry_bfr tmp_bfr = Bry_bfr_.New();
private final Gfo_qarg_mgr tmp_qarg_mgr = new Gfo_qarg_mgr();
public Xowe_page_mgr(Xowe_wiki wiki) {this.wiki = wiki;}
public Xosync_read_mgr Sync_mgr() {return read_mgr;}
public void Init_by_wiki(Xowe_wiki wiki) {
read_mgr.Init_by_wiki(wiki);
}
public Xoae_page Load_page(Xoa_url url, Xoa_ttl ttl, Xog_tab_itm tab) {
public Xoae_page Load_page(Xoa_url url, Xoa_ttl ttl, Xog_tab_itm tab) { // NOTE: called by GUI and HTTP_SERVER; not called by MASS_PARSE
Xoa_app_.Usr_dlg().Log_many("", "", "page.load: url=~{0}", url.To_str());
Wait_for_popups(wiki.App());
Xowe_wiki_.Rls_mem_if_needed(wiki);
// handle curid query_arg; EX:en.wikipedia.org/wiki/?curid=303 DATE:2017-02-15
Gfo_qarg_itm[] qarg_ary = url.Qargs_ary();
// if qargs exist...
if (qarg_ary.length > 0) {
tmp_qarg_mgr.Init(qarg_ary);
byte[] curid_bry = tmp_qarg_mgr.Read_bry_or(Xoa_url_.Qarg__curid, null);
// if "curid" qarg exists....
if (curid_bry != null) {
int curid = Bry_.To_int_or(curid_bry, -1);
Xowd_page_itm tmp_page = wiki.Data__core_mgr().Db__core().Tbl__page().Select_by_id_or_null(curid);
// if curid exists in db...
if (tmp_page != null) {
ttl = wiki.Ttl_parse(tmp_page.Ns_id(), tmp_page.Ttl_page_db());
// handle "home/wiki/?curid=123"; XO automatically changes to "home/wiki/Main_Page?curid=123"; change back to "home/wiki/?curid=123"
if (url.Page_is_main()) {
url.Page_bry_(Bry_.Empty);
}
}
}
}
// load page meta; wait_for_popups
Xoae_page page = wiki.Data_mgr().Load_page_and_parse(url, ttl, wiki.Lang(), tab, false);
ttl = page.Ttl(); // note that Load_page_and_parse can redirect ttl; EX: Special:Random -> A; DATE:2017-01-05

Loading…
Cancel
Save