diff options
Diffstat (limited to 'bin/wiki/ListarPaginas.php')
-rw-r--r-- | bin/wiki/ListarPaginas.php | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/bin/wiki/ListarPaginas.php b/bin/wiki/ListarPaginas.php new file mode 100644 index 00000000..96a4d6ef --- /dev/null +++ b/bin/wiki/ListarPaginas.php @@ -0,0 +1,66 @@ +<?php +# ---- +# Copyright (C) 2013-2020 - Reevo Project (http://reevo.org) +# License: Affero GPL version 3 - http://www.gnu.org/licenses/agpl.html +# ES: Este script recibe el nombre de una Plantilla o Categoría y lista todas las paginas que lo usan. +# Se usa con: php ListarPaginas.php "Categoría:Experiencia" +# ---- + + +// error_reporting(0); +// Load all the stuff +require_once( __DIR__ . '/vendor/autoload.php' ); +require_once( __DIR__ .'/../../etc/global_config.php' ); + +// Log in to a wiki +$api = new \Mediawiki\Api\MediawikiApi( $wgServer .'/api.php' ); +$api->login( new \Mediawiki\Api\ApiUser( $REEVO_WIKI_API_USER, $REEVO_WIKI_API_PASS ) ); +$services = new \Mediawiki\Api\MediawikiFactory( $api ); + +// Obtengo el nombre del template como parámetro +if ($argv[1]) { + + $pageListGetter = $services->newPageListGetter(); + $tipo = explode(':',$argv[1]); + switch ($tipo[0]) { + case 'Categoria': + $examplePages = $pageListGetter->getPageListFromCategoryName( $argv[1] ); + break; + case 'Plantilla': + $examplePages = $pageListGetter->getPageListFromPageTransclusions( $argv[1] ); + break; + default: + echo "No reconozco el tipo de objeto que estas intentando listar (debe ser Categoría o Plantilla)\n\n"; + exit(); + } + $array = accessProtected($examplePages,'pages'); + foreach ( $array as $exPage ) { + $pagename = $exPage->getTitle()->getText(); + echo "$pagename \n"; + } +} else { + echo "Hay que indicar una plantilla como parametro \n"; +} + +function accessProtected($obj, $prop) { + $reflection = new ReflectionClass($obj); + $property = $reflection->getProperty($prop); + $property->setAccessible(true); + return $property->getValue($obj); +} + + + + + +// print_r($examplePages); + +// $myArray = json_decode(json_encode($examplePages), true); +// print_r($examplePages->getPageList()); + + + + + + +?> |