X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FimportImages.inc;h=4b839a0f8ac0c4f8b5bcd25b6295c2406ff99601;hb=baddcab658195e9f2438b24f15030564e2fbd925;hp=5ae6d6bec824c0664a3ebf0e755d7bc27da49282;hpb=117424d9e57256ffb1c27f17ba6eb004d3944ce1;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/importImages.inc b/maintenance/importImages.inc index 5ae6d6bec8..4b839a0f8a 100644 --- a/maintenance/importImages.inc +++ b/maintenance/importImages.inc @@ -26,10 +26,10 @@ /** * Search a directory for files with one of a set of extensions * - * @param $dir string Path to directory to search - * @param $exts Array of extensions to search for - * @param $recurse Bool Search subdirectories recursively - * @return mixed Array of filenames on success, or false on failure + * @param string $dir Path to directory to search + * @param array $exts Array of extensions to search for + * @param bool $recurse Search subdirectories recursively + * @return array|bool Array of filenames on success, or false on failure */ function findFiles( $dir, $exts, $recurse = false ) { if ( is_dir( $dir ) ) { @@ -46,6 +46,7 @@ function findFiles( $dir, $exts, $recurse = false ) { $files = array_merge( $files, findFiles( $dir . '/' . $file, $exts, true ) ); } } + return $files; } else { return array(); @@ -58,14 +59,15 @@ function findFiles( $dir, $exts, $recurse = false ) { /** * Split a filename into filename and extension * - * @param $filename string Filename + * @param string $filename Filename * @return array */ function splitFilename( $filename ) { $parts = explode( '.', $filename ); - $ext = $parts[ count( $parts ) - 1 ]; - unset( $parts[ count( $parts ) - 1 ] ); + $ext = $parts[count( $parts ) - 1]; + unset( $parts[count( $parts ) - 1] ); $fname = implode( '.', $parts ); + return array( $fname, $ext ); } @@ -78,10 +80,10 @@ function splitFilename( $filename ) { * files for acme.foo.bar and the extension ".txt". With $maxStrip = 2, * acme.txt would also be acceptable. * - * @param $file string base path - * @param $auxExtension string the extension to be appended to the base path - * @param $maxStrip int the maximum number of extensions to strip from the base path (default: 1) - * @return string or false + * @param string $file Base path + * @param string $auxExtension The extension to be appended to the base path + * @param int $maxStrip The maximum number of extensions to strip from the base path (default: 1) + * @return string|bool */ function findAuxFile( $file, $auxExtension, $maxStrip = 1 ) { if ( strpos( $auxExtension, '.' ) !== 0 ) { @@ -110,10 +112,12 @@ function findAuxFile( $file, $auxExtension, $maxStrip = 1 ) { return false; } -# FIXME: Access the api in a saner way and performing just one query (preferably batching files too). +# @todo FIXME: Access the api in a saner way and performing just one query +# (preferably batching files too). function getFileCommentFromSourceWiki( $wiki_host, $file ) { - $url = $wiki_host . '/api.php?action=query&format=xml&titles=File:' . rawurlencode( $file ) . '&prop=imageinfo&&iiprop=comment'; - $body = Http::get( $url ); + $url = $wiki_host . '/api.php?action=query&format=xml&titles=File:' + . rawurlencode( $file ) . '&prop=imageinfo&&iiprop=comment'; + $body = Http::get( $url, array(), __METHOD__ ); if ( preg_match( '##', $body, $matches ) == 0 ) { return false; } @@ -122,8 +126,9 @@ function getFileCommentFromSourceWiki( $wiki_host, $file ) { } function getFileUserFromSourceWiki( $wiki_host, $file ) { - $url = $wiki_host . '/api.php?action=query&format=xml&titles=File:' . rawurlencode( $file ) . '&prop=imageinfo&&iiprop=user'; - $body = Http::get( $url ); + $url = $wiki_host . '/api.php?action=query&format=xml&titles=File:' + . rawurlencode( $file ) . '&prop=imageinfo&&iiprop=user'; + $body = Http::get( $url, array(), __METHOD__ ); if ( preg_match( '##', $body, $matches ) == 0 ) { return false; }