From: Carsten K. <car...@us...> - 2002-12-28 01:32:04
|
Update of /cvsroot/phpwiki/phpwiki/lib/plugin In directory sc8-pr-cvs1:/tmp/cvs-serv10783 Modified Files: PhpWeather.php Log Message: Plugin now traps the include error when phpweather.php is not installed. Tested with cvs version of PhpWeather. Index: PhpWeather.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/plugin/PhpWeather.php,v retrieving revision 1.4 retrieving revision 1.5 diff -u -2 -b -p -d -r1.4 -r1.5 --- PhpWeather.php 25 Nov 2002 20:28:04 -0000 1.4 +++ PhpWeather.php 28 Dec 2002 01:32:01 -0000 1.5 @@ -26,7 +26,10 @@ rcs_id('$Id PhpWeather.php 2002-08-26 15 // We require the base class from PHP Weather, adjust this to match // the location of PhpWeather on your server: -require_once($_SERVER['DOCUMENT_ROOT'] . '/phpweather/phpweather.php'); -require_once(PHPWEATHER_BASE_DIR . '/output/pw_images.php'); -require_once(PHPWEATHER_BASE_DIR . '/pw_utilities.php'); +$WEATHER = $_SERVER['DOCUMENT_ROOT'] . '/phpweather/phpweather.php'; +if(! @include_once($WEATHER)) { + if(!in_array($WEATHER, get_included_files()) ) { + trigger_error(sprintf(_("Could not open file %s."), "'$WEATHER'")); + } +} class WikiPlugin_PhpWeather @@ -50,4 +53,12 @@ extends WikiPlugin function run($dbi, $argstr, $request) { + // When 'phpweather/phpweather.php' is not installed then + // PHPWEATHER_BASE_DIR will be undefined + if (!defined('PHPWEATHER_BASE_DIR')) + return fmt("Plugin %s failed.", $this->getName()); //early return + + require_once(PHPWEATHER_BASE_DIR . '/output/pw_images.php'); + require_once(PHPWEATHER_BASE_DIR . '/pw_utilities.php'); + extract($this->getArgs($argstr, $request)); $html = HTML(); @@ -70,5 +81,6 @@ extends WikiPlugin /* We check and correct the language if necessary: */ - if (!in_array($lang, array_keys($w->get_languages('text')))) { + //if (!in_array($lang, array_keys($w->get_languages('text')))) { + if (!in_array($lang, array_keys(get_languages('text')))) { trigger_error(sprintf(_("%s does not know about the language '%s', using 'en' instead."), $this->getName(), $lang), E_USER_NOTICE); |