diff options
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r-- | modules/gallery/helpers/gallery.php | 13 | ||||
-rw-r--r-- | modules/gallery/helpers/graphics.php | 9 | ||||
-rw-r--r-- | modules/gallery/helpers/movie.php | 9 |
3 files changed, 21 insertions, 10 deletions
diff --git a/modules/gallery/helpers/gallery.php b/modules/gallery/helpers/gallery.php index ca8c92c9..3cf0eacd 100644 --- a/modules/gallery/helpers/gallery.php +++ b/modules/gallery/helpers/gallery.php @@ -140,4 +140,17 @@ class gallery_Core { return $file_name; } + /** + * Set the PATH environment variable to the paths specified. + * @param array Array of paths. Each array entry can contain a colon separated list of paths. + */ + static function set_path_env($paths) { + $path_env = array(); + foreach ($paths as $path) { + if ($path) { + array_push($path_env, $path); + } + } + putenv("PATH=" . implode(":", $path_env)); + } }
\ No newline at end of file diff --git a/modules/gallery/helpers/graphics.php b/modules/gallery/helpers/graphics.php index 2868a28d..dd521d84 100644 --- a/modules/gallery/helpers/graphics.php +++ b/modules/gallery/helpers/graphics.php @@ -313,11 +313,10 @@ class graphics_Core { $toolkits->graphicsmagick->installed = false; $toolkits->graphicsmagick->error = t("GraphicsMagick requires the <b>exec</b> function"); } else { - $graphics_path = module::get_var("gallery", "graphics_toolkit_path", null); - $extra_binary_paths = module::get_var("gallery", "extra_binary_paths", null); - - putenv("PATH=" . getenv("PATH") . (empty($graphics_path) ? "" : ":$graphics_path") . - ":" . $extra_binary_paths); + gallery::set_path_env( + array(module::get_var("gallery", "graphics_toolkit_path"), + getenv("PATH"), + module::get_var("gallery", "extra_binary_paths"))); // @todo: consider refactoring the two segments below into a loop since they are so // similar. diff --git a/modules/gallery/helpers/movie.php b/modules/gallery/helpers/movie.php index 50339541..78358b6b 100644 --- a/modules/gallery/helpers/movie.php +++ b/modules/gallery/helpers/movie.php @@ -85,11 +85,10 @@ class movie_Core { static function find_ffmpeg() { if (!($ffmpeg_path = module::get_var("gallery", "ffmpeg_path")) || !file_exists($ffmpeg_path)) { - $graphics_path = module::get_var("gallery", "graphics_toolkit_path", null); - $extra_binary_paths = module::get_var("gallery", "extra_binary_paths", null); - - putenv("PATH=" . getenv("PATH") . (empty($graphics_path) ? "" : ":$graphics_path") . - ":" . $extra_binary_paths); + gallery::set_path_env( + array(module::get_var("gallery", "graphics_toolkit_path"), + getenv("PATH"), + module::get_var("gallery", "extra_binary_paths"))); if (function_exists("exec")) { $ffmpeg_path = exec("which ffmpeg"); } |