Extension:YearsOld/es

From MediaWiki.org

Jump to: navigation, search
MediaWiki Extension
Crystal Clear action run.png
YearsOld

Estado release: stable

YearsOld.png
Implementación Tag
Descripción Calcula la cantidad de años pasados desde cierta fecha
Autor(es) Hidalgo Rionda (Hsilamot talk)
Versión (1.1.82) (10 Feb 2007)
MediaWiki 1.10.0
Descarga From Author's Site
Parámetros d="Dia"

m="Mes"
y="Año"

Ejemplo Donde dice "Tengo XX Años"

[edit] ¿Qué hace esta extensión?

Devuelve en un entero la cantidad de años que han pasado desde la fecha dada.

[edit] Uso

En tu artículo solo pon <yearsold d="01" m="01" y="2000"></yearsold> y te devolverá "7" (Hoy es 03 Dic 2007, Asi que han pasado desde ntonces 7 años)

[edit] Instalación

Solo extrae el contenido del Zip y añade la siguiente linea

 require_once( "{$IP}/extensions/YearsOld/YearsOld.php" );

a tu archivo LocalSettings.php.

[edit] Parametros

En el mismo Artículo

d="Día"
m="Mes"
y="Año"

$wgYearsOldLimit = 5000000;

Límite de años a procesar, para evitar ataques con números excesivamente grandes.

[edit] Cambios a LocalSettings.php

require_once("$IP/extensions/YearsOld/YearsOld.php");

[edit] Código

YearsOld tiene solo un archivo:

YearsOld.php

<?php
if (!defined('MEDIAWIKI')) die();
# Not a valid entry point, skip unless MEDIAWIKI is defined
/**
 * Returns Age from the day, month, year given.
 * 2008-02-10 Bug: Using MKTIME just returns with valid unix timestamps, corrected
 * 2008-02-10 Limit: Limit of 5'000'000 years for avoiding abuse
 */
 
$wgExtensionCredits['parserhook'][] = array(
	'name' => 'YearsOld (1.1.82)',
	'author' => 'Hidalgo Rionda',
	'url' => 'http://www.mediawiki.org/wiki/Extension:YearsOld',
	'description' => 'Adds &lt;yearsold d=&quot;DAY&quot; m=&quot;MONTH&quot; y=&quot;YEAR&quot;&gt;&lt;/yearsold&gt; and returns the Years passed since',
);
 
$wgExtensionFunctions[] = 'efYearsOldSetup';
 
function efYearsOldSetup() {
    global $wgParser;
    $wgParser->setHook( 'yearsold', 'efYearsOldRender' );
}
 
function efYearsOldRender( $input, $args, $parser ) {
	global $wgYearsOldLimit;
	if (!$wgYearsOldLimit) { $wgYearsOldLimit = 5000000; }
	$anio = $args["y"];
	if ($anio > ($wgYearsOldLimit - $wgYearsOldLimit - $wgYearsOldLimit) && $anio < $wgYearsOldLimit) {
		$multicin = 0;
		while ($anio < 1950) {
			$anio = $anio + 50;
			$multicin = $multicin + 1;
		}
		while ($anio > 2025) {
			$anio = $anio - 50;
			$multicin = $multicin - 1;
		}
		return htmlspecialchars( (intval(((time() - mktime(0, 0, 0, $args["m"], $args["d"], $anio)) / 60 / 60 / 24 / 365)) + ($multicin * 50)) );
	}
}
?>

[edit] Véase También