From 91cdadcc63cfb64b74f283e2d2bb058f5e2b9cb3 Mon Sep 17 00:00:00 2001 From: Tim Fry Date: Thu, 19 Dec 2024 16:26:34 -0400 Subject: [PATCH] update file class to use settings when retrieving sound files --- resources/classes/file.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/resources/classes/file.php b/resources/classes/file.php index 26c3c8f9ec..41d7b3a5b4 100644 --- a/resources/classes/file.php +++ b/resources/classes/file.php @@ -2,8 +2,6 @@ /** * cache class provides an abstracted cache - * - * @method string glob */ class file { @@ -12,12 +10,17 @@ class file { */ public $recursive; public $files; + private $settings; /** * Called when the object is created + * @param settings $settings Settings object */ - public function __construct() { - //place holder + public function __construct($settings = null) { + if ($settings === null) { + $settings = new settings(); + } + $this->settings = $settings; } /** @@ -66,8 +69,8 @@ class file { if (!isset($voice)) { $voice = 'callie'; } //set the variables - if (!empty($_SESSION['switch']['sounds']['dir']) && file_exists($_SESSION['switch']['sounds']['dir'])) { - $dir = $_SESSION['switch']['sounds']['dir'].'/'.$language.'/'.$dialect.'/'.$voice; + if (!empty($this->settings->get('switch', 'sounds')) && file_exists($this->settings->get('switch', 'sounds'))) { + $dir = $this->settings->get('switch', 'sounds').'/'.$language.'/'.$dialect.'/'.$voice; $rate = '8000'; $files = $this->glob($dir.'/*/'.$rate, true); } @@ -93,5 +96,3 @@ class file { $files = $file->sounds(); print_r($files); */ - -?>