private function handleINCLUDE($fullcommand, $args, $matches) { $filename = $matches[1]; if (file_exists($filename)) { wm_debug("Including '{$filename}'\n"); if (in_array($filename, $this->mapObject->included_files)) { wm_warn("Attempt to include '{$filename}' twice! Skipping it.\n"); return false; } $this->mapObject->included_files[] = $filename; $this->mapObject->has_includes = true; $reader = new WeatherMapConfigReader($this->mapObject); $reader->readConfigFile($matches[1]); $this->currentType = "GLOBAL"; $this->currentObject = $this->mapObject; return true; } wm_warn("INCLUDE File '{$matches[1]}' not found!\n"); return false; }
/** * ReadConfig reads in either a file or part of a config and modifies the current map. * * Temporary new ReadConfig, using the new table of keywords * However, this also expects a bunch of other internal change (WMColour, WMScale etc) * * @param $input string Either a filename or a fragment of config in a string * @return bool indicates success or failure * * */ function ReadConfig($input) { $reader = new WeatherMapConfigReader($this); // check if $input is more than one line. if it is, it's a text of a config file // if it isn't, it's the filename if (strchr($input, "\n") != false || strchr($input, "\r") != false) { wm_debug("ReadConfig Detected that this is a config fragment.\n"); // strip out any Windows line-endings that have gotten in here $input = str_replace("\r", "", $input); $lines = explode("\n", $input); $filename = "{text insert}"; $reader->readConfigLines($lines); } else { wm_debug("ReadConfig Detected that this is a config filename.\n"); $reader->readConfigFile($input); $this->configfile = $input; } $this->postReadConfigTasks(); return true; }