mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Mw_parse: Refactor Xomw_ThumbnailImage
This commit is contained in:
parent
906bcdc6fe
commit
ff7952447d
@ -33,7 +33,7 @@ public class Xoa_app_ {
|
||||
}
|
||||
public static final String Name = "xowa";
|
||||
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_fmt = "yyyy-MM-dd HH:mm:ss";
|
||||
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.filerepo.file.*; import gplx.xowa.mws.media.*;
|
||||
import gplx.xowa.mws.parsers.lnkis.*;
|
||||
import gplx.langs.phps.utls.*;
|
||||
import gplx.xowa.mws.utls.*;
|
||||
/* TODO.XO
|
||||
* P8: wfMessage
|
||||
* P7: titleFormatter->getPrefixedText
|
||||
@ -123,8 +123,8 @@ public class Xomw_linker {
|
||||
postfix = Gfh_tag_.Div_rhs;
|
||||
frame_params.align = Align__frame__none;
|
||||
}
|
||||
if (file != null && handler_params.width == Xomw_param_itm.Null_int) {
|
||||
if (handler_params.height != Xomw_param_itm.Null_int && file.isVectorized()) {
|
||||
if (file != null && handler_params.width == Php_utl_.Null_int) {
|
||||
if (handler_params.height != Php_utl_.Null_int && file.isVectorized()) {
|
||||
// If its a vector image, and user only specifies height
|
||||
// we don't want it to be limited by its "normal" width.
|
||||
// global $wgSVGMaxSize;
|
||||
@ -138,7 +138,7 @@ public class Xomw_linker {
|
||||
|| frame_params.manual_thumb != null
|
||||
|| frame_params.framed != null
|
||||
|| frame_params.frameless != null
|
||||
|| handler_params.width == Xomw_param_itm.Null_int
|
||||
|| handler_params.width == Php_utl_.Null_int
|
||||
) {
|
||||
// global $wgThumbLimits, $wgThumbUpright;
|
||||
|
||||
@ -161,7 +161,7 @@ public class Xomw_linker {
|
||||
|
||||
// Use width which is smaller: real image width or user preference width
|
||||
// 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()) {
|
||||
handler_params.width = pref_width;
|
||||
}
|
||||
@ -190,13 +190,13 @@ public class Xomw_linker {
|
||||
// For "frameless" option: do not present an image bigger than the
|
||||
// source (for bitmap-style images). This is the same behavior as the
|
||||
// "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;
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
thumb = file.transform(handler_params);
|
||||
}
|
||||
@ -221,7 +221,7 @@ public class Xomw_linker {
|
||||
}
|
||||
// $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();
|
||||
}
|
||||
if (frame_params.align != Bry_.Empty) {
|
||||
@ -247,9 +247,9 @@ public class Xomw_linker {
|
||||
// @return array
|
||||
// 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) {
|
||||
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;
|
||||
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;
|
||||
}
|
||||
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));
|
||||
}
|
||||
else if (!Php_utl_.Empty(frame_params.no_link)) {
|
||||
@ -289,9 +289,9 @@ public class Xomw_linker {
|
||||
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
|
||||
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 manual_thumb = false;
|
||||
@ -318,14 +318,14 @@ public class Xomw_linker {
|
||||
else if (frame_params.framed != null) {
|
||||
// Use image dimensions, don't scale
|
||||
// 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;
|
||||
}
|
||||
else {
|
||||
// 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
|
||||
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;
|
||||
}
|
||||
// thumb = $file->transform(handler_params);
|
||||
@ -378,7 +378,7 @@ public class Xomw_linker {
|
||||
mto_params.title = frame_params.title;
|
||||
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);
|
||||
thumb.To_html(bfr, tmp, mto_params);
|
||||
thumb.toHtml(bfr, tmp, mto_params);
|
||||
if (frame_params.framed != null) {
|
||||
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.*;
|
||||
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.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 {
|
||||
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();
|
||||
|
@ -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.*;
|
||||
import gplx.xowa.mws.filerepo.file.*;
|
||||
import gplx.langs.phps.utls.*;
|
||||
import gplx.xowa.mws.utls.*;
|
||||
/* TODO.XO:
|
||||
* 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.*;
|
||||
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.*;
|
||||
public class Xomw_File {
|
||||
/* TODO.XO:
|
||||
@ -281,7 +281,7 @@ public class Xomw_File {
|
||||
* @return String
|
||||
*/
|
||||
public byte[] getName() {
|
||||
if (!Php_utl_.Is_set(this.name)) {
|
||||
if (!Php_utl_.isset(this.name)) {
|
||||
// this.assertRepoDefined();
|
||||
this.name = this.repo.getNameFromTitle(this.title);
|
||||
}
|
||||
@ -295,7 +295,7 @@ public class Xomw_File {
|
||||
* @return String
|
||||
*/
|
||||
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);
|
||||
this.extension = normalizeExtension(
|
||||
n != Bry_find_.Not_found ? Php_str_.Substr(this.getName(), n + 1) : Bry_.Empty);
|
||||
@ -332,7 +332,7 @@ public class Xomw_File {
|
||||
* @return String
|
||||
*/
|
||||
public byte[] getUrl() {
|
||||
if (!Php_utl_.Is_set(this.url)) {
|
||||
if (!Php_utl_.isset(this.url)) {
|
||||
// this.assertRepoDefined();
|
||||
byte[] ext = this.getExtension();
|
||||
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
|
||||
*/
|
||||
private byte[] getHashPath() {
|
||||
if (!Php_utl_.Is_set(this.hashPath)) {
|
||||
if (!Php_utl_.isset(this.hashPath)) {
|
||||
// this.assertRepoDefined();
|
||||
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.*;
|
||||
import gplx.core.btries.*;
|
||||
import gplx.langs.phps.utls.*;
|
||||
import gplx.xowa.mws.utls.*;
|
||||
public class Xomw_html_utl {
|
||||
private final Bry_bfr tmp = Bry_bfr_.New();
|
||||
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.*;
|
||||
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
|
||||
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);
|
||||
@ -28,10 +34,11 @@ public abstract class Xomw_ImageHandler extends Xomw_MediaHandler { private fina
|
||||
* @return boolean
|
||||
*/
|
||||
@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() {
|
||||
// XO.MW: defined above: "return [ 'img_width' => 'width' ];"
|
||||
return paramMap;
|
||||
}
|
||||
|
||||
@ -51,10 +58,10 @@ public abstract class Xomw_ImageHandler extends Xomw_MediaHandler { private fina
|
||||
|
||||
@Override public byte[] makeParamString(Xomw_params_handler handlerParams) {
|
||||
int width = 0;
|
||||
if (handlerParams.physicalWidth != Xomw_param_itm.Null_int) {
|
||||
if (Php_utl_.isset(handlerParams.physicalWidth)) {
|
||||
width = handlerParams.physicalWidth;
|
||||
}
|
||||
else if (handlerParams.width != Xomw_param_itm.Null_int) {
|
||||
else if (Php_utl_.isset(handlerParams.width)) {
|
||||
width = handlerParams.width;
|
||||
}
|
||||
else {
|
||||
@ -74,7 +81,7 @@ public abstract class Xomw_ImageHandler extends Xomw_MediaHandler { private fina
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
|
||||
// function getScriptParams(paramsVar) {
|
||||
// return [ 'width' => paramsVar['width'] ];
|
||||
// }
|
||||
@ -122,7 +129,7 @@ public abstract class Xomw_ImageHandler extends Xomw_MediaHandler { private fina
|
||||
handlerParams.physicalWidth = handlerParams.width;
|
||||
} else {
|
||||
// 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.*;
|
||||
import gplx.langs.htmls.*;
|
||||
import gplx.langs.phps.utls.*;
|
||||
import gplx.xowa.mws.utls.*;
|
||||
import gplx.xowa.mws.filerepo.file.*;
|
||||
public 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 abstract class Xomw_MediaTransformOutput {
|
||||
public Xomw_MediaTransformOutput(Xomw_File file, byte[] url, byte[] path, int width, int height) {
|
||||
// this.file = file;
|
||||
this.url = url;
|
||||
this.width = width;
|
||||
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
|
||||
*/
|
||||
@ -44,114 +70,207 @@ public class Xomw_MediaTransformOutput {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
// Return HTML <img ... /> tag for the thumbnail, will include
|
||||
// width and height attributes and a blank alt text (as required).
|
||||
//
|
||||
// @param array options Associative array of options. Boolean options
|
||||
// should be indicated with a value of true for true, and false or
|
||||
// absent for false.
|
||||
//
|
||||
// alt HTML alt attribute
|
||||
// title HTML title attribute
|
||||
// desc-link Boolean, show a description link
|
||||
// file-link Boolean, show a file download link
|
||||
// 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 params
|
||||
// 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)
|
||||
// custom-url-link Custom URL to link to
|
||||
// custom-title-link Custom Title Object to link to
|
||||
// custom target-link Value of the target attribute, for custom-target-link
|
||||
// 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
|
||||
//
|
||||
// For images, desc-link and file-link are implemented as a click-through. For
|
||||
// sounds and videos, they may be displayed in other ways.
|
||||
// XO.MW:SYNC:1.29; DATE:2017-02-03
|
||||
public void To_html(Bry_bfr bfr, Bry_bfr tmp, Xomw_MediaTransformOutputParams options) {
|
||||
byte[] alt = options.alt;
|
||||
|
||||
// byte[] query = options.desc_query;
|
||||
|
||||
attribs.Clear();
|
||||
attribs.Add_many(Gfh_atr_.Bry__alt, alt);
|
||||
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'],
|
||||
// $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));
|
||||
attribs.Add_many(Gfh_atr_.Bry__height, Int_.To_bry(height));
|
||||
}
|
||||
if (!Php_utl_.Empty(options.valign)) {
|
||||
attribs.Add_many(Gfh_atr_.Bry__style, Bry_.Add(Bry__vertical_align, options.valign));
|
||||
}
|
||||
if (!Php_utl_.Empty(options.img_cls)) {
|
||||
attribs.Add_many(Gfh_atr_.Bry__class, options.img_cls);
|
||||
}
|
||||
if (Php_utl_.Is_set(options.override_height)) {
|
||||
attribs.Add_many(Gfh_atr_.Bry__class, options.override_height);
|
||||
}
|
||||
if (Php_utl_.Is_set(options.override_width)) {
|
||||
attribs.Add_many(Gfh_atr_.Bry__width, options.override_height);
|
||||
}
|
||||
|
||||
// Additional densities for responsive images, if specified.
|
||||
// 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)) {
|
||||
// $attribs['srcset'] = Html::srcSet($responsiveUrls);
|
||||
// /**
|
||||
// * @return File
|
||||
// */
|
||||
// public function getFile() {
|
||||
// return $this->file;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Get the final extension of the thumbnail.
|
||||
// * Returns false for scripted transformations.
|
||||
// * @return String|boolean
|
||||
// */
|
||||
// public function getExtension() {
|
||||
// return $this->path ? FileBackend::extensionFromPath( $this->path ) : false;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return String|boolean The thumbnail URL
|
||||
// */
|
||||
// public function getUrl() {
|
||||
// return $this->url;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return String|boolean The permanent thumbnail storage path
|
||||
// */
|
||||
// public function getStoragePath() {
|
||||
// return $this->storagePath;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @param String $storagePath The permanent storage path
|
||||
// * @return void
|
||||
// */
|
||||
// public function setStoragePath( $storagePath ) {
|
||||
// $this->storagePath = $storagePath;
|
||||
// if ( $this->path === false ) {
|
||||
// $this->path = $storagePath;
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Fetch HTML for this transform output
|
||||
*
|
||||
* @param array $options Associative array of options. Boolean options
|
||||
* should be indicated with a value of true for true, and false or
|
||||
* absent for false.
|
||||
*
|
||||
* alt Alternate text or caption
|
||||
* desc-link Boolean, show a description link
|
||||
* file-link Boolean, show a file download link
|
||||
* custom-url-link Custom URL to link to
|
||||
* custom-title-link Custom Title Object to link to
|
||||
* 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
|
||||
*
|
||||
* 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);
|
||||
|
||||
// /**
|
||||
// * This will be overridden to return true in error classes
|
||||
// * @return boolean
|
||||
// */
|
||||
// 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
|
||||
// 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) {
|
||||
Xomw_xml.Tags(bfr, Gfh_tag_.Bry__a, link_attribs, contents);
|
||||
}
|
||||
@ -159,5 +278,4 @@ public class Xomw_MediaTransformOutput {
|
||||
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/>.
|
||||
*/
|
||||
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.filerepo.file.*;
|
||||
// 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.
|
||||
* 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.
|
||||
@ -78,7 +83,7 @@ public class Xomw_ThumbnailImage extends Xomw_MediaTransformOutput { /**
|
||||
* file-link Boolean, show a file download link
|
||||
* 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
|
||||
* desc-query String, description link query prms
|
||||
* @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
|
||||
@ -96,80 +101,110 @@ public class Xomw_ThumbnailImage extends Xomw_MediaTransformOutput { /**
|
||||
* @throws MWException
|
||||
* @return String
|
||||
*/
|
||||
// function toHtml(options = ...) {
|
||||
// if (count(func_get_args()) == 2) {
|
||||
// throw new MWException(__METHOD__ . ' called in the old style');
|
||||
// }
|
||||
//
|
||||
// alt = isset(options['alt']) ? options['alt'] : '';
|
||||
//
|
||||
// query = isset(options['desc-query']) ? options['desc-query'] : '';
|
||||
//
|
||||
// attribs = [
|
||||
// 'alt' => alt,
|
||||
// 'src' => this->url,
|
||||
// ];
|
||||
//
|
||||
// if (!empty(options['custom-url-link'])) {
|
||||
// linkAttribs = [ 'href' => options['custom-url-link'] ];
|
||||
// if (!empty(options['title'])) {
|
||||
// linkAttribs['title'] = options['title'];
|
||||
// }
|
||||
// if (!empty(options['custom-target-link'])) {
|
||||
// linkAttribs['target'] = options['custom-target-link'];
|
||||
// } elseif (!empty(options['parser-extlink-target'])) {
|
||||
// linkAttribs['target'] = options['parser-extlink-target'];
|
||||
// }
|
||||
// if (!empty(options['parser-extlink-rel'])) {
|
||||
// linkAttribs['rel'] = options['parser-extlink-rel'];
|
||||
// }
|
||||
// } elseif (!empty(options['custom-title-link'])) {
|
||||
// /** @var Title title */
|
||||
// title = options['custom-title-link'];
|
||||
// linkAttribs = [
|
||||
// 'href' => title->getLinkURL(),
|
||||
// 'title' => empty(options['title']) ? title->getFullText() : options['title']
|
||||
// ];
|
||||
// } elseif (!empty(options['desc-link'])) {
|
||||
// linkAttribs = this->getDescLinkAttribs(
|
||||
// Return HTML <img ... /> tag for the thumbnail, will include
|
||||
// width and height attributes and a blank alt text (as required).
|
||||
//
|
||||
// @param array options Associative array of options. Boolean options
|
||||
// should be indicated with a value of true for true, and false or
|
||||
// absent for false.
|
||||
//
|
||||
// alt HTML alt attribute
|
||||
// title HTML title attribute
|
||||
// desc-link Boolean, show a description link
|
||||
// file-link Boolean, show a file download link
|
||||
// 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
|
||||
// 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)
|
||||
// custom-url-link Custom URL to link to
|
||||
// custom-title-link Custom Title Object to link to
|
||||
// custom target-link Value of the target attribute, for custom-target-link
|
||||
// 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
|
||||
//
|
||||
// For images, desc-link and file-link are implemented as a click-through. For
|
||||
// sounds and videos, they may be displayed in other ways.
|
||||
// XO.MW:SYNC:1.29; DATE:2017-02-03
|
||||
@Override public void toHtml(Bry_bfr bfr, Bry_bfr tmp, Xomw_MediaTransformOutputParams options) {
|
||||
byte[] alt = options.alt;
|
||||
|
||||
// byte[] query = options.desc_query;
|
||||
|
||||
attribs.Clear();
|
||||
attribs.Add_many(Gfh_atr_.Bry__alt, alt);
|
||||
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'],
|
||||
// query
|
||||
// $query
|
||||
// );
|
||||
// } elseif (!empty(options['file-link'])) {
|
||||
// linkAttribs = [ 'href' => this->file->getUrl() ];
|
||||
// } else {
|
||||
// linkAttribs = false;
|
||||
// if (!empty(options['title'])) {
|
||||
// attribs['title'] = options['title'];
|
||||
// }
|
||||
}
|
||||
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));
|
||||
attribs.Add_many(Gfh_atr_.Bry__height, Int_.To_bry(height));
|
||||
}
|
||||
if (!Php_utl_.Empty(options.valign)) {
|
||||
attribs.Add_many(Gfh_atr_.Bry__style, Bry_.Add(Bry__vertical_align, options.valign));
|
||||
}
|
||||
if (!Php_utl_.Empty(options.img_cls)) {
|
||||
attribs.Add_many(Gfh_atr_.Bry__class, options.img_cls);
|
||||
}
|
||||
if (Php_utl_.isset(options.override_height)) {
|
||||
attribs.Add_many(Gfh_atr_.Bry__class, options.override_height);
|
||||
}
|
||||
if (Php_utl_.isset(options.override_width)) {
|
||||
attribs.Add_many(Gfh_atr_.Bry__width, options.override_height);
|
||||
}
|
||||
|
||||
// Additional densities for responsive images, if specified.
|
||||
// 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)) {
|
||||
// $attribs['srcset'] = Html::srcSet($responsiveUrls);
|
||||
// }
|
||||
//
|
||||
// if (empty(options['no-dimensions'])) {
|
||||
// attribs['width'] = this->width;
|
||||
// attribs['height'] = this->height;
|
||||
// }
|
||||
// if (!empty(options['valign'])) {
|
||||
// attribs['style'] = "vertical-align: {options['valign']}";
|
||||
// }
|
||||
// if (!empty(options['img-class'])) {
|
||||
// attribs['class'] = options['img-class'];
|
||||
// }
|
||||
// if (isset(options['override-height'])) {
|
||||
// attribs['height'] = options['override-height'];
|
||||
// }
|
||||
// if (isset(options['override-width'])) {
|
||||
// attribs['width'] = options['override-width'];
|
||||
// }
|
||||
//
|
||||
// // Additional densities for responsive images, if specified.
|
||||
// // 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)) {
|
||||
// attribs['srcset'] = Html::srcSet(responsiveUrls);
|
||||
// }
|
||||
//
|
||||
// Hooks::run('ThumbnailBeforeProduceHTML', [ this, &attribs, &linkAttribs ]);
|
||||
//
|
||||
// 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.
|
||||
* @return boolean
|
||||
*/
|
||||
@Override public boolean normaliseParams(Xomw_File image, Xomw_params_handler handlerParams) {
|
||||
if (!super.normaliseParams(image, handlerParams)) {
|
||||
@Override public boolean normaliseParams(Xomw_File image, Xomw_params_handler prms) {
|
||||
if (!super.normaliseParams(image, prms)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Obtain the source, pre-rotation dimensions
|
||||
int srcWidth = image.getWidth(handlerParams.page);
|
||||
int srcHeight = image.getHeight(handlerParams.page);
|
||||
int srcWidth = image.getWidth(prms.page);
|
||||
int srcHeight = image.getHeight(prms.page);
|
||||
|
||||
// Don't make an image bigger than the source
|
||||
if (handlerParams.physicalWidth >= srcWidth) {
|
||||
handlerParams.physicalWidth = srcWidth;
|
||||
handlerParams.physicalHeight = srcHeight;
|
||||
if (prms.physicalWidth >= srcWidth) {
|
||||
prms.physicalWidth = srcWidth;
|
||||
prms.physicalHeight = srcHeight;
|
||||
|
||||
// Skip scaling limit checks if no scaling is required
|
||||
// due to requested size being bigger than source.
|
||||
@ -90,7 +90,7 @@ public class Xomw_TransformationalImageHandler extends Xomw_ImageHandler { publi
|
||||
* @param int flags
|
||||
* @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)) {
|
||||
// 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
|
||||
Xomw_params_scalar scalerParams = new Xomw_params_scalar();
|
||||
// // The size to which the image will be resized
|
||||
scalerParams.physicalWidth = handlerParams.physicalWidth;
|
||||
scalerParams.physicalHeight = handlerParams.physicalHeight;
|
||||
scalerParams.physicalWidth = prms.physicalWidth;
|
||||
scalerParams.physicalHeight = prms.physicalHeight;
|
||||
// 'physicalDimensions' => "{paramsVar['physicalWidth']}x{paramsVar['physicalHeight']}",
|
||||
// The size of the image on the page
|
||||
scalerParams.clientWidth = handlerParams.width;
|
||||
scalerParams.clientHeight = handlerParams.height;
|
||||
scalerParams.clientWidth = prms.width;
|
||||
scalerParams.clientHeight = prms.height;
|
||||
// Comment as will be added to the Exif of the thumbnail
|
||||
// 'comment' => isset(paramsVar['descriptionUrl'])
|
||||
// ? "File source: {paramsVar['descriptionUrl']}"
|
||||
@ -173,7 +173,7 @@ public class Xomw_TransformationalImageHandler extends Xomw_ImageHandler { publi
|
||||
// newParams['page'] = paramsVar['page'];
|
||||
// }
|
||||
// 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
|
||||
@ -319,11 +319,11 @@ public class Xomw_TransformationalImageHandler extends Xomw_ImageHandler { publi
|
||||
* @todo FIXME: No rotation support
|
||||
*/
|
||||
private Xomw_ThumbnailImage getClientScalingThumbnailImage(Xomw_File image, Xomw_params_scalar scalerParams) {
|
||||
Xomw_params_handler handler_params = new Xomw_params_handler();
|
||||
handler_params.width = scalerParams.clientWidth;
|
||||
handler_params.height = scalerParams.clientHeight;
|
||||
Xomw_params_handler prms = new Xomw_params_handler();
|
||||
prms.width = scalerParams.clientWidth;
|
||||
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.*;
|
||||
import gplx.core.btries.*;
|
||||
import gplx.langs.htmls.*;
|
||||
import gplx.langs.phps.utls.*;
|
||||
import gplx.xowa.mws.utls.*;
|
||||
public class Xomw_block_level_pass {
|
||||
private final Bry_bfr tmp = Bry_bfr_.New();
|
||||
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/>.
|
||||
*/
|
||||
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
|
||||
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);
|
||||
|
@ -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.*;
|
||||
import gplx.core.btries.*; import gplx.core.primitives.*;
|
||||
import gplx.langs.phps.utls.*;
|
||||
import gplx.xowa.mws.utls.*;
|
||||
import gplx.xowa.mws.htmls.*;
|
||||
/* TODO.XO
|
||||
* 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.*;
|
||||
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.mws.parsers.*; import gplx.xowa.mws.parsers.quotes.*;
|
||||
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.parsers.uniqs.*;
|
||||
/* 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
|
||||
// XO.MW.NOTE: for MW, "" -> null, null while "AxB" -> 0x0
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
|
@ -54,6 +54,4 @@ public class Xomw_param_itm {
|
||||
public static final byte[]
|
||||
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/>.
|
||||
*/
|
||||
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 int width;
|
||||
public int height;
|
||||
@ -24,7 +25,7 @@ public class Xomw_params_handler {
|
||||
public int physicalHeight;
|
||||
public Xomw_params_handler Clear() {
|
||||
width = height = page
|
||||
= physicalWidth = physicalHeight = Xomw_param_itm.Null_int;
|
||||
= physicalWidth = physicalHeight = Php_utl_.Null_int;
|
||||
return this;
|
||||
}
|
||||
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/>.
|
||||
*/
|
||||
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 int physicalWidth;
|
||||
public int physicalHeight;
|
||||
@ -30,6 +31,6 @@ public class Xomw_params_scalar {
|
||||
public byte[] dstUrl;
|
||||
public byte[] interlace;
|
||||
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.*;
|
||||
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.*;
|
||||
// TODO.XO: this->getConverterLanguage()->markNoConversion($url, true),
|
||||
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.*;
|
||||
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
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.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/>.
|
||||
*/
|
||||
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.core.primitives.*;
|
||||
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/>.
|
||||
*/
|
||||
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.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
|
||||
|
@ -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
|
||||
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 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);}
|
@ -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
|
||||
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 static byte[] rawurlencode(byte[] 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
|
||||
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.primitives.*;
|
||||
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
|
||||
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.*;
|
||||
public class Php_preg___tst {
|
||||
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
|
||||
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.*;
|
||||
public class Php_str_ {
|
||||
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
|
||||
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.*;
|
||||
public class Php_str___tst {
|
||||
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
|
||||
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 static boolean Empty(byte[] v) {return v == null || v.length == 0;}
|
||||
public static boolean Empty(boolean v) {return v == false;}
|
||||
public static boolean Is_set(byte[] v) {return v != null;}
|
||||
public static boolean isset(int v) {return v != Int_.Max_value;}
|
||||
public static boolean isset(byte[] v) {return v != null;}
|
||||
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) {
|
||||
if (src == null) return false;
|
||||
int len = src.length;
|
||||
@ -36,4 +37,5 @@ public class Php_utl_ {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public static final int Null_int = Int_.Max_value;
|
||||
}
|
Loading…
Reference in New Issue
Block a user