mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
XOMW: Start XomwMessage [#632]
This commit is contained in:
parent
0d917bccc7
commit
f9cf49c160
@ -196,6 +196,7 @@ public class XophpArray implements Bry_bfr_able {
|
|||||||
itm += v;
|
itm += v;
|
||||||
this.Set(idx, itm);
|
this.Set(idx, itm);
|
||||||
}
|
}
|
||||||
|
|
||||||
public XophpArray Clone() {
|
public XophpArray Clone() {
|
||||||
XophpArray rv = new XophpArray();
|
XophpArray rv = new XophpArray();
|
||||||
int len = hash.Len();
|
int len = hash.Len();
|
||||||
@ -240,5 +241,23 @@ public class XophpArray implements Bry_bfr_able {
|
|||||||
rv.Add(val);
|
rv.Add(val);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// REF.PHP:https://www.php.net/manual/en/function.reset.php
|
||||||
|
private int internalPointerIndex = 0;
|
||||||
|
private Object internalPointerAdd(int v) {
|
||||||
|
internalPointerIndex += v;
|
||||||
|
return internalPointerGetOrNull();
|
||||||
|
}
|
||||||
|
private Object internalPointerReset() {
|
||||||
|
internalPointerIndex = 0;
|
||||||
|
return internalPointerGetOrNull();
|
||||||
|
}
|
||||||
|
private Object internalPointerGetOrNull() {return hash.Len() == 0 ? null : this.Get_at(internalPointerIndex);}
|
||||||
|
public static Object reset(XophpArray array) {return array.internalPointerReset();}
|
||||||
|
public static Object current(XophpArray array) {return array.internalPointerGetOrNull();}
|
||||||
|
public static Object next(XophpArray array) {
|
||||||
|
return array.internalPointerAdd(1);
|
||||||
|
}
|
||||||
|
|
||||||
public static final XophpArray False = null; // handles code like "if ($var === false)" where var is an Object;
|
public static final XophpArray False = null; // handles code like "if ($var === false)" where var is an Object;
|
||||||
}
|
}
|
||||||
|
@ -129,6 +129,16 @@ public class XophpArray_ {
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static XophpArray array_values(XophpArray array) {
|
||||||
|
XophpArray rv = XophpArray.New();
|
||||||
|
int len = array.count();
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
XophpArrayItm itm = array.Get_at_itm(i);
|
||||||
|
rv.Add(itm.Val());
|
||||||
|
}
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
// DEPRECATE:use XophpArray
|
// DEPRECATE:use XophpArray
|
||||||
public static boolean popBoolOrN(List_adp list) {return Bool_.Cast(List_adp_.Pop_or(list, false));}
|
public static boolean popBoolOrN(List_adp list) {return Bool_.Cast(List_adp_.Pop_or(list, false));}
|
||||||
public static byte[] popBryOrNull(List_adp list) {return (byte[])List_adp_.Pop_or(list, null);}
|
public static byte[] popBryOrNull(List_adp list) {return (byte[])List_adp_.Pop_or(list, null);}
|
||||||
@ -151,7 +161,10 @@ public class XophpArray_ {
|
|||||||
public static boolean array_key_exists(int key, Ordered_hash array) {return array.Has(key);}
|
public static boolean array_key_exists(int key, Ordered_hash array) {return array.Has(key);}
|
||||||
public static boolean array_key_exists(String key, Ordered_hash array) {return array.Has(key);}
|
public static boolean array_key_exists(String key, Ordered_hash array) {return array.Has(key);}
|
||||||
public static boolean array_key_exists(byte[] key, Ordered_hash array) {return array.Has(key);}
|
public static boolean array_key_exists(byte[] key, Ordered_hash array) {return array.Has(key);}
|
||||||
public static boolean array_is_empty(Ordered_hash array) {
|
public static boolean empty(Ordered_hash array) {
|
||||||
|
return array.Len() == 0;
|
||||||
|
}
|
||||||
|
public static boolean empty(XophpArray array) {
|
||||||
return array.Len() == 0;
|
return array.Len() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
XOWA: the XOWA Offline Wiki Application
|
XOWA: the XOWA Offline Wiki Application
|
||||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
Copyright (C) 2012-2020 gnosygnu@gmail.com
|
||||||
|
|
||||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||||
or alternatively under the terms of the Apache License Version 2.0.
|
or alternatively under the terms of the Apache License Version 2.0.
|
||||||
@ -14,5 +14,8 @@ GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
|||||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||||
*/
|
*/
|
||||||
package gplx.xowa.mediawiki; import gplx.*; import gplx.xowa.*;
|
package gplx.xowa.mediawiki; import gplx.*; import gplx.xowa.*;
|
||||||
public class XophpInvalidArgumentException extends Err { public XophpInvalidArgumentException(String text) {super(false, "", text, text);}
|
public class XophpInvalidArgumentException extends Err {
|
||||||
|
public XophpInvalidArgumentException(String fmt, Object... args) {
|
||||||
|
super(true, "", "", String_.Format(fmt, args));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ package gplx.xowa.mediawiki.includes;
|
|||||||
|
|
||||||
import gplx.Gfo_log_;
|
import gplx.Gfo_log_;
|
||||||
import gplx.xowa.mediawiki.XomwEnv;
|
import gplx.xowa.mediawiki.XomwEnv;
|
||||||
|
import gplx.xowa.mediawiki.XophpObject_;
|
||||||
import gplx.xowa.mediawiki.XophpString_;
|
import gplx.xowa.mediawiki.XophpString_;
|
||||||
|
|
||||||
// MW.SRC:1.33.1
|
// MW.SRC:1.33.1
|
||||||
@ -1283,7 +1284,7 @@ public class XomwGlobalFunctions {
|
|||||||
*
|
*
|
||||||
* @see Message::__construct
|
* @see Message::__construct
|
||||||
*/
|
*/
|
||||||
public static XomwMessage wfMessage(XomwEnv env, String key, String... params) {
|
public static XomwMessageOld wfMessageOld(XomwEnv env, String key, String... params) {
|
||||||
// $message = new Message($key);
|
// $message = new Message($key);
|
||||||
//
|
//
|
||||||
// // We call Message::params() to reduce code duplication
|
// // We call Message::params() to reduce code duplication
|
||||||
@ -1292,7 +1293,17 @@ public class XomwGlobalFunctions {
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// return $message;
|
// return $message;
|
||||||
return env.Message_mgr().Get_by_str(key);
|
return env.Message_mgr().Old_get_by_str(key);
|
||||||
|
}
|
||||||
|
public static XomwMessage wfMessage(XomwEnv env, String key, String... params) {
|
||||||
|
XomwMessage message = new XomwMessage(key);
|
||||||
|
|
||||||
|
// We call Message::params() to reduce code duplication
|
||||||
|
if (XophpObject_.is_true(params)) {
|
||||||
|
// message.params(...$params);
|
||||||
|
}
|
||||||
|
|
||||||
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
|
@ -13,7 +13,8 @@ The terms of each license can be found in the source code repository:
|
|||||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||||
*/
|
*/
|
||||||
package gplx.xowa.mediawiki.includes; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*;
|
package gplx.xowa.mediawiki.includes; import gplx.*;
|
||||||
|
import gplx.xowa.mediawiki.*;
|
||||||
import gplx.core.btries.*;
|
import gplx.core.btries.*;
|
||||||
import gplx.langs.htmls.*;
|
import gplx.langs.htmls.*;
|
||||||
import gplx.xowa.mediawiki.includes.xohtml.*; import gplx.xowa.mediawiki.includes.linkers.*; import gplx.xowa.mediawiki.includes.parsers.*;
|
import gplx.xowa.mediawiki.includes.xohtml.*; import gplx.xowa.mediawiki.includes.linkers.*; import gplx.xowa.mediawiki.includes.parsers.*;
|
||||||
@ -650,7 +651,7 @@ public class XomwLinker {
|
|||||||
, tmp_attribs.Clear()
|
, tmp_attribs.Clear()
|
||||||
.Add(Gfh_atr_.Bry__href , url)
|
.Add(Gfh_atr_.Bry__href , url)
|
||||||
.Add(Gfh_atr_.Bry__class, Class__internal)
|
.Add(Gfh_atr_.Bry__class, Class__internal)
|
||||||
.Add(Gfh_atr_.Bry__title, XomwGlobalFunctions.wfMessage(env, "thumbnail-more").text())
|
.Add(Gfh_atr_.Bry__title, XomwGlobalFunctions.wfMessageOld(env, "thumbnail-more").text())
|
||||||
, Bry_.Empty);
|
, Bry_.Empty);
|
||||||
byte[] zoom_anch = tmp.To_bry_and_clear();
|
byte[] zoom_anch = tmp.To_bry_and_clear();
|
||||||
XomwHtml.rawElement(tmp, htmlTemp, Gfh_tag_.Bry__div, tmp_attribs.Clear().Add(Gfh_atr_.Bry__class, Class__magnify), zoom_anch);
|
XomwHtml.rawElement(tmp, htmlTemp, Gfh_tag_.Bry__div, tmp_attribs.Clear().Add(Gfh_atr_.Bry__class, Class__magnify), zoom_anch);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -13,12 +13,12 @@ The terms of each license can be found in the source code repository:
|
|||||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||||
*/
|
*/
|
||||||
package gplx.xowa.mediawiki.includes; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*;
|
package gplx.xowa.mediawiki.includes; import gplx.*;
|
||||||
import gplx.xowa.mediawiki.languages.*;
|
import gplx.xowa.mediawiki.languages.*;
|
||||||
public class XomwMessageMgr {
|
public class XomwMessageMgr {
|
||||||
private final Hash_adp hash = Hash_adp_.New();
|
private final Hash_adp hash = Hash_adp_.New();
|
||||||
public void Add(String key, String val, XomwLanguage language) {
|
public void Old_add(String key, String val, XomwLanguage language) {
|
||||||
hash.Add(key, new XomwMessage(Bry_.new_u8(val), language));
|
hash.Add(key, new XomwMessageOld(Bry_.new_u8(val), language));
|
||||||
}
|
}
|
||||||
public XomwMessage Get_by_str(String key) {return (XomwMessage)hash.Get_by(key);}
|
public XomwMessageOld Old_get_by_str(String key) {return (XomwMessageOld)hash.Get_by(key);}
|
||||||
}
|
}
|
||||||
|
1416
400_xowa/src/gplx/xowa/mediawiki/includes/XomwMessageOld.java
Normal file
1416
400_xowa/src/gplx/xowa/mediawiki/includes/XomwMessageOld.java
Normal file
File diff suppressed because it is too large
Load Diff
@ -15,7 +15,6 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
|||||||
*/
|
*/
|
||||||
package gplx.xowa.mediawiki.includes; import gplx.*;
|
package gplx.xowa.mediawiki.includes; import gplx.*;
|
||||||
import gplx.xowa.mediawiki.*;
|
import gplx.xowa.mediawiki.*;
|
||||||
import gplx.xowa.mediawiki.includes.linkers.XomwLinkTarget;
|
|
||||||
import gplx.xowa.mediawiki.includes.title.*;
|
import gplx.xowa.mediawiki.includes.title.*;
|
||||||
/**
|
/**
|
||||||
* Represents a title within MediaWiki.
|
* Represents a title within MediaWiki.
|
||||||
@ -558,7 +557,7 @@ public class XomwTitleOld { // implements XomwLinkTarget
|
|||||||
* @return Title The new Object
|
* @return Title The new Object
|
||||||
*/
|
*/
|
||||||
public static XomwTitleOld newMainPage(XomwEnv env) {
|
public static XomwTitleOld newMainPage(XomwEnv env) {
|
||||||
XomwTitleOld title = XomwTitleOld.newFromText(env, XomwGlobalFunctions.wfMessage(env, "mainpage").inContentLanguage().text());
|
XomwTitleOld title = XomwTitleOld.newFromText(env, XomwGlobalFunctions.wfMessageOld(env, "mainpage").inContentLanguage().text());
|
||||||
// Don't give fatal errors if the message is broken
|
// Don't give fatal errors if the message is broken
|
||||||
if (title == null) {
|
if (title == null) {
|
||||||
title = XomwTitleOld.newFromText(env, Bry_.new_a7("Main Page"));
|
title = XomwTitleOld.newFromText(env, Bry_.new_a7("Main Page"));
|
||||||
|
@ -13,7 +13,11 @@ The terms of each license can be found in the source code repository:
|
|||||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||||
*/
|
*/
|
||||||
package gplx.xowa.mediawiki.includes.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*;
|
package gplx.xowa.mediawiki.includes.parsers; import gplx.*;
|
||||||
|
import gplx.core.primitives.Bool_obj_ref;
|
||||||
|
import gplx.core.primitives.Int_obj_ref;
|
||||||
|
import gplx.core.primitives.String_obj_ref;
|
||||||
|
import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*;
|
||||||
import gplx.core.btries.*;
|
import gplx.core.btries.*;
|
||||||
import gplx.core.net.*;
|
import gplx.core.net.*;
|
||||||
import gplx.xowa.mediawiki.includes.content.XomwContent;
|
import gplx.xowa.mediawiki.includes.content.XomwContent;
|
||||||
@ -4507,20 +4511,20 @@ Tfds.Write(nowiki, isHTML, forceRawInterwiki, isChildObj, isLocalObj, titleText,
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static XophpArray statelessFetchTemplate(XomwTitle title, XomwParser parser) { // $parser = false
|
public static XophpArray statelessFetchTemplate(XomwTitle title, XomwParser parser) { // $parser = false
|
||||||
String text = XophpString_.False;
|
String_obj_ref text = String_obj_ref.new_(XophpString_.False);
|
||||||
boolean skip = false;
|
Bool_obj_ref skip = Bool_obj_ref.n_();
|
||||||
XomwTitle finalTitle = title;
|
XomwTitle finalTitle = title;
|
||||||
XophpArray deps = XophpArray.New();
|
XophpArray deps = XophpArray.New();
|
||||||
|
|
||||||
// Loop to fetch the article, with up to 1 redirect
|
// Loop to fetch the article, with up to 1 redirect
|
||||||
for (int i = 0; i < 2 && XophpObject_.is_object(title); i++) {
|
for (int i = 0; i < 2 && XophpObject_.is_object(title); i++) {
|
||||||
// Give extensions a chance to select the revision instead
|
// Give extensions a chance to select the revision instead
|
||||||
int id = XophpInt_.False; // Assume current
|
Int_obj_ref id = Int_obj_ref.New(XophpInt_.False); // Assume current
|
||||||
// Hooks::run('BeforeParserFetchTemplateAndtitle',
|
XomwHooks.run("BeforeParserFetchTemplateAndtitle",
|
||||||
// [ parser, title, &skip, &id ]);
|
XophpArray.New(parser, title, skip, id));
|
||||||
|
|
||||||
if (skip) {
|
if (skip.Val()) {
|
||||||
text = XophpString_.False;
|
text = text.Val_(XophpString_.False);
|
||||||
deps.Add(XophpArray.New()
|
deps.Add(XophpArray.New()
|
||||||
.Add("title", title)
|
.Add("title", title)
|
||||||
.Add("page_id", title.getArticleID())
|
.Add("page_id", title.getArticleID())
|
||||||
@ -4530,8 +4534,8 @@ Tfds.Write(nowiki, isHTML, forceRawInterwiki, isChildObj, isLocalObj, titleText,
|
|||||||
}
|
}
|
||||||
// Get the revision
|
// Get the revision
|
||||||
XomwRevision rev = null;
|
XomwRevision rev = null;
|
||||||
if (XophpInt_.is_true(id)) {
|
if (XophpInt_.is_true(id.Val())) {
|
||||||
rev = XomwRevision.newFromId(id);
|
rev = XomwRevision.newFromId(id.Val());
|
||||||
} else if (XophpObject_.is_true(parser)) {
|
} else if (XophpObject_.is_true(parser)) {
|
||||||
// rev = parser.fetchCurrentRevisionOfTitle(title);
|
// rev = parser.fetchCurrentRevisionOfTitle(title);
|
||||||
} else {
|
} else {
|
||||||
@ -4539,7 +4543,7 @@ Tfds.Write(nowiki, isHTML, forceRawInterwiki, isChildObj, isLocalObj, titleText,
|
|||||||
}
|
}
|
||||||
int rev_id = XophpObject_.is_true(rev) ? rev.getId() : 0;
|
int rev_id = XophpObject_.is_true(rev) ? rev.getId() : 0;
|
||||||
// If there is no current revision, there is no page
|
// If there is no current revision, there is no page
|
||||||
if (XophpInt_.is_false(id) && !XophpObject_.is_true(rev)) {
|
if (XophpInt_.is_false(id.Val()) && !XophpObject_.is_true(rev)) {
|
||||||
// linkCache = MediaWikiServices::getInstance().getLinkCache();
|
// linkCache = MediaWikiServices::getInstance().getLinkCache();
|
||||||
// linkCache.addBadLinkObj(title);
|
// linkCache.addBadLinkObj(title);
|
||||||
}
|
}
|
||||||
@ -4559,12 +4563,12 @@ Tfds.Write(nowiki, isHTML, forceRawInterwiki, isChildObj, isLocalObj, titleText,
|
|||||||
XomwContent content;
|
XomwContent content;
|
||||||
if (XophpObject_.is_true(rev)) {
|
if (XophpObject_.is_true(rev)) {
|
||||||
content = rev.getContent();
|
content = rev.getContent();
|
||||||
text = XophpObject_.is_true(content) ? content.getWikitextForTransclusion() : null;
|
text = text.Val_(XophpObject_.is_true(content) ? content.getWikitextForTransclusion() : null);
|
||||||
|
|
||||||
// Hooks::run('ParserFetchTemplate',
|
XomwHooks.run("ParserFetchTemplate",
|
||||||
// [ parser, title, rev, &text, &deps ]);
|
XophpArray.New(parser, title, rev, text, deps)); // NOTE: was &deps
|
||||||
if (XophpString_.is_false(text) || XophpString_.is_null(text)) {
|
if (XophpString_.is_false(text.Val()) || XophpString_.is_null(text.Val())) {
|
||||||
text = XophpString_.False;
|
text = text.Val_(XophpString_.False);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (title.getNamespace() == XomwDefines.NS_MEDIAWIKI) {
|
} else if (title.getNamespace() == XomwDefines.NS_MEDIAWIKI) {
|
||||||
|
@ -91,7 +91,7 @@ class Xomw_lnki_wkr__fxt {
|
|||||||
env.File_finder_(file_finder);
|
env.File_finder_(file_finder);
|
||||||
env.Magic_word_mgr().Add(Bry_.new_u8("img_thumbnail"), Bool_.Y, Bry_.Ary("thumb"));
|
env.Magic_word_mgr().Add(Bry_.new_u8("img_thumbnail"), Bool_.Y, Bry_.Ary("thumb"));
|
||||||
env.Magic_word_mgr().Add(Bry_.new_u8("img_width"), Bool_.Y, Bry_.Ary("$1px"));
|
env.Magic_word_mgr().Add(Bry_.new_u8("img_width"), Bool_.Y, Bry_.Ary("$1px"));
|
||||||
env.Message_mgr().Add("thumbnail-more", "enlarge", env.Language());
|
env.Message_mgr().Old_add("thumbnail-more", "enlarge", env.Language());
|
||||||
parser.Init_by_wiki(wiki);
|
parser.Init_by_wiki(wiki);
|
||||||
|
|
||||||
// ctx
|
// ctx
|
||||||
|
@ -13,7 +13,8 @@ The terms of each license can be found in the source code repository:
|
|||||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||||
*/
|
*/
|
||||||
package gplx.xowa.mediawiki.includes.site; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*;
|
package gplx.xowa.mediawiki.includes.site; import gplx.*;
|
||||||
|
import gplx.xowa.mediawiki.*;
|
||||||
import gplx.xowa.mediawiki.includes.libs.*;
|
import gplx.xowa.mediawiki.includes.libs.*;
|
||||||
/**
|
/**
|
||||||
* Collection of Site objects.
|
* Collection of Site objects.
|
||||||
@ -174,7 +175,7 @@ public class XomwSiteList extends XomwGenericArrayObject { public int Len() {ret
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
@Override public boolean isEmpty() {
|
@Override public boolean isEmpty() {
|
||||||
return XophpArray_.array_is_empty(this.byGlobalId);
|
return XophpArray_.empty(this.byGlobalId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -371,6 +371,24 @@ public class XophpArray__tst {
|
|||||||
, XophpArray_.array_filter(array, callbackOwner.NewCallback("array_filter_both"), XophpArray_.ARRAY_FILTER_USE_BOTH)
|
, XophpArray_.array_filter(array, callbackOwner.NewCallback("array_filter_both"), XophpArray_.ARRAY_FILTER_USE_BOTH)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@Test public void reset() {
|
||||||
|
// PHP examples
|
||||||
|
// Example #1 reset() example
|
||||||
|
XophpArray array;
|
||||||
|
array = XophpArray.New("step one", "step two", "step three", "step four");
|
||||||
|
|
||||||
|
// by default, the pointer is on the first element
|
||||||
|
Gftest.Eq__str("step one", (String)XophpArray.current(array));
|
||||||
|
|
||||||
|
// skip two steps
|
||||||
|
XophpArray.next(array);
|
||||||
|
XophpArray.next(array);
|
||||||
|
Gftest.Eq__str("step three", (String)XophpArray.current(array));
|
||||||
|
|
||||||
|
// reset pointer, start again on step one
|
||||||
|
XophpArray.reset(array);
|
||||||
|
Gftest.Eq__str("step one", (String)XophpArray.current(array));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
class XophpArray__fxt {
|
class XophpArray__fxt {
|
||||||
public XophpArray Make() {return new XophpArray();}
|
public XophpArray Make() {return new XophpArray();}
|
||||||
|
Loading…
Reference in New Issue
Block a user