扩展:HideCategorizedOrphans
此扩展在wiki页面上存储其源代码。 请注意此代码可能未审核,或被恶意修改。 其可能包含安全漏洞,不再兼容的过时界面等等。 注意: translatewiki.net 不提供此扩展的本地化更新。 |
此扩展目前不再活跃维护! 尽管它可能仍然工作,但任何错误报告或功能请求将很可能被忽略。 |
HideCategorizedOrphans 发行状态: 不再維護 |
|
---|---|
实现 | MyWiki |
描述 | Makes MediaWiki consider pages that belong to a category not be orphans |
作者 | Steven Orvis (Sorvis留言) |
最新版本 | 0.2.0 (2014-06-09) |
MediaWiki | 1.23+ |
PHP | 5.3+ |
数据库更改 | 否 |
许可协议 | GNU通用公眾授權條款2.0或更新版本 |
下載 | 请查阅代码部分 |
The HideCategorizedOrphans extension makes MediaWiki consider pages that belong to a category not be orphans. This is useful if you want to link to a category off of a page, but the links to that individual page show up nowhere else.
安裝
- Copy the code into files文件,并将其放置在您
extensions/
文件夹中的HideCategorizedOrphans
目录内。 - 将下列代码放置在您的LocalSettings.php 的底部:
require_once "$IP/extensions/HideCategorizedOrphans/HideCategorizedOrphans.php";
- 完成 – 在您的wiki上导航至Special:Version,以验证已成功安装扩展。
代码
- HideCategorizedOrphans.php
<?php
/**
* HideCategoizedOrphans extension
*
* For more info see https://mediawiki.org/wiki/Extension:HideCategorizedOrphans
*
* @file
* @ingroup Extensions
* @author Steven Orvis, 2014
* @license GNU General Public Licence 2.0 or later
*/
$wgExtensionCredits['other'][] = array(
'path' => __FILE__,
'name' => 'HideCategorizedOrphans',
'author' => array(
'Steven Orvis',
),
'version' => '0.2.0',
'url' => 'https://www.mediawiki.org/wiki/Extension:HideCategorizedOrphans',
'descriptionmsg' => 'Hides orphaned pages that belong to a category',
);
/* Setup */
// Register files
$wgAutoloadClasses['HideCategorizedOrphansHooks'] = __DIR__ . '/HideCategorizedOrphans.hooks.php';
// Register hooks
$wgHooks['LonelyPagesQuery'][] = 'HideCategorizedOrphansHooks::onLonelyPagesQuery';
- HideCategorizedOrphans.hooks.php
<?php
/**
* Hooks for HideCategorizedOrphans extension
*
* @file
* @ingroup Extensions
*/
class HideCategorizedOrphansHooks {
/**
* Add condition to LonelyPagesQuery to hide pages in categories
*/
public static function onLonelyPagesQuery( &$tables, &$conds, &$joinConds) {
$joinConds['categorylinks'] = array(
'LEFT JOIN', array(
'cl_from = page_id'
)
);
$tables[] = 'categorylinks';
$conds[] = 'cl_from is null';
return true;
}
}