From 5900c595b72790bccb7b2edd395d46dd369f5a7d Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Thu, 5 Apr 2018 12:08:42 -0500 Subject: [PATCH] Move get_all_php_files() to FileManage library as getAllPhpFiles() - part 3/3 :-) Improve code syntax, fix warnings and fix typo. --- main/cron/lang/list_undefined_langvars.php | 2 +- main/cron/lang/list_unused_langvars.php | 4 ++-- main/inc/lib/fileManage.lib.php | 11 +++++------ tests/scripts/img/list_unused_img.php | 2 +- tests/scripts/img/list_used_img.php | 3 ++- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/main/cron/lang/list_undefined_langvars.php b/main/cron/lang/list_undefined_langvars.php index 2fc3a2307a..d65084ec5f 100755 --- a/main/cron/lang/list_undefined_langvars.php +++ b/main/cron/lang/list_undefined_langvars.php @@ -8,7 +8,7 @@ * Includes and declarations. */ die(); -require_once '../../inc/global.inc.php'; +require_once __DIR__.'/../../inc/global.inc.php'; $path = api_get_path(SYS_LANG_PATH).'english'; ini_set('memory_limit', '128M'); /** diff --git a/main/cron/lang/list_unused_langvars.php b/main/cron/lang/list_unused_langvars.php index f72c673b30..319194ab18 100755 --- a/main/cron/lang/list_unused_langvars.php +++ b/main/cron/lang/list_unused_langvars.php @@ -8,7 +8,7 @@ * Includes and declarations. */ die(); -require_once '../../inc/global.inc.php'; +require_once __DIR__.'/../../inc/global.inc.php'; $path = api_get_path(SYS_LANG_PATH).'english'; ini_set('memory_limit', '128M'); /** @@ -31,7 +31,7 @@ echo count($defined_terms)." terms were found in language files
"; // time and memory) $usedTerms = []; $l = strlen(api_get_path(SYS_PATH)); -$files = getAllPhpFget_iles(api_get_path(SYS_PATH)); +$files = getAllPhpFiles(api_get_path(SYS_PATH)); // Browse files foreach ($files as $file) { //echo 'Analyzing '.$file."
"; diff --git a/main/inc/lib/fileManage.lib.php b/main/inc/lib/fileManage.lib.php index a604bcbce5..3c71744b5a 100755 --- a/main/inc/lib/fileManage.lib.php +++ b/main/inc/lib/fileManage.lib.php @@ -63,9 +63,8 @@ function my_delete($file) return true; } - } else { - return false; // no file or directory to delete } + return false; // no file or directory to delete } /** @@ -258,9 +257,8 @@ function move($source, $target, $forceMove = true, $moveContent = false) return true; } - } else { - return false; } + return false; } /** @@ -270,6 +268,7 @@ function move($source, $target, $forceMove = true, $moveContent = false) * * @param string $source the path of the directory to move * @param string $destination the path of the new area + * @param bool $move Whether we want to remove the source at the end * * @return bool false on error */ @@ -347,8 +346,8 @@ function getextension($filename) /** * Get a list of all PHP (.php) files in a given directory. Includes .tpl files - * @param $base_path The base path in which to find the corresponding files - * @param $includeStatic Include static .html, .htm and .css files + * @param string $base_path The base path in which to find the corresponding files + * @param bool $includeStatic Include static .html, .htm and .css files * @return array */ function getAllPhpFiles($base_path, $includeStatic = false) diff --git a/tests/scripts/img/list_unused_img.php b/tests/scripts/img/list_unused_img.php index 4a537002d0..b37a556123 100644 --- a/tests/scripts/img/list_unused_img.php +++ b/tests/scripts/img/list_unused_img.php @@ -9,7 +9,7 @@ if (PHP_SAPI!='cli') { die('Run this script through the command line or comment this line in the code'); } -require_once '../../inc/global.inc.php'; +require_once __DIR__.'/../../../main/inc/global.inc.php'; $path = api_get_path(SYS_CODE_PATH).'img/'; ini_set('memory_limit', '128M'); ini_set('max_execution_time', '240'); diff --git a/tests/scripts/img/list_used_img.php b/tests/scripts/img/list_used_img.php index b6e825dcde..664b9b55a7 100644 --- a/tests/scripts/img/list_used_img.php +++ b/tests/scripts/img/list_used_img.php @@ -7,7 +7,7 @@ * Includes and declarations */ if (PHP_SAPI!='cli') { die('Run this script through the command line or comment this line in the code'); } -require_once '../../inc/global.inc.php'; +require_once __DIR__.'/../../../main/inc/global.inc.php'; $path = api_get_path(SYS_CODE_PATH).'img/'; ini_set('memory_limit','128M'); ini_set('max_execution_time','240'); @@ -21,6 +21,7 @@ $unexisting_img = array(); $l = strlen(api_get_path(SYS_PATH)); $files = getAllPhpFiles(api_get_path(SYS_PATH), true); $counter = 0; +$used_icons = []; foreach ($files as $file) { $shortfile = substr($file,$l); $lines = file($file);