|
|
@ -18,6 +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.btries.*;
|
|
|
|
import gplx.core.btries.*;
|
|
|
|
import gplx.xowa.mws.htmls.*;
|
|
|
|
import gplx.xowa.mws.htmls.*;
|
|
|
|
|
|
|
|
import gplx.xowa.mws.linkers.*;
|
|
|
|
public class Xomw_linker {
|
|
|
|
public class Xomw_linker {
|
|
|
|
private final Bry_bfr tmp = Bry_bfr_.New();
|
|
|
|
private final Bry_bfr tmp = Bry_bfr_.New();
|
|
|
|
private final Linker_rel_splitter splitter = new Linker_rel_splitter();
|
|
|
|
private final Linker_rel_splitter splitter = new Linker_rel_splitter();
|
|
|
@ -27,95 +28,88 @@ public class Xomw_linker {
|
|
|
|
private final byte[][] split_trail_rv = new byte[2][];
|
|
|
|
private final byte[][] split_trail_rv = new byte[2][];
|
|
|
|
private Btrie_slim_mgr split_trail_trie;
|
|
|
|
private Btrie_slim_mgr split_trail_trie;
|
|
|
|
private static final byte[] Atr__class = Bry_.new_a7("class"), Atr__rel = Bry_.new_a7("rel"), Atr__href = Bry_.new_a7("href"), Rel__nofollow = Bry_.new_a7("nofollow");
|
|
|
|
private static final byte[] Atr__class = Bry_.new_a7("class"), Atr__rel = Bry_.new_a7("rel"), Atr__href = Bry_.new_a7("href"), Rel__nofollow = Bry_.new_a7("nofollow");
|
|
|
|
|
|
|
|
private final Xomw_link_renderer link_renderer;
|
|
|
|
|
|
|
|
public Xomw_linker(Xomw_link_renderer link_renderer) {
|
|
|
|
|
|
|
|
this.link_renderer = link_renderer;
|
|
|
|
|
|
|
|
}
|
|
|
|
public void Init_by_wiki(Btrie_slim_mgr trie) {
|
|
|
|
public void Init_by_wiki(Btrie_slim_mgr trie) {
|
|
|
|
this.split_trail_trie = trie;
|
|
|
|
this.split_trail_trie = trie;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// /**
|
|
|
|
// This function returns an HTML link to the given target. It serves a few
|
|
|
|
// * This function returns an HTML link to the given target. It serves a few
|
|
|
|
// purposes:
|
|
|
|
// * purposes:
|
|
|
|
// 1) If $target is a Title, the correct URL to link to will be figured
|
|
|
|
// * 1) If $target is a Title, the correct URL to link to will be figured
|
|
|
|
// out automatically.
|
|
|
|
// * out automatically.
|
|
|
|
// 2) It automatically adds the usual classes for various types of link
|
|
|
|
// * 2) It automatically adds the usual classes for various types of link
|
|
|
|
// targets: "new" for red links, "stub" for short articles, etc.
|
|
|
|
// * targets: "new" for red links, "stub" for short articles, etc.
|
|
|
|
// 3) It escapes all attribute values safely so there's no risk of XSS.
|
|
|
|
// * 3) It escapes all attribute values safely so there's no risk of XSS.
|
|
|
|
// 4) It provides a default tooltip if the target is a Title (the page
|
|
|
|
// * 4) It provides a default tooltip if the target is a Title (the page
|
|
|
|
// name of the target).
|
|
|
|
// * name of the target).
|
|
|
|
// link() replaces the old functions in the makeLink() family.
|
|
|
|
// * link() replaces the old functions in the makeLink() family.
|
|
|
|
|
|
|
|
// *
|
|
|
|
|
|
|
|
// * @since 1.18 Method exists since 1.16 as non-static, made static in 1.18.
|
|
|
|
|
|
|
|
// * @deprecated since 1.28, use MediaWiki\Linker\LinkRenderer instead
|
|
|
|
|
|
|
|
// *
|
|
|
|
|
|
|
|
// * @param Title $target Can currently only be a Title, but this may
|
|
|
|
|
|
|
|
// * change to support Images, literal URLs, etc.
|
|
|
|
|
|
|
|
// * @param String $html The HTML contents of the <a> element, i.e.,
|
|
|
|
|
|
|
|
// * the link text. This is raw HTML and will not be escaped. If null,
|
|
|
|
|
|
|
|
// * defaults to the prefixed text of the Title; or if the Title is just a
|
|
|
|
|
|
|
|
// * fragment, the contents of the fragment.
|
|
|
|
|
|
|
|
// * @param array $customAttribs A key => value array of extra HTML attributes,
|
|
|
|
|
|
|
|
// * such as title and class. (href is ignored.) Classes will be
|
|
|
|
|
|
|
|
// * merged with the default classes, while other attributes will replace
|
|
|
|
|
|
|
|
// * default attributes. All passed attribute values will be HTML-escaped.
|
|
|
|
|
|
|
|
// * A false attribute value means to suppress that attribute.
|
|
|
|
|
|
|
|
// * @param array $query The query String to append to the URL
|
|
|
|
|
|
|
|
// * you're linking to, in key => value array form. Query keys and values
|
|
|
|
|
|
|
|
// * will be URL-encoded.
|
|
|
|
|
|
|
|
// * @param String|array $options String or array of strings:
|
|
|
|
|
|
|
|
// * 'known': Page is known to exist, so don't check if it does.
|
|
|
|
|
|
|
|
// * 'broken': Page is known not to exist, so don't check if it does.
|
|
|
|
|
|
|
|
// * 'noclasses': Don't add any classes automatically (includes "new",
|
|
|
|
|
|
|
|
// * "stub", "mw-redirect", "extiw"). Only use the class attribute
|
|
|
|
|
|
|
|
// * provided, if any, so you get a simple blue link with no funny i-
|
|
|
|
|
|
|
|
// * cons.
|
|
|
|
|
|
|
|
// * 'forcearticlepath': Use the article path always, even with a querystring.
|
|
|
|
|
|
|
|
// * Has compatibility issues on some setups, so avoid wherever possible.
|
|
|
|
|
|
|
|
// * 'http': Force a full URL with http:// as the scheme.
|
|
|
|
|
|
|
|
// * 'https': Force a full URL with https:// as the scheme.
|
|
|
|
|
|
|
|
// * 'stubThreshold' => (int): Stub threshold to use when determining link classes.
|
|
|
|
|
|
|
|
// * @return String HTML <a> attribute
|
|
|
|
|
|
|
|
// */
|
|
|
|
|
|
|
|
// public static function link(
|
|
|
|
|
|
|
|
// $target, $html = null, $customAttribs = [], $query = [], $options = []
|
|
|
|
|
|
|
|
// ) {
|
|
|
|
|
|
|
|
// if ( !$target instanceof Title ) {
|
|
|
|
|
|
|
|
// wfWarn( __METHOD__ . ': Requires $target to be a Title Object.', 2 );
|
|
|
|
|
|
|
|
// return "<!-- ERROR -->$html";
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// if ( is_string( $query ) ) {
|
|
|
|
// @since 1.18 Method exists since 1.16 as non-static, made static in 1.18.
|
|
|
|
// // some functions withing core using this still hand over query strings
|
|
|
|
// @deprecated since 1.28, use MediaWiki\Linker\LinkRenderer instead
|
|
|
|
// wfDeprecated( __METHOD__ . ' with parameter $query as String (should be array)', '1.20' );
|
|
|
|
|
|
|
|
// $query = wfCgiToArray( $query );
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// $services = MediaWikiServices::getInstance();
|
|
|
|
// @param Title $target Can currently only be a Title, but this may
|
|
|
|
// $options = (array)$options;
|
|
|
|
// change to support Images, literal URLs, etc.
|
|
|
|
// if ( $options ) {
|
|
|
|
// @param String $html The HTML contents of the <a> element, i.e.,
|
|
|
|
|
|
|
|
// the link text. This is raw HTML and will not be escaped. If null,
|
|
|
|
|
|
|
|
// defaults to the prefixed text of the Title; or if the Title is just a
|
|
|
|
|
|
|
|
// fragment, the contents of the fragment.
|
|
|
|
|
|
|
|
// @param array $customAttribs A key => value array of extra HTML attributes,
|
|
|
|
|
|
|
|
// such as title and class. (href is ignored.) Classes will be
|
|
|
|
|
|
|
|
// merged with the default classes, while other attributes will replace
|
|
|
|
|
|
|
|
// default attributes. All passed attribute values will be HTML-escaped.
|
|
|
|
|
|
|
|
// A false attribute value means to suppress that attribute.
|
|
|
|
|
|
|
|
// @param array $query The query String to append to the URL
|
|
|
|
|
|
|
|
// you're linking to, in key => value array form. Query keys and values
|
|
|
|
|
|
|
|
// will be URL-encoded.
|
|
|
|
|
|
|
|
// @param String|array $options String or array of strings:
|
|
|
|
|
|
|
|
// 'known': Page is known to exist, so don't check if it does.
|
|
|
|
|
|
|
|
// 'broken': Page is known not to exist, so don't check if it does.
|
|
|
|
|
|
|
|
// 'noclasses': Don't add any classes automatically (includes "new",
|
|
|
|
|
|
|
|
// "stub", "mw-redirect", "extiw"). Only use the class attribute
|
|
|
|
|
|
|
|
// provided, if any, so you get a simple blue link with no funny i-
|
|
|
|
|
|
|
|
// cons.
|
|
|
|
|
|
|
|
// 'forcearticlepath': Use the article path always, even with a querystring.
|
|
|
|
|
|
|
|
// Has compatibility issues on some setups, so avoid wherever possible.
|
|
|
|
|
|
|
|
// 'http': Force a full URL with http:// as the scheme.
|
|
|
|
|
|
|
|
// 'https': Force a full URL with https:// as the scheme.
|
|
|
|
|
|
|
|
// 'stubThreshold' => (int): Stub threshold to use when determining link classes.
|
|
|
|
|
|
|
|
// @return String HTML <a> attribute
|
|
|
|
|
|
|
|
public void Link(Bry_bfr bfr, Xoa_ttl target, byte[] html, Xomw_atr_mgr custom_attribs, Xomw_qry_mgr query, Xomw_opt_mgr options) {
|
|
|
|
|
|
|
|
// XO.MW.UNSUPPORTED:MW has different renderers -- presumably for forcing "https:" and others; XO only has one
|
|
|
|
|
|
|
|
//if (options != null) {
|
|
|
|
// // Custom options, create new LinkRenderer
|
|
|
|
// // Custom options, create new LinkRenderer
|
|
|
|
// if (!isset($options['stubThreshold'])) {
|
|
|
|
// if (!isset($options['stubThreshold'])) {
|
|
|
|
// $defaultLinkRenderer = $services->getLinkRenderer();
|
|
|
|
// $defaultLinkRenderer = $services->getLinkRenderer();
|
|
|
|
// $options['stubThreshold'] = $defaultLinkRenderer->getStubThreshold();
|
|
|
|
// $options['stubThreshold'] = $defaultLinkRenderer->getStubThreshold();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// $linkRenderer = $services->getLinkRendererFactory()
|
|
|
|
// $linkRenderer = $services->getLinkRendererFactory()->createFromLegacyOptions($options);
|
|
|
|
// ->createFromLegacyOptions( $options );
|
|
|
|
//}
|
|
|
|
// } else {
|
|
|
|
//else {
|
|
|
|
// $linkRenderer = $services->getLinkRenderer();
|
|
|
|
// $linkRenderer = $services->getLinkRenderer();
|
|
|
|
//}
|
|
|
|
//}
|
|
|
|
//
|
|
|
|
|
|
|
|
// if ( $html !== null ) {
|
|
|
|
byte[] text = null;
|
|
|
|
|
|
|
|
if (html != null) {
|
|
|
|
// $text = new HtmlArmor($html);
|
|
|
|
// $text = new HtmlArmor($html);
|
|
|
|
// } else {
|
|
|
|
}
|
|
|
|
// $text = $html; // null
|
|
|
|
else {
|
|
|
|
// }
|
|
|
|
text = html; // null
|
|
|
|
// if ( in_array( 'known', $options, true ) ) {
|
|
|
|
}
|
|
|
|
// return $linkRenderer->makeKnownLink( $target, $text, $customAttribs, $query );
|
|
|
|
if (options.known) {
|
|
|
|
// } elseif ( in_array( 'broken', $options, true ) ) {
|
|
|
|
link_renderer.Make_known_link(bfr, target, text, custom_attribs, query);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (options.broken) {
|
|
|
|
// return $linkRenderer->makeBrokenLink($target, $text, $customAttribs, $query);
|
|
|
|
// return $linkRenderer->makeBrokenLink($target, $text, $customAttribs, $query);
|
|
|
|
// } elseif ( in_array( 'noclasses', $options, true ) ) {
|
|
|
|
}
|
|
|
|
// return $linkRenderer->makePreloadedLink( $target, $text, '', $customAttribs, $query );
|
|
|
|
else if (options.no_classes) {
|
|
|
|
// } else {
|
|
|
|
link_renderer.Make_preloaded_link(bfr, target, text, Bry_.Empty, custom_attribs, query);
|
|
|
|
// return $linkRenderer->makeLink( $target, $text, $customAttribs, $query );
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
else {
|
|
|
|
// }
|
|
|
|
// $linkRenderer->makeLink($target, $text, $customAttribs, $query);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
public void Make_self_link_obj(Bry_bfr bfr, Xoa_ttl nt, byte[] html, byte[] query, byte[] trail, byte[] prefix) {
|
|
|
|
public void Make_self_link_obj(Bry_bfr bfr, Xoa_ttl nt, byte[] html, byte[] query, byte[] trail, byte[] prefix) {
|
|
|
|
// MW.HOOK:SelfLinkBegin
|
|
|
|
// MW.HOOK:SelfLinkBegin
|
|
|
|
if (html == Bry_.Empty) {
|
|
|
|
if (html == Bry_.Empty) {
|
|
|
@ -130,12 +124,12 @@ public class Xomw_linker {
|
|
|
|
bfr.Add_str_a7("</strong>");
|
|
|
|
bfr.Add_str_a7("</strong>");
|
|
|
|
bfr.Add(trail);
|
|
|
|
bfr.Add(trail);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public void Make_external_link(Bry_bfr bfr, byte[] url, byte[] text, boolean escape, byte[] link_type, Xomwh_atr_mgr attribs, byte[] title) {
|
|
|
|
public void Make_external_link(Bry_bfr bfr, byte[] url, byte[] text, boolean escape, byte[] link_type, Xomw_atr_mgr attribs, byte[] title) {
|
|
|
|
tmp.Add_str_a7("external");
|
|
|
|
tmp.Add_str_a7("external");
|
|
|
|
if (link_type != null) {
|
|
|
|
if (link_type != null) {
|
|
|
|
tmp.Add_byte_space().Add(link_type);
|
|
|
|
tmp.Add_byte_space().Add(link_type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Xomwh_atr_itm cls_itm = attribs.Get_by_or_make(Atr__class);
|
|
|
|
Xomw_atr_itm cls_itm = attribs.Get_by_or_make(Atr__class);
|
|
|
|
if (cls_itm.Val() != null) {
|
|
|
|
if (cls_itm.Val() != null) {
|
|
|
|
tmp.Add(cls_itm.Val());
|
|
|
|
tmp.Add(cls_itm.Val());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -148,7 +142,7 @@ public class Xomw_linker {
|
|
|
|
title = wg_title;
|
|
|
|
title = wg_title;
|
|
|
|
|
|
|
|
|
|
|
|
byte[] new_rel = Get_external_link_rel(url, title);
|
|
|
|
byte[] new_rel = Get_external_link_rel(url, title);
|
|
|
|
Xomwh_atr_itm cur_rel_atr = attribs.Get_by_or_make(Atr__rel);
|
|
|
|
Xomw_atr_itm cur_rel_atr = attribs.Get_by_or_make(Atr__rel);
|
|
|
|
if (cur_rel_atr.Val() == null) {
|
|
|
|
if (cur_rel_atr.Val() == null) {
|
|
|
|
cur_rel_atr.Val_(new_rel);
|
|
|
|
cur_rel_atr.Val_(new_rel);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -537,18 +531,7 @@ public class Xomw_linker {
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// return [ $this->mImageParams[$handlerClass], $this->mImageParamsMagicArray[$handlerClass] ];
|
|
|
|
// return [ $this->mImageParams[$handlerClass], $this->mImageParamsMagicArray[$handlerClass] ];
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// /**
|
|
|
|
// // Make HTML for a thumbnail including image, border and caption
|
|
|
|
// * Make HTML for a thumbnail including image, border and caption
|
|
|
|
|
|
|
|
// * @param Title $title
|
|
|
|
|
|
|
|
// * @param File|boolean $file File Object or false if it doesn't exist
|
|
|
|
|
|
|
|
// * @param String $label
|
|
|
|
|
|
|
|
// * @param String $alt
|
|
|
|
|
|
|
|
// * @param String $align
|
|
|
|
|
|
|
|
// * @param array $params
|
|
|
|
|
|
|
|
// * @param boolean $framed
|
|
|
|
|
|
|
|
// * @param String $manualthumb
|
|
|
|
|
|
|
|
// * @return String
|
|
|
|
|
|
|
|
// */
|
|
|
|
|
|
|
|
// public static function makeThumbLinkObj(Title $title, $file, $label = '', $alt,
|
|
|
|
// public static function makeThumbLinkObj(Title $title, $file, $label = '', $alt,
|
|
|
|
// $align = 'right', $params = [], $framed = false, $manualthumb = ""
|
|
|
|
// $align = 'right', $params = [], $framed = false, $manualthumb = ""
|
|
|
|
// ) {
|
|
|
|
// ) {
|
|
|
@ -565,16 +548,7 @@ public class Xomw_linker {
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// return self::makeThumbLink2($title, $file, $frameParams, $params);
|
|
|
|
// return self::makeThumbLink2($title, $file, $frameParams, $params);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
|
|
|
|
// /**
|
|
|
|
|
|
|
|
// * @param Title $title
|
|
|
|
|
|
|
|
// * @param File $file
|
|
|
|
|
|
|
|
// * @param array $frameParams
|
|
|
|
|
|
|
|
// * @param array $handlerParams
|
|
|
|
|
|
|
|
// * @param boolean $time
|
|
|
|
|
|
|
|
// * @param String $query
|
|
|
|
|
|
|
|
// * @return String
|
|
|
|
|
|
|
|
// */
|
|
|
|
|
|
|
|
// public static function makeThumbLink2(Title $title, $file, $frameParams = [],
|
|
|
|
// public static function makeThumbLink2(Title $title, $file, $frameParams = [],
|
|
|
|
// $handlerParams = [], $time = false, $query = ""
|
|
|
|
// $handlerParams = [], $time = false, $query = ""
|
|
|
|
// ) {
|
|
|
|
// ) {
|
|
|
@ -606,7 +580,7 @@ public class Xomw_linker {
|
|
|
|
// $outerWidth = $handlerParams['width'] + 2;
|
|
|
|
// $outerWidth = $handlerParams['width'] + 2;
|
|
|
|
// } else {
|
|
|
|
// } else {
|
|
|
|
// if (isset($frameParams['manualthumb'])) {
|
|
|
|
// if (isset($frameParams['manualthumb'])) {
|
|
|
|
// # Use manually specified thumbnail
|
|
|
|
// // Use manually specified thumbnail
|
|
|
|
// $manual_title = Title::makeTitleSafe(NS_FILE, $frameParams['manualthumb']);
|
|
|
|
// $manual_title = Title::makeTitleSafe(NS_FILE, $frameParams['manualthumb']);
|
|
|
|
// if ($manual_title) {
|
|
|
|
// if ($manual_title) {
|
|
|
|
// $manual_img = wfFindFile($manual_title);
|
|
|
|
// $manual_img = wfFindFile($manual_title);
|
|
|
@ -622,8 +596,8 @@ public class Xomw_linker {
|
|
|
|
// $thumb = $file->getUnscaledThumb($handlerParams);
|
|
|
|
// $thumb = $file->getUnscaledThumb($handlerParams);
|
|
|
|
// $noscale = true;
|
|
|
|
// $noscale = 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
|
|
|
|
// $srcWidth = $file->getWidth($page);
|
|
|
|
// $srcWidth = $file->getWidth($page);
|
|
|
|
// if ($srcWidth && !$file->mustRender() && $handlerParams['width'] > $srcWidth) {
|
|
|
|
// if ($srcWidth && !$file->mustRender() && $handlerParams['width'] > $srcWidth) {
|
|
|
|
// $handlerParams['width'] = $srcWidth;
|
|
|
|
// $handlerParams['width'] = $srcWidth;
|
|
|
@ -638,9 +612,9 @@ public class Xomw_linker {
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// # ThumbnailImage::toHtml() already adds page= onto the end of DjVu URLs
|
|
|
|
// // ThumbnailImage::toHtml() already adds page= onto the end of DjVu URLs
|
|
|
|
// # So we don't need to pass it here in $query. However, the URL for the
|
|
|
|
// // So we don't need to pass it here in $query. However, the URL for the
|
|
|
|
// # zoom icon still needs it, so we make a unique query for it. See bug 14771
|
|
|
|
// // zoom icon still needs it, so we make a unique query for it. See bug 14771
|
|
|
|
// $url = $title->getLocalURL($query);
|
|
|
|
// $url = $title->getLocalURL($query);
|
|
|
|
// if ($page) {
|
|
|
|
// if ($page) {
|
|
|
|
// $url = wfAppendQuery($url, [ 'page' => $page ]);
|
|
|
|
// $url = wfAppendQuery($url, [ 'page' => $page ]);
|
|
|
@ -688,18 +662,7 @@ public class Xomw_linker {
|
|
|
|
// $s .= ' <div class="thumbcaption">' . $zoomIcon . $frameParams['caption'] . "</div></div></div>";
|
|
|
|
// $s .= ' <div class="thumbcaption">' . $zoomIcon . $frameParams['caption'] . "</div></div></div>";
|
|
|
|
// return str_replace("\n", ' ', $s);
|
|
|
|
// return str_replace("\n", ' ', $s);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// /**
|
|
|
|
// // Make a "broken" link to an image
|
|
|
|
// * Make a "broken" link to an image
|
|
|
|
|
|
|
|
// *
|
|
|
|
|
|
|
|
// * @since 1.16.3
|
|
|
|
|
|
|
|
// * @param Title $title
|
|
|
|
|
|
|
|
// * @param String $label Link label (plain text)
|
|
|
|
|
|
|
|
// * @param String $query Query String
|
|
|
|
|
|
|
|
// * @param String $unused1 Unused parameter kept for b/c
|
|
|
|
|
|
|
|
// * @param String $unused2 Unused parameter kept for b/c
|
|
|
|
|
|
|
|
// * @param boolean $time A file of a certain timestamp was requested
|
|
|
|
|
|
|
|
// * @return String
|
|
|
|
|
|
|
|
// */
|
|
|
|
|
|
|
|
// public static function makeBrokenImageLinkObj($title, $label = '',
|
|
|
|
// public static function makeBrokenImageLinkObj($title, $label = '',
|
|
|
|
// $query = '', $unused1 = '', $unused2 = '', $time = false
|
|
|
|
// $query = '', $unused1 = '', $unused2 = '', $time = false
|
|
|
|
// ) {
|
|
|
|
// ) {
|
|
|
@ -741,32 +704,14 @@ public class Xomw_linker {
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// return self::link($title, $encLabel, [], wfCgiToArray($query), [ 'known', 'noclasses' ]);
|
|
|
|
// return self::link($title, $encLabel, [], wfCgiToArray($query), [ 'known', 'noclasses' ]);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// /**
|
|
|
|
// // Create a direct link to a given uploaded file.
|
|
|
|
// * Create a direct link to a given uploaded file.
|
|
|
|
|
|
|
|
// *
|
|
|
|
|
|
|
|
// * @since 1.16.3
|
|
|
|
|
|
|
|
// * @param Title $title
|
|
|
|
|
|
|
|
// * @param String $html Pre-sanitized HTML
|
|
|
|
|
|
|
|
// * @param String $time MW timestamp of file creation time
|
|
|
|
|
|
|
|
// * @return String HTML
|
|
|
|
|
|
|
|
// */
|
|
|
|
|
|
|
|
// public static function makeMediaLinkObj($title, $html = '', $time = false) {
|
|
|
|
// public static function makeMediaLinkObj($title, $html = '', $time = false) {
|
|
|
|
// $img = wfFindFile($title, [ 'time' => $time ]);
|
|
|
|
// $img = wfFindFile($title, [ 'time' => $time ]);
|
|
|
|
// return self::makeMediaLinkFile($title, $img, $html);
|
|
|
|
// return self::makeMediaLinkFile($title, $img, $html);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// // Create a direct link to a given uploaded file.
|
|
|
|
// * Create a direct link to a given uploaded file.
|
|
|
|
// // This will make a broken link if $file is false.
|
|
|
|
// * This will make a broken link if $file is false.
|
|
|
|
|
|
|
|
// *
|
|
|
|
|
|
|
|
// * @since 1.16.3
|
|
|
|
|
|
|
|
// * @param Title $title
|
|
|
|
|
|
|
|
// * @param File|boolean $file File Object or false
|
|
|
|
|
|
|
|
// * @param String $html Pre-sanitized HTML
|
|
|
|
|
|
|
|
// * @return String HTML
|
|
|
|
|
|
|
|
// *
|
|
|
|
|
|
|
|
// * @todo Handle invalid or missing images better.
|
|
|
|
|
|
|
|
// */
|
|
|
|
|
|
|
|
// public static function makeMediaLinkFile(Title $title, $file, $html = '') {
|
|
|
|
// public static function makeMediaLinkFile(Title $title, $file, $html = '') {
|
|
|
|
// if ($file && $file->exists()) {
|
|
|
|
// if ($file && $file->exists()) {
|
|
|
|
// $url = $file->getUrl();
|
|
|
|
// $url = $file->getUrl();
|
|
|
@ -797,6 +742,19 @@ public class Xomw_linker {
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// return Html::rawElement('a', $attribs, $html);
|
|
|
|
// return Html::rawElement('a', $attribs, $html);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
public static Xoa_ttl Normalise_special_page(Xoa_ttl target) {
|
|
|
|
|
|
|
|
// if (target.Ns().Id_is_special() && !target.Is_external()) {
|
|
|
|
|
|
|
|
// list($name, $subpage) = SpecialPageFactory::resolveAlias($target->getDBkey());
|
|
|
|
|
|
|
|
// if (!$name) {
|
|
|
|
|
|
|
|
// return $target;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// $ret = SpecialPage::getTitleValueFor($name, $subpage, $target->getFragment());
|
|
|
|
|
|
|
|
// return $ret;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// else {
|
|
|
|
|
|
|
|
return target;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
}
|
|
|
|
private static final byte[] Bry__dot2 = Bry_.new_a7("../");
|
|
|
|
private static final byte[] Bry__dot2 = Bry_.new_a7("../");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
class Linker_rel_splitter implements gplx.core.brys.Bry_split_wkr {
|
|
|
|
class Linker_rel_splitter implements gplx.core.brys.Bry_split_wkr {
|
|
|
|