1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

Xomw: Change Php classes to Xophp; move to root namespace

This commit is contained in:
gnosygnu
2017-02-24 07:56:49 -05:00
parent a8c7f27ff5
commit d8c2eaba1d
42 changed files with 408 additions and 864 deletions

View File

@@ -15,7 +15,6 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes.media; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*;
import gplx.xowa.mediawiki.includes.filerepo.file.*; import gplx.xowa.mediawiki.includes.parsers.lnkis.*;
import gplx.xowa.mediawiki.includes.utls.*;
/* XO.TODO:
* validateThumbParams
*/
@@ -29,7 +28,7 @@ public abstract class XomwImageHandler extends XomwMediaHandler { private final
* @return boolean
*/
@Override public boolean canRender(XomwFile file) {
return (Php_utl_.istrue(file.getWidth()) && Php_utl_.istrue(file.getHeight()));
return (XophpUtility.istrue(file.getWidth()) && XophpUtility.istrue(file.getHeight()));
}
@Override public Xomw_param_map getParamMap() {
@@ -53,10 +52,10 @@ public abstract class XomwImageHandler extends XomwMediaHandler { private final
@Override public byte[] makeParamString(Xomw_params_handler handlerParams) {
int width = 0;
if (Php_utl_.isset(handlerParams.physicalWidth)) {
if (XophpUtility.isset(handlerParams.physicalWidth)) {
width = handlerParams.physicalWidth;
}
else if (Php_utl_.isset(handlerParams.width)) {
else if (XophpUtility.isset(handlerParams.width)) {
width = handlerParams.width;
}
else {
@@ -77,7 +76,7 @@ public abstract class XomwImageHandler extends XomwMediaHandler { private final
// pos = Bry_find_.Find_fwd_while_num(src, 1, len); // skip numeric
// if (Bry_.Match(src, pos, len, Xomw_lnki_wkr.Bry__px)) { // matches "px"
// Xomw_params_handler rv = new Xomw_params_handler();
// rv.width = Bry_.To_int_or(src, 0, pos, Php_utl_.Null_int);
// rv.width = Bry_.To_int_or(src, 0, pos, XophpUtility.Null_int);
// return rv;
// }
// }
@@ -96,11 +95,11 @@ public abstract class XomwImageHandler extends XomwMediaHandler { private final
@Override public boolean normaliseParams(XomwFile image, Xomw_params_handler handlerParams) {
byte[] mimeType = image.getMimeType();
if (!Php_utl_.isset(handlerParams.width)) {
if (!XophpUtility.isset(handlerParams.width)) {
return false;
}
if (!Php_utl_.isset(handlerParams.page)) {
if (!XophpUtility.isset(handlerParams.page)) {
handlerParams.page = 1;
}
else {
@@ -117,7 +116,7 @@ public abstract class XomwImageHandler extends XomwMediaHandler { private final
int srcWidth = image.getWidth(handlerParams.page);
int srcHeight = image.getHeight(handlerParams.page);
if (Php_utl_.isset(handlerParams.height) && handlerParams.height != -1) {
if (XophpUtility.isset(handlerParams.height) && handlerParams.height != -1) {
// Height & width were both set
if (handlerParams.width * srcHeight > handlerParams.height * srcWidth) {
// Height is the relative smaller dimension, so scale width accordingly
@@ -131,11 +130,11 @@ public abstract class XomwImageHandler extends XomwMediaHandler { private final
handlerParams.physicalWidth = handlerParams.width;
} else {
// Height was crap, unset it so that it will be calculated later
handlerParams.height = Php_utl_.Null_int;
handlerParams.height = XophpUtility.Null_int;
}
}
if (!Php_utl_.isset(handlerParams.physicalWidth)) {
if (!XophpUtility.isset(handlerParams.physicalWidth)) {
// Passed all validations, so set the physicalWidth
handlerParams.physicalWidth = handlerParams.width;
}
@@ -147,7 +146,7 @@ public abstract class XomwImageHandler extends XomwMediaHandler { private final
handlerParams.physicalWidth);
// Set the height if it was not validated in the if block higher up
if (!Php_utl_.isset(handlerParams.height) || handlerParams.height == -1) {
if (!XophpUtility.isset(handlerParams.height) || handlerParams.height == -1) {
handlerParams.height = handlerParams.physicalHeight;
}

View File

@@ -15,7 +15,6 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes.media; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*;
import org.junit.*; import gplx.core.tests.*;
import gplx.xowa.mediawiki.includes.utls.*;
import gplx.xowa.mediawiki.includes.parsers.*; import gplx.xowa.mediawiki.includes.parsers.lnkis.*;
import gplx.xowa.mediawiki.includes.filerepo.*; import gplx.xowa.mediawiki.includes.filerepo.file.*;
public class XomwImageHandlerTest {
@@ -36,7 +35,7 @@ class XomwImageHandler_fxt {
public XomwImageHandler_fxt() {
handler = new XomwTransformationalImageHandler(Bry_.new_a7("test_handler"));
}
public Xomw_params_handler Make__handlerParams(int w) {return Make__handlerParams(w, Php_utl_.Null_int, Php_utl_.Null_int, Php_utl_.Null_int);}
public Xomw_params_handler Make__handlerParams(int w) {return Make__handlerParams(w, XophpUtility.Null_int, XophpUtility.Null_int, XophpUtility.Null_int);}
public Xomw_params_handler Make__handlerParams(int w, int h, int phys_w, int phys_h) {
Xomw_params_handler rv = new Xomw_params_handler();
rv.width = w;

View File

@@ -15,7 +15,6 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes.media; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*;
import gplx.langs.htmls.*;
import gplx.xowa.mediawiki.includes.utls.*;
import gplx.xowa.mediawiki.includes.parsers.lnkis.*;
import gplx.xowa.mediawiki.includes.filerepo.file.*;
public abstract class XomwMediaTransformOutput {

View File

@@ -15,7 +15,6 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes.media; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.includes.*;
import gplx.langs.htmls.*;
import gplx.xowa.mediawiki.includes.utls.*;
import gplx.xowa.mediawiki.includes.parsers.lnkis.*;
import gplx.xowa.mediawiki.includes.filerepo.file.*;
// Media transform output for images
@@ -136,71 +135,71 @@ public class XomwThumbnailImage extends XomwMediaTransformOutput { private final
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)) {
if (!XophpUtility.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)) {
if (!XophpUtility.empty(options.title)) {
link_attribs.Add_many(Gfh_atr_.Bry__title, options.title);
}
if (Php_utl_.empty(options.custom_target_link)) {
if (XophpUtility.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)) {
else if (XophpUtility.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)) {
if (XophpUtility.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)) {
else if (!XophpUtility.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);
// link_attribs.Add_many(Gfh_atr_.Bry__title, XophpUtility.empty(options_title) ? title.Get_full_text() : options_title);
}
else if (!Php_utl_.empty(options.desc_link)) {
else if (!XophpUtility.empty(options.desc_link)) {
// link_attribs = this.getDescLinkAttribs(
// empty(options['title']) ? null : options['title'],
// $query
// );
link_attribs.Clear();
this.getDescLinkAttribs(link_attribs,
Php_utl_.empty(options.title) ? null : options.title,
XophpUtility.empty(options.title) ? null : options.title,
null);
}
else if (!Php_utl_.empty(options.file_link)) {
else if (!XophpUtility.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)) {
if (!XophpUtility.empty(options.title)) {
attribs.Add_many(Gfh_atr_.Bry__title, options.title);
}
}
if (Php_utl_.empty(options.no_dimensions)) {
if (XophpUtility.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)) {
if (!XophpUtility.empty(options.valign)) {
attribs.Add_many(Gfh_atr_.Bry__style, Bry_.Add(Bry__vertical_align, options.valign));
}
if (!Php_utl_.empty(options.img_cls)) {
if (!XophpUtility.empty(options.img_cls)) {
attribs.Add_many(Gfh_atr_.Bry__class, options.img_cls);
}
if (Php_utl_.isset(options.override_height)) {
if (XophpUtility.isset(options.override_height)) {
attribs.Add_many(Gfh_atr_.Bry__class, options.override_height);
}
if (Php_utl_.isset(options.override_width)) {
if (XophpUtility.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)) {
// if (!XophpUtility.empty($responsiveUrls)) {
// $attribs['srcset'] = Html::srcSet($responsiveUrls);
// }