mediawiki/alink 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mediawiki/alink

Composer 安装命令:

composer require mediawiki/alink

包简介

Creates custom anchor links

README 文档

README

MediaWiki extension (type: parserhook) that provides two parser functions for rendering raw HTML <a> and <img> tags with full attribute control.

Installation

  1. Clone or extract into extensions/Alink/.
  2. Add to LocalSettings.php:
    wfLoadExtension( 'Alink' );

Parser functions

#alink — anchor tag

{{#alink: href=<url or wiki page> | <attributes> | <flags> | link text }}

Allowed attributes: href, rel, target, class, id, content, name, itemprop, and any data-* attribute.

Flags (no = sign):

Flag Effect
nourlencode Skip urlencode() on the page name (useful for query strings with special characters)
noprefix Strip namespace prefix from auto-generated link text

Link text is the bare argument (no =). If omitted, falls back to the href value; with noprefix, falls back to the page title without namespace.

Internal vs external links: if href starts with http://, https://, or ftp://, the value is used as-is. Otherwise it is treated as a wiki page name and resolved through $wgArticlePath.

Examples

External link:

{{#alink: href=https://www.mediawiki.org | target=_blank | rel=nofollow | MediaWiki }}

Internal wiki page:

{{#alink: href=Example_page | target=_blank | Example page }}

Internal link with special characters in query string (skip URL encoding):

{{#alink: href=Special:FormEdit/Myform/Mypage?MyTemplate[Myparam]=Acción | nourlencode | Trigger action }}

Internal link, display title without namespace:

{{#alink: href=User:John_Smith | noprefix }}

With data-* attribute:

{{#alink: href=Main_Page | data-tracking=nav | Home }}

#aimg — image tag

{{#aimg: src=<url or file name> | <attributes> }}

Allowed attributes: src, rel, title, alt, class, id, content, itemprop, and any data-* attribute.

If src does not start with a recognized protocol, it is treated as a MediaWiki file name and resolved to its full URL via wfFindFile(). If the file does not exist in the wiki, src is left unchanged.

Examples

External image:

{{#aimg: src=https://example.com/logo.png | alt=Logo | class=site-logo }}

Wiki-hosted file:

{{#aimg: src=Example.png | alt=Example image | title=An example }}

Development

Install dependencies:

composer install

Lint (syntax check + executable-bit check):

composer test

Fix executable bits:

composer fix

PHP CodeSniffer (requires mediawiki/mediawiki-codesniffer installed separately):

vendor/bin/phpcs

There are no automated unit tests. Manual testing requires a running MediaWiki instance with the extension loaded.

Notes

  • Output is passed through $parser->insertStripItem() to prevent further wiki parsing of the raw HTML.
  • Using raw <a> tags bypasses MediaWiki's link tracking (incoming/outgoing links are not recorded in the database). Use standard wikitext links when link tracking matters.

mediawiki/alink 适用场景与选型建议

mediawiki/alink 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 296 次下载、GitHub Stars 达 1, 最近一次更新时间为 2014 年 11 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「link」 「mediawiki」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 mediawiki/alink 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mediawiki/alink 我们能提供哪些服务?
定制开发 / 二次开发

基于 mediawiki/alink 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 296
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 19
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2014-11-13