From 2a09fe8f3e843c39769049ac6c7a9a5076d7c077 Mon Sep 17 00:00:00 2001 From: raphaelpereira Date: Thu, 25 Nov 2004 19:41:07 +0000 Subject: [PATCH] - Now class.javascript.inc.php automatically loads the specific browser JS, which is located at the same hierarchy, but inside a folder with the name of the browser. For example: Usual folder => contactcenter/js/ccQuickAdd/ccQuickAdd.js Specific Folder => contactcenter/js/ccQuickAdd/mozilla/ccQuickAdd.js It falls back to the usual folder if there is no specific code. --- phpgwapi/inc/class.javascript.inc.php | 39 ++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/phpgwapi/inc/class.javascript.inc.php b/phpgwapi/inc/class.javascript.inc.php index 2ee3f8cd4e..a82d04371a 100644 --- a/phpgwapi/inc/class.javascript.inc.php +++ b/phpgwapi/inc/class.javascript.inc.php @@ -130,11 +130,12 @@ { if(!empty($files) && is_array($files)) { - foreach($files as $file => $ignored) + print_r($files); + foreach($files as $file => $browser) { $links .= '\n"; } } @@ -203,20 +204,44 @@ * @param string $package package to be included * @param string $file file to be included - no ".js" on the end * @param string $app application directory to search - default = phpgwapi + * @param bool $browser insert specific browser javascript. + * + * @discuss The browser specific option loads the file which is in the correct + * browser folder. Supported folder are those supported by class.browser.inc.php + * * @returns bool was the file found? */ - function validate_file($package, $file, $app='phpgwapi') + function validate_file($package, $file, $app='phpgwapi', $browser=true) { - if(is_readable(PHPGW_INCLUDE_ROOT .SEP .$app .SEP .'js' .SEP . $package .SEP. $file . '.js')) + if ($browser) { - $this->files[$app][$package][$file] = $file; + $browser_folder = strtolower(ExecMethod('phpgwapi.browser.get_agent')); + } + else + { + $browser_folder = '.'; + } + + if(is_readable(PHPGW_INCLUDE_ROOT .SEP .$app .SEP .'js' .SEP . $package . SEP . $browser_folder . SEP . $file . '.js')) + { + $this->files[$app][$package][$file] = $browser_folder; + return True; + } + elseif (is_readable(PHPGW_INCLUDE_ROOT .SEP .$app .SEP .'js' .SEP . $package . SEP . $file . '.js')) + { + $this->files[$app][$package][$file] = '.'; return True; } elseif($app != 'phpgwapi') { - if(is_readable(PHPGW_INCLUDE_ROOT .SEP .'phpgwapi' .SEP .'js' .SEP . $package .SEP . $file . '.js')) + if(is_readable(PHPGW_INCLUDE_ROOT .SEP .'phpgwapi' .SEP .'js' .SEP . $package .SEP . $browser_folder . SEP . $file . '.js')) { - $this->files['phpgwapi'][$package][$file] = $file; + $this->files['phpgwapi'][$package][$file] = $browser_folder; + return True; + } + elseif(is_readable(PHPGW_INCLUDE_ROOT .SEP .'phpgwapi' .SEP .'js' .SEP . $package .SEP . $file . '.js')) + { + $this->files['phpgwapi'][$package][$file] = '.'; return True; } return False;