Mw_parse: Refactor Xomw_ThumbnailImage

pull/620/head
gnosygnu 8 years ago
parent 906bcdc6fe
commit ff7952447d

@ -33,7 +33,7 @@ public class Xoa_app_ {
} }
public static final String Name = "xowa"; public static final String Name = "xowa";
public static final int Version_id = 514; public static final int Version_id = 514;
public static final String Version = "4.1.1.1702"; // RELEASE:2017-01-03 20:30 public static final String Version = "4.1.2.1702"; // RELEASE:2017-01-03 20:30
public static String Build_date = "2012-12-30 00:00:00"; public static String Build_date = "2012-12-30 00:00:00";
public static String Build_date_fmt = "yyyy-MM-dd HH:mm:ss"; public static String Build_date_fmt = "yyyy-MM-dd HH:mm:ss";
public static String Op_sys_str; public static String Op_sys_str;

@ -21,7 +21,7 @@ import gplx.langs.htmls.*;
import gplx.xowa.mws.htmls.*; import gplx.xowa.mws.linkers.*; import gplx.xowa.mws.parsers.*; import gplx.xowa.mws.htmls.*; import gplx.xowa.mws.linkers.*; import gplx.xowa.mws.parsers.*;
import gplx.xowa.mws.filerepo.file.*; import gplx.xowa.mws.media.*; import gplx.xowa.mws.filerepo.file.*; import gplx.xowa.mws.media.*;
import gplx.xowa.mws.parsers.lnkis.*; import gplx.xowa.mws.parsers.lnkis.*;
import gplx.langs.phps.utls.*; import gplx.xowa.mws.utls.*;
/* TODO.XO /* TODO.XO
* P8: wfMessage * P8: wfMessage
* P7: titleFormatter->getPrefixedText * P7: titleFormatter->getPrefixedText
@ -123,8 +123,8 @@ public class Xomw_linker {
postfix = Gfh_tag_.Div_rhs; postfix = Gfh_tag_.Div_rhs;
frame_params.align = Align__frame__none; frame_params.align = Align__frame__none;
} }
if (file != null && handler_params.width == Xomw_param_itm.Null_int) { if (file != null && handler_params.width == Php_utl_.Null_int) {
if (handler_params.height != Xomw_param_itm.Null_int && file.isVectorized()) { if (handler_params.height != Php_utl_.Null_int && file.isVectorized()) {
// If its a vector image, and user only specifies height // If its a vector image, and user only specifies height
// we don't want it to be limited by its "normal" width. // we don't want it to be limited by its "normal" width.
// global $wgSVGMaxSize; // global $wgSVGMaxSize;
@ -138,7 +138,7 @@ public class Xomw_linker {
|| frame_params.manual_thumb != null || frame_params.manual_thumb != null
|| frame_params.framed != null || frame_params.framed != null
|| frame_params.frameless != null || frame_params.frameless != null
|| handler_params.width == Xomw_param_itm.Null_int || handler_params.width == Php_utl_.Null_int
) { ) {
// global $wgThumbLimits, $wgThumbUpright; // global $wgThumbLimits, $wgThumbUpright;
@ -161,7 +161,7 @@ public class Xomw_linker {
// Use width which is smaller: real image width or user preference width // Use width which is smaller: real image width or user preference width
// Unless image is scalable vector. // Unless image is scalable vector.
if (handler_params.height == Xomw_param_itm.Null_int && handler_params.width <= 0 || if (handler_params.height == Php_utl_.Null_int && handler_params.width <= 0 ||
pref_width < handler_params.width || file.isVectorized()) { pref_width < handler_params.width || file.isVectorized()) {
handler_params.width = pref_width; handler_params.width = pref_width;
} }
@ -190,13 +190,13 @@ public class Xomw_linker {
// For "frameless" option: do not present an image bigger than the // For "frameless" option: do not present an image bigger than the
// source (for bitmap-style images). This is the same behavior as the // source (for bitmap-style images). This is the same behavior as the
// "thumb" option does it already. // "thumb" option does it already.
if (src_width != Xomw_param_itm.Null_int && !file.mustRender() && handler_params.width > src_width) { if (src_width != Php_utl_.Null_int && !file.mustRender() && handler_params.width > src_width) {
handler_params.width = src_width; handler_params.width = src_width;
} }
} }
Xomw_MediaTransformOutput thumb = null; Xomw_MediaTransformOutput thumb = null;
if (file != null && handler_params.width != Xomw_param_itm.Null_int) { if (file != null && handler_params.width != Php_utl_.Null_int) {
// Create a resized image, without the additional thumbnail features // Create a resized image, without the additional thumbnail features
thumb = file.transform(handler_params); thumb = file.transform(handler_params);
} }
@ -221,7 +221,7 @@ public class Xomw_linker {
} }
// $params = self::getImageLinkMTOParams(frame_params, $query, $parser) + $params; // $params = self::getImageLinkMTOParams(frame_params, $query, $parser) + $params;
thumb.To_html(tmp, tmp_2, params_list); thumb.toHtml(tmp, tmp_2, params_list);
s = tmp.To_bry_and_clear(); s = tmp.To_bry_and_clear();
} }
if (frame_params.align != Bry_.Empty) { if (frame_params.align != Bry_.Empty) {
@ -247,9 +247,9 @@ public class Xomw_linker {
// @return array // @return array
// XO.MW:SYNC:1.29; DATE:2017-02-03 // XO.MW:SYNC:1.29; DATE:2017-02-03
public void Get_image_link_mto_params(Xomw_MediaTransformOutputParams mto_params, Xomw_params_frame frame_params, byte[] query, Xomw_parser parser) { public void Get_image_link_mto_params(Xomw_MediaTransformOutputParams mto_params, Xomw_params_frame frame_params, byte[] query, Xomw_parser parser) {
if (Php_utl_.Is_set(frame_params.link_url) && frame_params.link_url != Bry_.Empty) { if (Php_utl_.isset(frame_params.link_url) && frame_params.link_url != Bry_.Empty) {
mto_params.custom_url_link = frame_params.link_url; mto_params.custom_url_link = frame_params.link_url;
if (Php_utl_.Is_set(frame_params.link_target)) { if (Php_utl_.isset(frame_params.link_target)) {
mto_params.custom_target_link = frame_params.link_target; mto_params.custom_target_link = frame_params.link_target;
} }
if (parser != null) { if (parser != null) {
@ -260,7 +260,7 @@ public class Xomw_linker {
// } // }
} }
} }
else if (Php_utl_.Is_set(frame_params.link_title) && frame_params.link_title != Bry_.Empty) { else if (Php_utl_.isset(frame_params.link_title) && frame_params.link_title != Bry_.Empty) {
// mto_params.custom_title_link = Title::newFromLinkTarget(Normalize_speecial_page(frame_params.link_title)); // mto_params.custom_title_link = Title::newFromLinkTarget(Normalize_speecial_page(frame_params.link_title));
} }
else if (!Php_utl_.Empty(frame_params.no_link)) { else if (!Php_utl_.Empty(frame_params.no_link)) {
@ -289,9 +289,9 @@ public class Xomw_linker {
frame_params.caption = Bry_.Empty; frame_params.caption = Bry_.Empty;
} }
if (handler_params.width == Xomw_param_itm.Null_int) { if (handler_params.width == Php_utl_.Null_int) {
// Reduce width for upright images when parameter 'upright' is used // Reduce width for upright images when parameter 'upright' is used
handler_params.width = frame_params.upright != Xomw_param_itm.Null_int ? 130 : 180; handler_params.width = frame_params.upright != Php_utl_.Null_int ? 130 : 180;
} }
boolean no_scale = false; boolean no_scale = false;
boolean manual_thumb = false; boolean manual_thumb = false;
@ -318,14 +318,14 @@ public class Xomw_linker {
else if (frame_params.framed != null) { else if (frame_params.framed != null) {
// Use image dimensions, don't scale // Use image dimensions, don't scale
// thumb = $file->getUnscaledThumb(handler_params); // thumb = $file->getUnscaledThumb(handler_params);
thumb = new Xomw_MediaTransformOutput(file, file.getUrl(), file.getUrl(), file.getWidth(), file.getHeight()); thumb = new Xomw_ThumbnailImage(file, file.getUrl(), file.getUrl(), file.getWidth(), file.getHeight());
no_scale = true; no_scale = true;
} }
else { else {
// Do not present an image bigger than the source, for bitmap-style images // Do not present an image bigger than the source, for bitmap-style images
// This is a hack to maintain compatibility with arbitrary pre-1.10 behavior // This is a hack to maintain compatibility with arbitrary pre-1.10 behavior
int src_width = file.getWidth(page); int src_width = file.getWidth(page);
if (src_width != Xomw_param_itm.Null_int && !file.mustRender() && handler_params.width > src_width) { if (src_width != Php_utl_.Null_int && !file.mustRender() && handler_params.width > src_width) {
handler_params.width = src_width; handler_params.width = src_width;
} }
// thumb = $file->transform(handler_params); // thumb = $file->transform(handler_params);
@ -378,7 +378,7 @@ public class Xomw_linker {
mto_params.title = frame_params.title; mto_params.title = frame_params.title;
mto_params.img_cls = Xomw_params_frame.Cls_add(frame_params.cls, Img_class__thumbimage); mto_params.img_cls = Xomw_params_frame.Cls_add(frame_params.cls, Img_class__thumbimage);
Get_image_link_mto_params(mto_params, frame_params, query, null); Get_image_link_mto_params(mto_params, frame_params, query, null);
thumb.To_html(bfr, tmp, mto_params); thumb.toHtml(bfr, tmp, mto_params);
if (frame_params.framed != null) { if (frame_params.framed != null) {
zoom_icon = Bry_.Empty; zoom_icon = Bry_.Empty;
} }

@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.mws; import gplx.*; import gplx.xowa.*; package gplx.xowa.mws; import gplx.*; import gplx.xowa.*;
import gplx.core.brys.*; import gplx.core.btries.*; import gplx.core.encoders.*; import gplx.core.primitives.*; import gplx.langs.htmls.entitys.*; import gplx.core.brys.*; import gplx.core.btries.*; import gplx.core.encoders.*; import gplx.core.primitives.*; import gplx.langs.htmls.entitys.*;
import gplx.xowa.parsers.htmls.*; import gplx.xowa.parsers.htmls.*;
import gplx.langs.htmls.*; import gplx.xowa.mws.htmls.*; import gplx.xowa.mws.parsers.*; import gplx.langs.phps.utls.*; import gplx.langs.htmls.*; import gplx.xowa.mws.htmls.*; import gplx.xowa.mws.parsers.*; import gplx.xowa.mws.utls.*;
public class Xomw_sanitizer { public class Xomw_sanitizer {
private final Mwh_doc_wkr__atr_bldr atr_bldr = new Mwh_doc_wkr__atr_bldr(); private final Mwh_doc_wkr__atr_bldr atr_bldr = new Mwh_doc_wkr__atr_bldr();
private final Mwh_atr_parser atr_parser = new Mwh_atr_parser(); private final Mwh_atr_parser atr_parser = new Mwh_atr_parser();

@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa.mws.filerepo; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; package gplx.xowa.mws.filerepo; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*;
import gplx.xowa.mws.filerepo.file.*; import gplx.xowa.mws.filerepo.file.*;
import gplx.langs.phps.utls.*; import gplx.xowa.mws.utls.*;
/* TODO.XO: /* TODO.XO:
* getZoneUrl * getZoneUrl
*/ */

@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa.mws.filerepo.file; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; import gplx.xowa.mws.filerepo.*; package gplx.xowa.mws.filerepo.file; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; import gplx.xowa.mws.filerepo.*;
import gplx.xowa.mws.media.*; import gplx.xowa.mws.media.*;
import gplx.langs.phps.utls.*; import gplx.xowa.mws.utls.*;
import gplx.xowa.mws.parsers.*; import gplx.xowa.mws.parsers.lnkis.*; import gplx.xowa.mws.parsers.*; import gplx.xowa.mws.parsers.lnkis.*;
public class Xomw_File { public class Xomw_File {
/* TODO.XO: /* TODO.XO:
@ -281,7 +281,7 @@ public class Xomw_File {
* @return String * @return String
*/ */
public byte[] getName() { public byte[] getName() {
if (!Php_utl_.Is_set(this.name)) { if (!Php_utl_.isset(this.name)) {
// this.assertRepoDefined(); // this.assertRepoDefined();
this.name = this.repo.getNameFromTitle(this.title); this.name = this.repo.getNameFromTitle(this.title);
} }
@ -295,7 +295,7 @@ public class Xomw_File {
* @return String * @return String
*/ */
private byte[] getExtension() { private byte[] getExtension() {
if (!Php_utl_.Is_set(this.extension)) { if (!Php_utl_.isset(this.extension)) {
int n = Php_str_.Strpos(this.getName(), Byte_ascii.Dot); int n = Php_str_.Strpos(this.getName(), Byte_ascii.Dot);
this.extension = normalizeExtension( this.extension = normalizeExtension(
n != Bry_find_.Not_found ? Php_str_.Substr(this.getName(), n + 1) : Bry_.Empty); n != Bry_find_.Not_found ? Php_str_.Substr(this.getName(), n + 1) : Bry_.Empty);
@ -332,7 +332,7 @@ public class Xomw_File {
* @return String * @return String
*/ */
public byte[] getUrl() { public byte[] getUrl() {
if (!Php_utl_.Is_set(this.url)) { if (!Php_utl_.isset(this.url)) {
// this.assertRepoDefined(); // this.assertRepoDefined();
byte[] ext = this.getExtension(); byte[] ext = this.getExtension();
this.url = Bry_.Add(this.repo.getZoneUrl(Xomw_FileRepo.Zone__public, ext), Byte_ascii.Slash_bry, this.getUrlRel()); this.url = Bry_.Add(this.repo.getZoneUrl(Xomw_FileRepo.Zone__public, ext), Byte_ascii.Slash_bry, this.getUrlRel());
@ -1499,7 +1499,7 @@ public class Xomw_File {
* @return String * @return String
*/ */
private byte[] getHashPath() { private byte[] getHashPath() {
if (!Php_utl_.Is_set(this.hashPath)) { if (!Php_utl_.isset(this.hashPath)) {
// this.assertRepoDefined(); // this.assertRepoDefined();
this.hashPath = this.repo.getHashPath(this.getName()); this.hashPath = this.repo.getHashPath(this.getName());
} }

@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa.mws.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; package gplx.xowa.mws.htmls; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*;
import gplx.core.btries.*; import gplx.core.btries.*;
import gplx.langs.phps.utls.*; import gplx.xowa.mws.utls.*;
public class Xomw_html_utl { public class Xomw_html_utl {
private final Bry_bfr tmp = Bry_bfr_.New(); private final Bry_bfr tmp = Bry_bfr_.New();
private final Btrie_rv trv = new Btrie_rv(); private final Btrie_rv trv = new Btrie_rv();

@ -17,7 +17,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa.mws.media; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; package gplx.xowa.mws.media; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*;
import gplx.xowa.mws.filerepo.file.*; import gplx.xowa.mws.parsers.lnkis.*; import gplx.xowa.mws.filerepo.file.*; import gplx.xowa.mws.parsers.lnkis.*;
import gplx.langs.phps.utls.*; import gplx.xowa.mws.utls.*;
/* XO.TODO:
* parseParamString
* fitBoxWidth
* scaleHeight
* validateThumbParams
*/
// MEMORY:only one instance per wiki // MEMORY:only one instance per wiki
public abstract class Xomw_ImageHandler extends Xomw_MediaHandler { private final Xomw_param_map paramMap = new Xomw_param_map(); public abstract class Xomw_ImageHandler extends Xomw_MediaHandler { private final Xomw_param_map paramMap = new Xomw_param_map();
public Xomw_ImageHandler(byte[] key) {super(key); public Xomw_ImageHandler(byte[] key) {super(key);
@ -28,10 +34,11 @@ public abstract class Xomw_ImageHandler extends Xomw_MediaHandler { private fina
* @return boolean * @return boolean
*/ */
@Override public boolean canRender(Xomw_File file) { @Override public boolean canRender(Xomw_File file) {
return (file.getWidth(1) != Xomw_param_itm.Null_int && file.getHeight(1) != Xomw_param_itm.Null_int); return (Php_utl_.istrue(file.getWidth()) && Php_utl_.istrue(file.getHeight()));
} }
@Override public Xomw_param_map getParamMap() { @Override public Xomw_param_map getParamMap() {
// XO.MW: defined above: "return [ 'img_width' => 'width' ];"
return paramMap; return paramMap;
} }
@ -51,10 +58,10 @@ public abstract class Xomw_ImageHandler extends Xomw_MediaHandler { private fina
@Override public byte[] makeParamString(Xomw_params_handler handlerParams) { @Override public byte[] makeParamString(Xomw_params_handler handlerParams) {
int width = 0; int width = 0;
if (handlerParams.physicalWidth != Xomw_param_itm.Null_int) { if (Php_utl_.isset(handlerParams.physicalWidth)) {
width = handlerParams.physicalWidth; width = handlerParams.physicalWidth;
} }
else if (handlerParams.width != Xomw_param_itm.Null_int) { else if (Php_utl_.isset(handlerParams.width)) {
width = handlerParams.width; width = handlerParams.width;
} }
else { else {
@ -74,7 +81,7 @@ public abstract class Xomw_ImageHandler extends Xomw_MediaHandler { private fina
// return false; // return false;
// } // }
// } // }
//
// function getScriptParams(paramsVar) { // function getScriptParams(paramsVar) {
// return [ 'width' => paramsVar['width'] ]; // return [ 'width' => paramsVar['width'] ];
// } // }
@ -122,7 +129,7 @@ public abstract class Xomw_ImageHandler extends Xomw_MediaHandler { private fina
handlerParams.physicalWidth = handlerParams.width; handlerParams.physicalWidth = handlerParams.width;
} else { } else {
// Height was crap, unset it so that it will be calculated later // Height was crap, unset it so that it will be calculated later
handlerParams.height = Xomw_param_itm.Null_int; handlerParams.height = Php_utl_.Null_int;
} }
} }

@ -17,19 +17,45 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa.mws.media; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; package gplx.xowa.mws.media; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*;
import gplx.langs.htmls.*; import gplx.langs.htmls.*;
import gplx.langs.phps.utls.*; import gplx.xowa.mws.utls.*;
import gplx.xowa.mws.filerepo.file.*; import gplx.xowa.mws.filerepo.file.*;
public class Xomw_MediaTransformOutput { public abstract class Xomw_MediaTransformOutput {
// private final Xomw_File file;
private final byte[] url;
private final int width, height;
private final List_adp attribs = List_adp_.New(), link_attribs = List_adp_.New();
public Xomw_MediaTransformOutput(Xomw_File file, byte[] url, byte[] path, int width, int height) { public Xomw_MediaTransformOutput(Xomw_File file, byte[] url, byte[] path, int width, int height) {
// this.file = file; // this.file = file;
this.url = url; this.url = url;
this.width = width; this.width = width;
this.height = height; this.height = height;
} }
// /** @var array Associative array mapping optional supplementary image files
// * from pixel density (eg 1.5 or 2) to additional URLs.
// */
// public $responsiveUrls = [];
//
// /** @var File */
// private final Xomw_File file;
/** @var int Image width */
protected final int width;
/** @var int Image height */
protected final int height;
/** @var String URL path to the thumb */
protected final byte[] url;
// /** @var boolean|String */
// protected $page;
//
// /** @var boolean|String Filesystem path to the thumb */
// protected $path;
//
// /** @var boolean|String Language code, false if not set */
// protected $lang;
//
// /** @var boolean|String Permanent storage path */
// protected $storagePath = false;
/** /**
* @return int Width of the output box * @return int Width of the output box
*/ */
@ -44,114 +70,207 @@ public class Xomw_MediaTransformOutput {
return this.height; return this.height;
} }
// Return HTML <img ... /> tag for the thumbnail, will include // /**
// width and height attributes and a blank alt text (as required). // * @return File
// // */
// @param array options Associative array of options. Boolean options // public function getFile() {
// should be indicated with a value of true for true, and false or // return $this->file;
// absent for false. // }
// //
// alt HTML alt attribute // /**
// title HTML title attribute // * Get the final extension of the thumbnail.
// desc-link Boolean, show a description link // * Returns false for scripted transformations.
// file-link Boolean, show a file download link // * @return String|boolean
// valign vertical-align property, if the output is an inline element // */
// img-class Class applied to the \<img\> tag, if there is such a tag // public function getExtension() {
// desc-query String, description link query params // return $this->path ? FileBackend::extensionFromPath( $this->path ) : false;
// override-width Override width attribute. Should generally not set // }
// override-height Override height attribute. Should generally not set //
// no-dimensions Boolean, skip width and height attributes (useful if // /**
// set in CSS) // * @return String|boolean The thumbnail URL
// custom-url-link Custom URL to link to // */
// custom-title-link Custom Title Object to link to // public function getUrl() {
// custom target-link Value of the target attribute, for custom-target-link // return $this->url;
// parser-extlink-* Attributes added by parser for external links: // }
// parser-extlink-rel: add rel="nofollow" //
// parser-extlink-target: link target, but overridden by custom-target-link // /**
// // * @return String|boolean The permanent thumbnail storage path
// For images, desc-link and file-link are implemented as a click-through. For // */
// sounds and videos, they may be displayed in other ways. // public function getStoragePath() {
// XO.MW:SYNC:1.29; DATE:2017-02-03 // return $this->storagePath;
public void To_html(Bry_bfr bfr, Bry_bfr tmp, Xomw_MediaTransformOutputParams options) { // }
byte[] alt = options.alt; //
// /**
// byte[] query = options.desc_query; // * @param String $storagePath The permanent storage path
// * @return void
attribs.Clear(); // */
attribs.Add_many(Gfh_atr_.Bry__alt, alt); // public function setStoragePath( $storagePath ) {
attribs.Add_many(Gfh_atr_.Bry__src, url); // $this->storagePath = $storagePath;
boolean link_attribs_is_null = false; // if ( $this->path === false ) {
if (!Php_utl_.Empty(options.custom_url_link)) { // $this->path = $storagePath;
link_attribs.Clear(); // }
link_attribs.Add_many(Gfh_atr_.Bry__href, options.custom_url_link); // }
if (!Php_utl_.Empty(options.title)) {
link_attribs.Add_many(Gfh_atr_.Bry__title, options.title);
}
if (Php_utl_.Empty(options.custom_target_link)) {
link_attribs.Add_many(Gfh_atr_.Bry__target, options.custom_target_link);
}
else if (Php_utl_.Empty(options.parser_extlink_target)) {
link_attribs.Add_many(Gfh_atr_.Bry__target, options.parser_extlink_target);
}
if (Php_utl_.Empty(options.parser_extlink_rel)) {
link_attribs.Add_many(Gfh_atr_.Bry__rel, options.parser_extlink_rel);
}
}
else if (!Php_utl_.Empty(options.custom_title_link)) {
// byte[] title = options.custom_title_link;
// link_attribs.Clear();
// link_attribs.Add_many(Gfh_atr_.Bry__href, title.Get_link_url());
// byte[] options_title = options.title;
// link_attribs.Add_many(Gfh_atr_.Bry__title, Php_utl_.Empty(options_title) ? title.Get_full_text() : options_title);
}
else if (!Php_utl_.Empty(options.desc_link)) {
// link_attribs = this.getDescLinkAttribs(
// empty(options['title']) ? null : options['title'],
// $query
// );
}
else if (!Php_utl_.Empty(options.file_link)) {
// link_attribs.Clear();
// link_attribs.Add_many(Gfh_atr_.Bry__href, file.Get_url());
}
else {
link_attribs_is_null = true;
if (!Php_utl_.Empty(options.title)) {
attribs.Add_many(Gfh_atr_.Bry__title, options.title);
}
}
if (!Php_utl_.Empty(options.no_dimensions)) { /**
attribs.Add_many(Gfh_atr_.Bry__width, Int_.To_bry(width)); * Fetch HTML for this transform output
attribs.Add_many(Gfh_atr_.Bry__height, Int_.To_bry(height)); *
} * @param array $options Associative array of options. Boolean options
if (!Php_utl_.Empty(options.valign)) { * should be indicated with a value of true for true, and false or
attribs.Add_many(Gfh_atr_.Bry__style, Bry_.Add(Bry__vertical_align, options.valign)); * absent for false.
} *
if (!Php_utl_.Empty(options.img_cls)) { * alt Alternate text or caption
attribs.Add_many(Gfh_atr_.Bry__class, options.img_cls); * desc-link Boolean, show a description link
} * file-link Boolean, show a file download link
if (Php_utl_.Is_set(options.override_height)) { * custom-url-link Custom URL to link to
attribs.Add_many(Gfh_atr_.Bry__class, options.override_height); * custom-title-link Custom Title Object to link to
} * valign vertical-align property, if the output is an inline element
if (Php_utl_.Is_set(options.override_width)) { * img-class Class applied to the "<img>" tag, if there is such a tag
attribs.Add_many(Gfh_atr_.Bry__width, options.override_height); *
} * For images, desc-link and file-link are implemented as a click-through. For
* sounds and videos, they may be displayed in other ways.
*
* @return String
*/
public abstract void toHtml(Bry_bfr bfr, Bry_bfr tmp, Xomw_MediaTransformOutputParams options);
// Additional densities for responsive images, if specified. // /**
// If any of these urls is the same as src url, it'll be excluded. // * This will be overridden to return true in error classes
// $responsiveUrls = array_diff(this.responsiveUrls, [ this.url ]); // * @return boolean
// if (!Php_utl_.Empty($responsiveUrls)) { // */
// $attribs['srcset'] = Html::srcSet($responsiveUrls); // public function isError() {
// return false;
// }
//
// /**
// * Check if an output thumbnail file actually exists.
// *
// * This will return false if there was an error, the
// * thumbnail is to be handled client-side only, or if
// * transformation was deferred via TRANSFORM_LATER.
// * This file may exist as a new file in /tmp, a file
// * in permanent storage, or even refer to the original.
// *
// * @return boolean
// */
// public function hasFile() {
// // If TRANSFORM_LATER, $this->path will be false.
// // Note: a null path means "use the source file".
// return ( !$this->isError() && ( $this->path || $this->path === null ) );
// }
//
// /**
// * Check if the output thumbnail is the same as the source.
// * This can occur if the requested width was bigger than the source.
// *
// * @return boolean
// */
// public function fileIsSource() {
// return ( !$this->isError() && $this->path === null );
// }
//
// /**
// * Get the path of a file system copy of the thumbnail.
// * Callers should never write to this path.
// *
// * @return String|boolean Returns false if there isn't one
// */
// public function getLocalCopyPath() {
// if ( $this->isError() ) {
// return false;
// } elseif ( $this->path === null ) {
// return $this->file->getLocalRefPath(); // assume thumb was not scaled
// } elseif ( FileBackend::isStoragePath( $this->path ) ) {
// $be = $this->file->getRepo()->getBackend();
// // The temp file will be process cached by FileBackend
// $fsFile = $be->getLocalReference( [ 'src' => $this->path ] );
//
// return $fsFile ? $fsFile->getPath() : false;
// } else {
// return $this->path; // may return false
// }
// }
//
// /**
// * Stream the file if there were no errors
// *
// * @param array $headers Additional HTTP headers to send on success
// * @return Status
// * @since 1.27
// */
// public function streamFileWithStatus( $headers = [] ) {
// if ( !$this->path ) {
// return Status::newFatal( 'backend-fail-stream', '<no path>' );
// } elseif ( FileBackend::isStoragePath( $this->path ) ) {
// $be = $this->file->getRepo()->getBackend();
// return $be->streamFile( [ 'src' => $this->path, 'headers' => $headers ] );
// } else { // FS-file
// $success = StreamFile::stream( $this->getLocalCopyPath(), $headers );
// return $success ? Status::newGood() : Status::newFatal( 'backend-fail-stream', $this->path );
// }
// }
//
// /**
// * Stream the file if there were no errors
// *
// * @deprecated since 1.26, use streamFileWithStatus
// * @param array $headers Additional HTTP headers to send on success
// * @return boolean Success
// */
// public function streamFile( $headers = [] ) {
// $this->streamFileWithStatus( $headers )->isOK();
// }
//
// /**
// * Wrap some XHTML text in an anchor tag with the given attributes
// *
// * @param array $linkAttribs
// * @param String $contents
// * @return String
// */
// protected function linkWrap( $linkAttribs, $contents ) {
// if ( $linkAttribs ) {
// return Xml::tags( 'a', $linkAttribs, $contents );
// } else {
// return $contents;
// }
// }
//
// /**
// * @param String $title
// * @param String|array $params Query parameters to add
// * @return array
// */
// public function getDescLinkAttribs( $title = null, $params = [] ) {
// if ( is_array( $params ) ) {
// $query = $params;
// } else {
// $query = [];
// }
// if ( $this->page && $this->page !== 1 ) {
// $query['page'] = $this->page;
// }
// if ( $this->lang ) {
// $query['lang'] = $this->lang;
// }
//
// if ( is_string( $params ) && $params !== '' ) {
// $query = $params . '&' . wfArrayToCgi( $query );
// }
//
// $attribs = [
// 'href' => $this->file->getTitle()->getLocalURL( $query ),
// 'class' => 'image',
// ];
// if ( $title ) {
// $attribs['title'] = $title;
// }
//
// return $attribs;
// } // }
// XO.MW.HOOK:ThumbnailBeforeProduceHTML
Xomw_xml.Element(tmp, Gfh_tag_.Bry__img, attribs, Bry_.Empty, Bool_.Y);
Link_wrap(bfr, link_attribs_is_null ? null : link_attribs, tmp.To_bry_and_clear());
}
// Wrap some XHTML text in an anchor tag with the given attributes // Wrap some XHTML text in an anchor tag with the given attributes
// XO.MW:SYNC:1.29; DATE:2017-02-03 // XO.MW:SYNC:1.29; DATE:2017-02-03
private void Link_wrap(Bry_bfr bfr, List_adp link_attribs, byte[] contents) { protected void Link_wrap(Bry_bfr bfr, List_adp link_attribs, byte[] contents) {
if (link_attribs != null) { if (link_attribs != null) {
Xomw_xml.Tags(bfr, Gfh_tag_.Bry__a, link_attribs, contents); Xomw_xml.Tags(bfr, Gfh_tag_.Bry__a, link_attribs, contents);
} }
@ -159,5 +278,4 @@ public class Xomw_MediaTransformOutput {
bfr.Add(contents); bfr.Add(contents);
} }
} }
private static final byte[] Bry__vertical_align = Bry_.new_a7("vertical-align: ");
} }

@ -16,10 +16,15 @@ 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa.mws.media; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; package gplx.xowa.mws.media; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*;
import gplx.langs.htmls.*;
import gplx.xowa.mws.utls.*;
import gplx.xowa.mws.parsers.lnkis.*; import gplx.xowa.mws.parsers.lnkis.*;
import gplx.xowa.mws.filerepo.file.*; import gplx.xowa.mws.filerepo.file.*;
// Media transform output for images // Media transform output for images
public class Xomw_ThumbnailImage extends Xomw_MediaTransformOutput { /** public class Xomw_ThumbnailImage extends Xomw_MediaTransformOutput { private final List_adp attribs = List_adp_.New(), link_attribs = List_adp_.New();
public Xomw_ThumbnailImage(Xomw_File file, byte[] url, byte[] path, int w, int h) {super(file, url, path, w, h);
}
/**
* Get a thumbnail Object from a file and parameters. * Get a thumbnail Object from a file and parameters.
* If path is set to null, the output file is treated as a source copy. * If path is set to null, the output file is treated as a source copy.
* If path is set to false, no output file will be created. * If path is set to false, no output file will be created.
@ -78,7 +83,7 @@ public class Xomw_ThumbnailImage extends Xomw_MediaTransformOutput { /**
* file-link Boolean, show a file download link * file-link Boolean, show a file download link
* valign vertical-align property, if the output is an inline element * valign vertical-align property, if the output is an inline element
* img-class Class applied to the \<img\> tag, if there is such a tag * img-class Class applied to the \<img\> tag, if there is such a tag
* desc-query String, description link query * desc-query String, description link query prms
* @Override width Override width attribute. Should generally not set * @Override width Override width attribute. Should generally not set
* @Override height Override height attribute. Should generally not set * @Override height Override height attribute. Should generally not set
* no-dimensions Boolean, skip width and height attributes (useful if * no-dimensions Boolean, skip width and height attributes (useful if
@ -96,80 +101,110 @@ public class Xomw_ThumbnailImage extends Xomw_MediaTransformOutput { /**
* @throws MWException * @throws MWException
* @return String * @return String
*/ */
// function toHtml(options = ...) { // Return HTML <img ... /> tag for the thumbnail, will include
// if (count(func_get_args()) == 2) { // width and height attributes and a blank alt text (as required).
// throw new MWException(__METHOD__ . ' called in the old style'); //
// } // @param array options Associative array of options. Boolean options
// // should be indicated with a value of true for true, and false or
// alt = isset(options['alt']) ? options['alt'] : ''; // absent for false.
// //
// query = isset(options['desc-query']) ? options['desc-query'] : ''; // alt HTML alt attribute
// // title HTML title attribute
// attribs = [ // desc-link Boolean, show a description link
// 'alt' => alt, // file-link Boolean, show a file download link
// 'src' => this->url, // valign vertical-align property, if the output is an inline element
// ]; // img-class Class applied to the \<img\> tag, if there is such a tag
// // desc-query String, description link query prms
// if (!empty(options['custom-url-link'])) { // override-width Override width attribute. Should generally not set
// linkAttribs = [ 'href' => options['custom-url-link'] ]; // override-height Override height attribute. Should generally not set
// if (!empty(options['title'])) { // no-dimensions Boolean, skip width and height attributes (useful if
// linkAttribs['title'] = options['title']; // set in CSS)
// } // custom-url-link Custom URL to link to
// if (!empty(options['custom-target-link'])) { // custom-title-link Custom Title Object to link to
// linkAttribs['target'] = options['custom-target-link']; // custom target-link Value of the target attribute, for custom-target-link
// } elseif (!empty(options['parser-extlink-target'])) { // parser-extlink-* Attributes added by parser for external links:
// linkAttribs['target'] = options['parser-extlink-target']; // parser-extlink-rel: add rel="nofollow"
// } // parser-extlink-target: link target, but overridden by custom-target-link
// if (!empty(options['parser-extlink-rel'])) { //
// linkAttribs['rel'] = options['parser-extlink-rel']; // For images, desc-link and file-link are implemented as a click-through. For
// } // sounds and videos, they may be displayed in other ways.
// } elseif (!empty(options['custom-title-link'])) { // XO.MW:SYNC:1.29; DATE:2017-02-03
// /** @var Title title */ @Override public void toHtml(Bry_bfr bfr, Bry_bfr tmp, Xomw_MediaTransformOutputParams options) {
// title = options['custom-title-link']; byte[] alt = options.alt;
// linkAttribs = [
// 'href' => title->getLinkURL(), // byte[] query = options.desc_query;
// 'title' => empty(options['title']) ? title->getFullText() : options['title']
// ]; attribs.Clear();
// } elseif (!empty(options['desc-link'])) { attribs.Add_many(Gfh_atr_.Bry__alt, alt);
// linkAttribs = this->getDescLinkAttribs( attribs.Add_many(Gfh_atr_.Bry__src, url);
boolean link_attribs_is_null = false;
if (!Php_utl_.Empty(options.custom_url_link)) {
link_attribs.Clear();
link_attribs.Add_many(Gfh_atr_.Bry__href, options.custom_url_link);
if (!Php_utl_.Empty(options.title)) {
link_attribs.Add_many(Gfh_atr_.Bry__title, options.title);
}
if (Php_utl_.Empty(options.custom_target_link)) {
link_attribs.Add_many(Gfh_atr_.Bry__target, options.custom_target_link);
}
else if (Php_utl_.Empty(options.parser_extlink_target)) {
link_attribs.Add_many(Gfh_atr_.Bry__target, options.parser_extlink_target);
}
if (Php_utl_.Empty(options.parser_extlink_rel)) {
link_attribs.Add_many(Gfh_atr_.Bry__rel, options.parser_extlink_rel);
}
}
else if (!Php_utl_.Empty(options.custom_title_link)) {
// byte[] title = options.custom_title_link;
// link_attribs.Clear();
// link_attribs.Add_many(Gfh_atr_.Bry__href, title.Get_link_url());
// byte[] options_title = options.title;
// link_attribs.Add_many(Gfh_atr_.Bry__title, Php_utl_.Empty(options_title) ? title.Get_full_text() : options_title);
}
else if (!Php_utl_.Empty(options.desc_link)) {
// link_attribs = this.getDescLinkAttribs(
// empty(options['title']) ? null : options['title'], // empty(options['title']) ? null : options['title'],
// query // $query
// ); // );
// } elseif (!empty(options['file-link'])) { }
// linkAttribs = [ 'href' => this->file->getUrl() ]; else if (!Php_utl_.Empty(options.file_link)) {
// } else { // link_attribs.Clear();
// linkAttribs = false; // link_attribs.Add_many(Gfh_atr_.Bry__href, file.Get_url());
// if (!empty(options['title'])) { }
// attribs['title'] = options['title']; else {
// } link_attribs_is_null = true;
// } if (!Php_utl_.Empty(options.title)) {
// attribs.Add_many(Gfh_atr_.Bry__title, options.title);
// if (empty(options['no-dimensions'])) { }
// attribs['width'] = this->width; }
// attribs['height'] = this->height;
// } if (!Php_utl_.Empty(options.no_dimensions)) {
// if (!empty(options['valign'])) { attribs.Add_many(Gfh_atr_.Bry__width, Int_.To_bry(width));
// attribs['style'] = "vertical-align: {options['valign']}"; attribs.Add_many(Gfh_atr_.Bry__height, Int_.To_bry(height));
// } }
// if (!empty(options['img-class'])) { if (!Php_utl_.Empty(options.valign)) {
// attribs['class'] = options['img-class']; attribs.Add_many(Gfh_atr_.Bry__style, Bry_.Add(Bry__vertical_align, options.valign));
// } }
// if (isset(options['override-height'])) { if (!Php_utl_.Empty(options.img_cls)) {
// attribs['height'] = options['override-height']; attribs.Add_many(Gfh_atr_.Bry__class, options.img_cls);
// } }
// if (isset(options['override-width'])) { if (Php_utl_.isset(options.override_height)) {
// attribs['width'] = options['override-width']; attribs.Add_many(Gfh_atr_.Bry__class, options.override_height);
// } }
// if (Php_utl_.isset(options.override_width)) {
// // Additional densities for responsive images, if specified. attribs.Add_many(Gfh_atr_.Bry__width, options.override_height);
// // If any of these urls is the same as src url, it'll be excluded. }
// responsiveUrls = array_diff(this->responsiveUrls, [ this->url ]);
// if (!empty(responsiveUrls)) { // Additional densities for responsive images, if specified.
// attribs['srcset'] = Html::srcSet(responsiveUrls); // If any of these urls is the same as src url, it'll be excluded.
// } // $responsiveUrls = array_diff(this.responsiveUrls, [ this.url ]);
// // if (!Php_utl_.Empty($responsiveUrls)) {
// Hooks::run('ThumbnailBeforeProduceHTML', [ this, &attribs, &linkAttribs ]); // $attribs['srcset'] = Html::srcSet($responsiveUrls);
//
// return this->linkWrap(linkAttribs, Xml::element('img', attribs));
// } // }
// XO.MW.HOOK:ThumbnailBeforeProduceHTML
Xomw_xml.Element(tmp, Gfh_tag_.Bry__img, attribs, Bry_.Empty, Bool_.Y);
Link_wrap(bfr, link_attribs_is_null ? null : link_attribs, tmp.To_bry_and_clear());
}
private static final byte[] Bry__vertical_align = Bry_.new_a7("vertical-align: ");
} }

@ -28,19 +28,19 @@ public class Xomw_TransformationalImageHandler extends Xomw_ImageHandler { publi
* 'physicalWidth' and 'physicalHeight' indicate the thumbnail dimensions. * 'physicalWidth' and 'physicalHeight' indicate the thumbnail dimensions.
* @return boolean * @return boolean
*/ */
@Override public boolean normaliseParams(Xomw_File image, Xomw_params_handler handlerParams) { @Override public boolean normaliseParams(Xomw_File image, Xomw_params_handler prms) {
if (!super.normaliseParams(image, handlerParams)) { if (!super.normaliseParams(image, prms)) {
return false; return false;
} }
// Obtain the source, pre-rotation dimensions // Obtain the source, pre-rotation dimensions
int srcWidth = image.getWidth(handlerParams.page); int srcWidth = image.getWidth(prms.page);
int srcHeight = image.getHeight(handlerParams.page); int srcHeight = image.getHeight(prms.page);
// Don't make an image bigger than the source // Don't make an image bigger than the source
if (handlerParams.physicalWidth >= srcWidth) { if (prms.physicalWidth >= srcWidth) {
handlerParams.physicalWidth = srcWidth; prms.physicalWidth = srcWidth;
handlerParams.physicalHeight = srcHeight; prms.physicalHeight = srcHeight;
// Skip scaling limit checks if no scaling is required // Skip scaling limit checks if no scaling is required
// due to requested size being bigger than source. // due to requested size being bigger than source.
@ -90,7 +90,7 @@ public class Xomw_TransformationalImageHandler extends Xomw_ImageHandler { publi
* @param int flags * @param int flags
* @return MediaTransformError|ThumbnailImage|TransformParameterError * @return MediaTransformError|ThumbnailImage|TransformParameterError
*/ */
@Override public Xomw_MediaTransformOutput doTransform(Xomw_File image, byte[] dstPath, byte[] dstUrl, Xomw_params_handler handlerParams, int flags) { @Override public Xomw_MediaTransformOutput doTransform(Xomw_File image, byte[] dstPath, byte[] dstUrl, Xomw_params_handler prms, int flags) {
// if (!this.normaliseParams(image, paramsVar)) { // if (!this.normaliseParams(image, paramsVar)) {
// return new TransformParameterError(paramsVar); // return new TransformParameterError(paramsVar);
// } // }
@ -98,12 +98,12 @@ public class Xomw_TransformationalImageHandler extends Xomw_ImageHandler { publi
// // Create a parameter array to pass to the scaler // // Create a parameter array to pass to the scaler
Xomw_params_scalar scalerParams = new Xomw_params_scalar(); Xomw_params_scalar scalerParams = new Xomw_params_scalar();
// // The size to which the image will be resized // // The size to which the image will be resized
scalerParams.physicalWidth = handlerParams.physicalWidth; scalerParams.physicalWidth = prms.physicalWidth;
scalerParams.physicalHeight = handlerParams.physicalHeight; scalerParams.physicalHeight = prms.physicalHeight;
// 'physicalDimensions' => "{paramsVar['physicalWidth']}x{paramsVar['physicalHeight']}", // 'physicalDimensions' => "{paramsVar['physicalWidth']}x{paramsVar['physicalHeight']}",
// The size of the image on the page // The size of the image on the page
scalerParams.clientWidth = handlerParams.width; scalerParams.clientWidth = prms.width;
scalerParams.clientHeight = handlerParams.height; scalerParams.clientHeight = prms.height;
// Comment as will be added to the Exif of the thumbnail // Comment as will be added to the Exif of the thumbnail
// 'comment' => isset(paramsVar['descriptionUrl']) // 'comment' => isset(paramsVar['descriptionUrl'])
// ? "File source: {paramsVar['descriptionUrl']}" // ? "File source: {paramsVar['descriptionUrl']}"
@ -173,7 +173,7 @@ public class Xomw_TransformationalImageHandler extends Xomw_ImageHandler { publi
// newParams['page'] = paramsVar['page']; // newParams['page'] = paramsVar['page'];
// } // }
// return new Xomw_ThumbnailImage(image, dstUrl, null, newParams); // return new Xomw_ThumbnailImage(image, dstUrl, null, newParams);
return new Xomw_ThumbnailImage(image, dstUrl, null, handlerParams); return new Xomw_ThumbnailImage(image, dstUrl, null, prms);
// } // }
// //
// // Try to make a target path for the thumbnail // // Try to make a target path for the thumbnail
@ -319,11 +319,11 @@ public class Xomw_TransformationalImageHandler extends Xomw_ImageHandler { publi
* @todo FIXME: No rotation support * @todo FIXME: No rotation support
*/ */
private Xomw_ThumbnailImage getClientScalingThumbnailImage(Xomw_File image, Xomw_params_scalar scalerParams) { private Xomw_ThumbnailImage getClientScalingThumbnailImage(Xomw_File image, Xomw_params_scalar scalerParams) {
Xomw_params_handler handler_params = new Xomw_params_handler(); Xomw_params_handler prms = new Xomw_params_handler();
handler_params.width = scalerParams.clientWidth; prms.width = scalerParams.clientWidth;
handler_params.height = scalerParams.clientHeight; prms.height = scalerParams.clientHeight;
return new Xomw_ThumbnailImage(image, image.getUrl(), image.getPath(), handler_params); return new Xomw_ThumbnailImage(image, image.getUrl(), null, prms);
} }
// /** // /**

@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package gplx.xowa.mws.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; package gplx.xowa.mws.parsers; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*;
import gplx.core.btries.*; import gplx.core.btries.*;
import gplx.langs.htmls.*; import gplx.langs.htmls.*;
import gplx.langs.phps.utls.*; import gplx.xowa.mws.utls.*;
public class Xomw_block_level_pass { public class Xomw_block_level_pass {
private final Bry_bfr tmp = Bry_bfr_.New(); private final Bry_bfr tmp = Bry_bfr_.New();
private final Btrie_rv trv = new Btrie_rv(); private final Btrie_rv trv = new Btrie_rv();

@ -16,7 +16,7 @@ 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa.mws.parsers.hrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; import gplx.xowa.mws.parsers.*; package gplx.xowa.mws.parsers.hrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; import gplx.xowa.mws.parsers.*;
import gplx.langs.phps.utls.*; import gplx.xowa.mws.utls.*;
public class Xomw_hr_wkr {// THREAD.UNSAFE: caching for repeated calls public class Xomw_hr_wkr {// THREAD.UNSAFE: caching for repeated calls
private Bry_bfr bfr; private Bry_bfr bfr;
public void Replace_hrs(Xomw_parser_ctx pctx, Xomw_parser_bfr pbfr) { // REF.MW: text = preg_replace('/(^|\n)-----*/', '\\1<hr />', text); public void Replace_hrs(Xomw_parser_ctx pctx, Xomw_parser_bfr pbfr) { // REF.MW: text = preg_replace('/(^|\n)-----*/', '\\1<hr />', text);

@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa.mws.parsers.lnkes; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; import gplx.xowa.mws.parsers.*; package gplx.xowa.mws.parsers.lnkes; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; import gplx.xowa.mws.parsers.*;
import gplx.core.btries.*; import gplx.core.primitives.*; import gplx.core.btries.*; import gplx.core.primitives.*;
import gplx.langs.phps.utls.*; import gplx.xowa.mws.utls.*;
import gplx.xowa.mws.htmls.*; import gplx.xowa.mws.htmls.*;
/* TODO.XO /* TODO.XO
* P3: $langObj->formatNum( ++$this->mAutonumber ); * P3: $langObj->formatNum( ++$this->mAutonumber );

@ -17,11 +17,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa.mws.parsers.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; import gplx.xowa.mws.parsers.*; package gplx.xowa.mws.parsers.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; import gplx.xowa.mws.parsers.*;
import gplx.core.btries.*; import gplx.core.primitives.*; import gplx.core.btries.*; import gplx.core.primitives.*;
import gplx.langs.phps.utls.*; import gplx.xowa.mws.utls.*;
import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.xwikis.*;
import gplx.xowa.mws.parsers.*; import gplx.xowa.mws.parsers.quotes.*; import gplx.xowa.mws.parsers.*; import gplx.xowa.mws.parsers.quotes.*;
import gplx.xowa.mws.htmls.*; import gplx.xowa.mws.linkers.*; import gplx.xowa.mws.htmls.*; import gplx.xowa.mws.linkers.*;
import gplx.xowa.mws.utls.*; import gplx.xowa.mws.libs.*; import gplx.xowa.mws.libs.*;
import gplx.xowa.mws.media.*; import gplx.xowa.mws.filerepo.file.*; import gplx.xowa.mws.media.*; import gplx.xowa.mws.filerepo.file.*;
import gplx.xowa.parsers.uniqs.*; import gplx.xowa.parsers.uniqs.*;
/* TODO.XO /* TODO.XO
@ -743,7 +743,7 @@ public class Xomw_lnki_wkr {// THREAD.UNSAFE: caching for repeated calls
// Parsed a width param of imagelink like 300px or 200x300px // Parsed a width param of imagelink like 300px or 200x300px
// XO.MW.NOTE: for MW, "" -> null, null while "AxB" -> 0x0 // XO.MW.NOTE: for MW, "" -> null, null while "AxB" -> 0x0
public void parseWidthParam(int[] img_size, byte[] src) { public void parseWidthParam(int[] img_size, byte[] src) {
img_size[0] = img_size[1] = Xomw_param_itm.Null_int; img_size[0] = img_size[1] = Php_utl_.Null_int;
if (src == Bry_.Empty) { if (src == Bry_.Empty) {
return; return;
} }

@ -54,6 +54,4 @@ public class Xomw_param_itm {
public static final byte[] public static final byte[]
Name_bry__width = Bry_.new_a7("width") Name_bry__width = Bry_.new_a7("width")
; ;
public static final int Null_int = Int_.Max_value;
} }

@ -16,6 +16,7 @@ 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa.mws.parsers.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; import gplx.xowa.mws.parsers.*; package gplx.xowa.mws.parsers.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; import gplx.xowa.mws.parsers.*;
import gplx.xowa.mws.utls.*;
public class Xomw_params_handler { public class Xomw_params_handler {
public int width; public int width;
public int height; public int height;
@ -24,7 +25,7 @@ public class Xomw_params_handler {
public int physicalHeight; public int physicalHeight;
public Xomw_params_handler Clear() { public Xomw_params_handler Clear() {
width = height = page width = height = page
= physicalWidth = physicalHeight = Xomw_param_itm.Null_int; = physicalWidth = physicalHeight = Php_utl_.Null_int;
return this; return this;
} }
public void Copy_to(Xomw_params_handler src) { public void Copy_to(Xomw_params_handler src) {

@ -16,6 +16,7 @@ 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa.mws.parsers.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; import gplx.xowa.mws.parsers.*; package gplx.xowa.mws.parsers.lnkis; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; import gplx.xowa.mws.parsers.*;
import gplx.xowa.mws.utls.*;
public class Xomw_params_scalar { public class Xomw_params_scalar {
public int physicalWidth; public int physicalWidth;
public int physicalHeight; public int physicalHeight;
@ -30,6 +31,6 @@ public class Xomw_params_scalar {
public byte[] dstUrl; public byte[] dstUrl;
public byte[] interlace; public byte[] interlace;
public Xomw_params_scalar() { public Xomw_params_scalar() {
physicalWidth = physicalHeight = clientWidth = clientHeight = srcWidth = srcHeight = Xomw_param_itm.Null_int; physicalWidth = physicalHeight = clientWidth = clientHeight = srcWidth = srcHeight = Php_utl_.Null_int;
} }
} }

@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa.mws.parsers.magiclinks; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; import gplx.xowa.mws.parsers.*; package gplx.xowa.mws.parsers.magiclinks; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; import gplx.xowa.mws.parsers.*;
import gplx.core.primitives.*; import gplx.core.btries.*; import gplx.core.net.*; import gplx.core.primitives.*; import gplx.core.btries.*; import gplx.core.net.*;
import gplx.langs.phps.utls.*; import gplx.xowa.mws.htmls.*; import gplx.xowa.mws.utls.*; import gplx.xowa.mws.htmls.*;
import gplx.langs.regxs.*; import gplx.langs.regxs.*;
// TODO.XO: this->getConverterLanguage()->markNoConversion($url, true), // TODO.XO: this->getConverterLanguage()->markNoConversion($url, true),
public class Xomw_magiclinks_wkr { public class Xomw_magiclinks_wkr {

@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa.mws.parsers.prepros; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; import gplx.xowa.mws.parsers.*; package gplx.xowa.mws.parsers.prepros; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; import gplx.xowa.mws.parsers.*;
import gplx.core.btries.*; import gplx.core.btries.*;
import gplx.langs.phps.utls.*; import gplx.xowa.mws.utls.*;
public class Xomw_prepro_wkr { // THREAD.UNSAFE: caching for repeated calls public class Xomw_prepro_wkr { // THREAD.UNSAFE: caching for repeated calls
private final Bry_bfr tmp_bfr = Bry_bfr_.New(); private final Bry_bfr tmp_bfr = Bry_bfr_.New();
private final List_adp comments_list = List_adp_.New(); private final List_adp comments_list = List_adp_.New();

@ -16,7 +16,7 @@ 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa.mws.parsers.quotes; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; import gplx.xowa.mws.parsers.*; package gplx.xowa.mws.parsers.quotes; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; import gplx.xowa.mws.parsers.*;
import gplx.langs.phps.utls.*; import gplx.xowa.mws.utls.*;
import gplx.xowa.parsers.htmls.*; import gplx.xowa.parsers.htmls.*;
import gplx.core.primitives.*; import gplx.core.primitives.*;
public class Xomw_quote_wkr {// THREAD.UNSAFE: caching for repeated calls public class Xomw_quote_wkr {// THREAD.UNSAFE: caching for repeated calls

@ -16,7 +16,7 @@ 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.xowa.mws.parsers.tables; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; import gplx.xowa.mws.parsers.*; package gplx.xowa.mws.parsers.tables; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*; import gplx.xowa.mws.parsers.*;
import gplx.langs.phps.utls.*; import gplx.xowa.mws.utls.*;
import gplx.xowa.parsers.htmls.*; import gplx.xowa.parsers.htmls.*;
import gplx.xowa.mws.libs.*; import gplx.xowa.parsers.uniqs.*; import gplx.xowa.mws.libs.*; import gplx.xowa.parsers.uniqs.*;
public class Xomw_table_wkr implements gplx.core.brys.Bry_split_wkr {// THREAD.UNSAFE: caching for repeated calls public class Xomw_table_wkr implements gplx.core.brys.Bry_split_wkr {// THREAD.UNSAFE: caching for repeated calls

@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.langs.phps.utls; import gplx.*; import gplx.langs.*; import gplx.langs.phps.*; package gplx.xowa.mws.utls; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*;
public class Php_ary_ { public class Php_ary_ {
public static boolean Pop_bool_or_n(List_adp list) {return (boolean)List_adp_.Pop_or(list, false);} public static boolean Pop_bool_or_n(List_adp list) {return (boolean)List_adp_.Pop_or(list, false);}
public static byte[] Pop_bry_or_null(List_adp list) {return (byte[])List_adp_.Pop_or(list, null);} public static byte[] Pop_bry_or_null(List_adp list) {return (byte[])List_adp_.Pop_or(list, null);}

@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.langs.phps.utls; import gplx.*; import gplx.langs.*; import gplx.langs.phps.*; package gplx.xowa.mws.utls; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*;
public class Php_encode_ { public class Php_encode_ {
public static byte[] rawurlencode(byte[] v) { public static byte[] rawurlencode(byte[] v) {
return gplx.langs.htmls.encoders.Gfo_url_encoder_.Php_rawurlencode.Encode(v); return gplx.langs.htmls.encoders.Gfo_url_encoder_.Php_rawurlencode.Encode(v);

@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.langs.phps.utls; import gplx.*; import gplx.langs.*; import gplx.langs.phps.*; package gplx.xowa.mws.utls; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*;
import gplx.core.btries.*; import gplx.core.brys.*; import gplx.core.btries.*; import gplx.core.brys.*;
import gplx.core.primitives.*; import gplx.core.primitives.*;
public class Php_preg_ { public class Php_preg_ {

@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.langs.phps.utls; import gplx.*; import gplx.langs.*; import gplx.langs.phps.*; package gplx.xowa.mws.utls; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*;
import org.junit.*; import gplx.core.tests.*; import org.junit.*; import gplx.core.tests.*;
public class Php_preg___tst { public class Php_preg___tst {
private final Php_preg___fxt fxt = new Php_preg___fxt(); private final Php_preg___fxt fxt = new Php_preg___fxt();

@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.langs.phps.utls; import gplx.*; import gplx.langs.*; import gplx.langs.phps.*; package gplx.xowa.mws.utls; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*;
import gplx.core.btries.*; import gplx.core.btries.*;
public class Php_str_ { public class Php_str_ {
public static int Strpos(byte[] src, byte find) {return Strpos(src, find, 0, src.length);} public static int Strpos(byte[] src, byte find) {return Strpos(src, find, 0, src.length);}

@ -15,7 +15,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.langs.phps.utls; import gplx.*; import gplx.langs.*; import gplx.langs.phps.*; package gplx.xowa.mws.utls; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*;
import org.junit.*; import gplx.core.tests.*; import gplx.core.btries.*; import org.junit.*; import gplx.core.tests.*; import gplx.core.btries.*;
public class Php_str___tst { public class Php_str___tst {
private final Php_str___fxt fxt = new Php_str___fxt(); private final Php_str___fxt fxt = new Php_str___fxt();

@ -15,12 +15,13 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package gplx.langs.phps.utls; import gplx.*; import gplx.langs.*; import gplx.langs.phps.*; package gplx.xowa.mws.utls; import gplx.*; import gplx.xowa.*; import gplx.xowa.mws.*;
public class Php_utl_ { public class Php_utl_ {
public static boolean Empty(byte[] v) {return v == null || v.length == 0;} public static boolean Empty(byte[] v) {return v == null || v.length == 0;}
public static boolean Empty(boolean v) {return v == false;} public static boolean Empty(boolean v) {return v == false;}
public static boolean Is_set(byte[] v) {return v != null;} public static boolean isset(byte[] v) {return v != null;}
public static boolean isset(int v) {return v != Int_.Max_value;} public static boolean isset(int v) {return v != Null_int;}
public static boolean istrue(int v) {return v != Null_int;}
public static boolean isnumeric(byte[] src) { public static boolean isnumeric(byte[] src) {
if (src == null) return false; if (src == null) return false;
int len = src.length; int len = src.length;
@ -36,4 +37,5 @@ public class Php_utl_ {
} }
return true; return true;
} }
public static final int Null_int = Int_.Max_value;
} }
Loading…
Cancel
Save