From 19a0bf0eac1f71a015e339026d3838c076fa059e Mon Sep 17 00:00:00 2001 From: Yaco Date: Sun, 29 Sep 2019 20:34:06 -0300 Subject: agrega funcion para importar desde carpeta por argumento --- bin/wiki/initReevoClass.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/bin/wiki/initReevoClass.php b/bin/wiki/initReevoClass.php index 875843b0..ee67ded7 100644 --- a/bin/wiki/initReevoClass.php +++ b/bin/wiki/initReevoClass.php @@ -14,6 +14,7 @@ class InitReevo extends Maintenance { parent::__construct (); $this->mDescription = "Init Reevo pages"; $this->addArg( 'namespace', 'El namspace especifico del cual generar las pagínas. Tambien puede pasarse un nombre de página especifico, ej: Portada.mw', false ); + $this->addOption ( 'folder', 'Importa las paginas de las carpeta especificada', false , false); $this->addOption ( 'setReevoHomePage', "Cambia la portada", false, false ); $this->addOption ( 'force', "Fuerza la edición cuando las páginas ya existan", false, false ); $this->addOption ( 'int', "Usar solo páginas internacionales, de la carpeta 'int'", false, false ); @@ -33,7 +34,13 @@ class InitReevo extends Maintenance { $setReevoHomePage = $this->getOption ( 'setReevoHomePage' ); $force = $this->getOption ( 'force' ) ? true : false; - $lang = $this->getOption ( 'int' ) ? 'int' : $wgContLang->getCode(); + if ($this->getOption ( 'folder' )) { + echo 'Voy a importar de la carpeta: '. $this->getOption ( 'folder' ); + $lang = $this->getOption ( 'folder' ); + } else { + $lang = $this->getOption ( 'int' ) ? 'int' : $wgContLang->getCode(); + } + $homePageFile = [ 'es' => 'Portada.md', @@ -155,6 +162,7 @@ class InitReevo extends Maintenance { // $page = str_replace ( 'Ayuda_', 'Ayuda:', $page ); // $page = str_replace ( 'Reevo_', 'Reevo:', $page ); $page = str_replace ( '_', ' ', $page ); + $page = str_replace ( '~', '/', $page ); $page = str_replace ( '.mw', '', $page ); return $page; @@ -175,14 +183,15 @@ class InitReevo extends Maintenance { throw new Exception('File not found : ' . $page); } - protected function getPageListToCreate( $lang = 'int') { + protected function getPageListToCreate( $lang) { + $result = [ ]; $dirs = $this->getPagesDirs($lang); foreach ($dirs as $dir) { $files = scandir ( $dir ); foreach ( $files as $file ) { - if (preg_match ( '/^([a-zA-Z_0-9\-áéíóúñÁÉÍÓÚÑ:])+\.mw$/', $file )) { + if (preg_match ( '/^([a-zA-Z_0-9\-áéíóúñÁÉÍÓÚÑ~:’()])+\.mw$/', $file )) { $namespace = $this->getArg( 0 ); if ($namespace) { if(strpos($file, $namespace) === 0) { @@ -195,7 +204,7 @@ class InitReevo extends Maintenance { } } } - + print_r($result); return $result; } } -- cgit v1.2.1