Mw_parse: Start porting Title

pull/620/head
gnosygnu 7 years ago
parent 85f05bfd02
commit fdf6c49a05

File diff suppressed because it is too large Load Diff

@ -22,7 +22,7 @@ import gplx.xowa.mws.parsers.lnkis.*;
import gplx.xowa.mws.filerepo.file.*;
public abstract class Xomw_MediaTransformOutput {
public Xomw_MediaTransformOutput(Xomw_File file, byte[] url, byte[] path, int width, int height) {
// this.file = file;
this.file = file;
this.url = url;
this.width = width;
this.height = height;
@ -31,9 +31,9 @@ public abstract class Xomw_MediaTransformOutput {
// * from pixel density (eg 1.5 or 2) to additional URLs.
// */
// public $responsiveUrls = [];
//
// /** @var File */
// private final Xomw_File file;
/** @var File */
private final Xomw_File file;
/** @var int Image width */
protected final int width;
@ -235,15 +235,15 @@ public abstract class Xomw_MediaTransformOutput {
// 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;
/**
* @param String $title
* @param String|array $prms Query parameters to add
* @return array
*/
public void getDescLinkAttribs(List_adp attribs, byte[] title, List_adp prms) {
// if ( is_array( prms ) ) {
// $query = prms;
// } else {
// $query = [];
// }
@ -254,20 +254,18 @@ public abstract class Xomw_MediaTransformOutput {
// $query['lang'] = $this->lang;
// }
//
// if ( is_string( $params ) && $params !== '' ) {
// $query = $params . '&' . wfArrayToCgi( $query );
// if ( is_string( prms ) && prms !== '' ) {
// $query = prms . '&' . wfArrayToCgi( $query );
// }
//
// $attribs = [
// 'href' => $this->file->getTitle()->getLocalURL( $query ),
// 'class' => 'image',
// ];
// if ( $title ) {
// $attribs['title'] = $title;
// }
//
// return $attribs;
// }
attribs.Clear();
// 'href' => $this->file->getTitle()->getLocalURL( $query ),
attribs.Add_many(Gfh_atr_.Bry__href, this.file.getTitle());
attribs.Add_many(Gfh_atr_.Bry__class, Bry__class__image);
if (title != null) {
attribs.Add_many(Gfh_atr_.Bry__title, title);
}
}
// Wrap some XHTML text in an anchor tag with the given attributes
// XO.MW:SYNC:1.29; DATE:2017-02-03
@ -279,4 +277,5 @@ public abstract class Xomw_MediaTransformOutput {
bfr.Add(contents);
}
}
private static final byte[] Bry__class__image = Bry_.new_a7("image");
}

@ -166,6 +166,10 @@ public class Xomw_ThumbnailImage extends Xomw_MediaTransformOutput { private fin
// empty(options['title']) ? null : options['title'],
// $query
// );
link_attribs.Clear();
this.getDescLinkAttribs(link_attribs,
Php_utl_.empty(options.title) ? null : options.title,
null);
}
else if (!Php_utl_.empty(options.file_link)) {
// link_attribs.Clear();

@ -26,13 +26,13 @@ public class Xomw_lnki_wkr__file__tst {
fxt.Init__file("A.png", 300, 200);
}
@Test public void Plain() {
fxt.Test__to_html("[[File:A.png]]", "<a><img alt='A.png' src='/orig/7/70/A.png' /></a>");
fxt.Test__to_html("[[File:A.png]]", "<a href='A.png' class='image'><img alt='A.png' src='/orig/7/70/A.png' /></a>");
}
@Test public void Thumb() {
fxt.Test__to_html("[[File:A.png|thumb]]", "<div class='thumb tright'><div class='thumbinner' style='width:222px;'><a><img alt='A.png' src='/thumb/7/70/A.png/220px-A.png' class='thumbimage' /></a> <div class='thumbcaption'><div class='magnify'><a href='' class='internal'></a></div></div></div></div>");
fxt.Test__to_html("[[File:A.png|thumb]]", "<div class='thumb tright'><div class='thumbinner' style='width:222px;'><a href='A.png' class='image'><img alt='A.png' src='/thumb/7/70/A.png/220px-A.png' class='thumbimage' /></a> <div class='thumbcaption'><div class='magnify'><a href='' class='internal'></a></div></div></div></div>");
}
@Test public void Size() {
fxt.Test__to_html("[[File:A.png|123x456px]]", "<a><img alt='A.png' src='/thumb/7/70/A.png/123px-A.png' /></a>");
fxt.Test__to_html("[[File:A.png|123x456px]]", "<a href='A.png' class='image'><img alt='A.png' src='/thumb/7/70/A.png/123px-A.png' /></a>");
}
@Test public void fitBoxWidth() {
// COMMENT:"Height is the relative smaller dimension, so scale width accordingly"

@ -146,4 +146,7 @@ public class Php_str_ {
}
return dirty ? tmp.To_bry_and_clear() : src;
}
public static byte[] strtr(byte[] src, byte find, byte repl) {
return Bry_.Replace(src, 0, src.length, find, repl);
}
}

Loading…
Cancel
Save