Extensión:HideCategorizedOrphans

From MediaWiki.org
Jump to navigation Jump to search
This page is a translated version of the page Extension:HideCategorizedOrphans and the translation is 38% complete.

Other languages:
Deutsch • ‎English • ‎español • ‎polski • ‎sicilianu • ‎日本語
MediaWiki extensions manual
OOjs UI icon advanced.svg
HideCategorizedOrphans
Release status: beta
Implementación MyWiki
Descripción Makes MediaWiki consider pages that belong to a category not be orphans
Autor(es) Steven Orvis (Sorvistalk)
Última versión 0.2.0 (2014-06-09)
MediaWiki 1.23+
PHP 5.3+
Cambios de la base de datos No
Licencia GNU General Public License 2.0 or later
Descarga See the code section
Hooks que usa
LonelyPagesQuery
Translate the HideCategorizedOrphans extension if it is available at translatewiki.net
Verificar uso y versión de la matriz.

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.

Instalación

  • Copy the code into files y extrae los archivos en el directorio «HideCategorizedOrphans» dentro del directorio extensions/ existente.
  • Añade el siguiente código a tu LocalSettings.php (preferiblemente al final):
    require_once "$IP/extensions/HideCategorizedOrphans/HideCategorizedOrphans.php";
    
  • Yes Listo – Navega a Special:Version en tu wiki para verificar que la apariencia se haya instalado correctamente.

Código

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;
        }
}