function WriteConfig() { $output = ''; # $output .= "# ID ".$this->id." - first seen in ".$this->defined_in."\n"; if ($this->config_override != '') { $output = $this->config_override . "\n"; } else { # $defdef = $this->owner->defaultlink; $dd = $this->owner->links[$this->template]; wm_debug("Writing config for LINK {$this->name} against {$this->template}\n"); $basic_params = array(array('width', 'WIDTH', CONFIG_TYPE_LITERAL), array('zorder', 'ZORDER', CONFIG_TYPE_LITERAL), array('overlibwidth', 'OVERLIBWIDTH', CONFIG_TYPE_LITERAL), array('overlibheight', 'OVERLIBHEIGHT', CONFIG_TYPE_LITERAL), array('arrowstyle', 'ARROWSTYLE', CONFIG_TYPE_LITERAL), array('viastyle', 'VIASTYLE', CONFIG_TYPE_LITERAL), array('linkstyle', 'LINKSTYLE', CONFIG_TYPE_LITERAL), array('splitpos', 'SPLITPOS', CONFIG_TYPE_LITERAL), array('duplex', 'DUPLEX', CONFIG_TYPE_LITERAL), array('commentstyle', 'COMMENTSTYLE', CONFIG_TYPE_LITERAL), array('labelboxstyle', 'BWSTYLE', CONFIG_TYPE_LITERAL), array('bwfont', 'BWFONT', CONFIG_TYPE_LITERAL), array('commentfont', 'COMMENTFONT', CONFIG_TYPE_LITERAL), array('bwoutlinecolour', 'BWOUTLINECOLOR', CONFIG_TYPE_COLOR), array('bwboxcolour', 'BWBOXCOLOR', CONFIG_TYPE_COLOR), array('outlinecolour', 'OUTLINECOLOR', CONFIG_TYPE_COLOR), array('commentfontcolour', 'COMMENTFONTCOLOR', CONFIG_TYPE_COLOR), array('bwfontcolour', 'BWFONTCOLOR', CONFIG_TYPE_COLOR)); # TEMPLATE must come first. DEFAULT if ($this->template != 'DEFAULT' && $this->template != ':: DEFAULT ::') { $output .= "\tTEMPLATE " . $this->template . "\n"; } foreach ($basic_params as $param) { $field = $param[0]; $keyword = $param[1]; # $output .= "# For $keyword: ".$this->$field." vs ".$dd->$field."\n"; if ($this->{$field} != $dd->{$field}) { if ($param[2] == CONFIG_TYPE_COLOR) { $output .= "\t{$keyword} " . render_colour($this->{$field}) . "\n"; } if ($param[2] == CONFIG_TYPE_LITERAL) { $output .= "\t{$keyword} " . $this->{$field} . "\n"; } } } $val = $this->usescale . " " . $this->scaletype; $comparison = $dd->usescale . " " . $dd->scaletype; if ($val != $comparison) { $output .= "\tUSESCALE " . $val . "\n"; } if ($this->infourl[IN] == $this->infourl[OUT]) { $dirs = array(IN => ""); // only use the IN value, since they're both the same, but don't prefix the output keyword } else { $dirs = array(IN => "IN", OUT => "OUT"); // the full monty two-keyword version } foreach ($dirs as $dir => $tdir) { if ($this->infourl[$dir] != $dd->infourl[$dir]) { $output .= "\t" . $tdir . "INFOURL " . $this->infourl[$dir] . "\n"; } } if ($this->overlibcaption[IN] == $this->overlibcaption[OUT]) { $dirs = array(IN => ""); // only use the IN value, since they're both the same, but don't prefix the output keyword } else { $dirs = array(IN => "IN", OUT => "OUT"); // the full monty two-keyword version } foreach ($dirs as $dir => $tdir) { if ($this->overlibcaption[$dir] != $dd->overlibcaption[$dir]) { $output .= "\t" . $tdir . "OVERLIBCAPTION " . $this->overlibcaption[$dir] . "\n"; } } if ($this->notestext[IN] == $this->notestext[OUT]) { $dirs = array(IN => ""); // only use the IN value, since they're both the same, but don't prefix the output keyword } else { $dirs = array(IN => "IN", OUT => "OUT"); // the full monty two-keyword version } foreach ($dirs as $dir => $tdir) { if ($this->notestext[$dir] != $dd->notestext[$dir]) { $output .= "\t" . $tdir . "NOTES " . $this->notestext[$dir] . "\n"; } } if ($this->overliburl[IN] == $this->overliburl[OUT]) { $dirs = array(IN => ""); // only use the IN value, since they're both the same, but don't prefix the output keyword } else { $dirs = array(IN => "IN", OUT => "OUT"); // the full monty two-keyword version } foreach ($dirs as $dir => $tdir) { if ($this->overliburl[$dir] != $dd->overliburl[$dir]) { $output .= "\t" . $tdir . "OVERLIBGRAPH " . join(" ", $this->overliburl[$dir]) . "\n"; } } // if formats have been set, but they're just the longform of the built-in styles, set them back to the built-in styles if ($this->labelstyle == '--' && $this->bwlabelformats[IN] == FMT_PERC_IN && $this->bwlabelformats[OUT] == FMT_PERC_OUT) { $this->labelstyle = 'percent'; } if ($this->labelstyle == '--' && $this->bwlabelformats[IN] == FMT_BITS_IN && $this->bwlabelformats[OUT] == FMT_BITS_OUT) { $this->labelstyle = 'bits'; } if ($this->labelstyle == '--' && $this->bwlabelformats[IN] == FMT_UNFORM_IN && $this->bwlabelformats[OUT] == FMT_UNFORM_OUT) { $this->labelstyle = 'unformatted'; } // if specific formats have been set, then the style will be '--' // if it isn't then use the named style if ($this->labelstyle != $dd->labelstyle && $this->labelstyle != '--') { $output .= "\tBWLABEL " . $this->labelstyle . "\n"; } // if either IN or OUT field changes, then both must be written because a regular BWLABEL can't do it // XXX this looks wrong $comparison = $dd->bwlabelformats[IN]; $comparison2 = $dd->bwlabelformats[OUT]; if ($this->labelstyle == '--' && ($this->bwlabelformats[IN] != $comparison || $this->bwlabelformats[OUT] != '--')) { $output .= "\tINBWFORMAT " . $this->bwlabelformats[IN] . "\n"; $output .= "\tOUTBWFORMAT " . $this->bwlabelformats[OUT] . "\n"; } $comparison = $dd->labeloffset_in; $comparison2 = $dd->labeloffset_out; if ($this->labeloffset_in != $comparison || $this->labeloffset_out != $comparison2) { $output .= "\tBWLABELPOS " . $this->labeloffset_in . " " . $this->labeloffset_out . "\n"; } $comparison = $dd->commentoffset_in . ":" . $dd->commentoffset_out; $mine = $this->commentoffset_in . ":" . $this->commentoffset_out; if ($mine != $comparison) { $output .= "\tCOMMENTPOS " . $this->commentoffset_in . " " . $this->commentoffset_out . "\n"; } $comparison = $dd->targets; if ($this->targets != $comparison) { $output .= "\tTARGET"; foreach ($this->targets as $target) { if (strpos($target[4], " ") == FALSE) { $output .= " " . $target[4]; } else { $output .= ' "' . $target[4] . '"'; } } $output .= "\n"; } foreach (array(IN, OUT) as $dir) { if ($dir == IN) { $tdir = "IN"; } if ($dir == OUT) { $tdir = "OUT"; } $comparison = $dd->comments[$dir]; if ($this->comments[$dir] != $comparison) { $output .= "\t" . $tdir . "COMMENT " . $this->comments[$dir] . "\n"; } } if (isset($this->a) && isset($this->b)) { $output .= "\tNODES " . $this->a->name; if ($this->a_offset != 'C') { $output .= ":" . $this->a_offset; } $output .= " " . $this->b->name; if ($this->b_offset != 'C') { $output .= ":" . $this->b_offset; } $output .= "\n"; } if (count($this->vialist) > 0) { foreach ($this->vialist as $via) { if (isset($via[2])) { $output .= sprintf("\tVIA %s %d %d\n", $via[2], $via[0], $via[1]); } else { $output .= sprintf("\tVIA %d %d\n", $via[0], $via[1]); } } } if ($this->max_bandwidth_in != $dd->max_bandwidth_in || $this->max_bandwidth_out != $dd->max_bandwidth_out || $this->name == 'DEFAULT') { if ($this->max_bandwidth_in == $this->max_bandwidth_out) { $output .= "\tBANDWIDTH " . $this->max_bandwidth_in_cfg . "\n"; } else { $output .= "\tBANDWIDTH " . $this->max_bandwidth_in_cfg . " " . $this->max_bandwidth_out_cfg . "\n"; } } foreach ($this->hints as $hintname => $hint) { // all hints for DEFAULT node are for writing // only changed ones, or unique ones, otherwise if ($this->name == 'DEFAULT' || isset($dd->hints[$hintname]) && $dd->hints[$hintname] != $hint || !isset($dd->hints[$hintname])) { $output .= "\tSET {$hintname} {$hint}\n"; } } if ($output != '') { $output = "LINK " . $this->name . "\n" . $output . "\n"; } } return $output; }
function WriteConfig($filename) { global $WEATHERMAP_VERSION; $fd=fopen($filename, "w"); $output=""; if ($fd) { $output.="# Automatically generated by php-weathermap v$WEATHERMAP_VERSION\n\n"; if (count($this->fonts) > 0) { foreach ($this->fonts as $fontnumber => $font) { if ($font->type == 'truetype') $output.=sprintf("FONTDEFINE %d %s %d\n", $fontnumber, $font->file, $font->size); if ($font->type == 'gd') $output.=sprintf("FONTDEFINE %d %s\n", $fontnumber, $font->file); } $output.="\n"; } $basic_params = array( array('background','BACKGROUND',CONFIG_TYPE_LITERAL), array('width','WIDTH',CONFIG_TYPE_LITERAL), array('height','HEIGHT',CONFIG_TYPE_LITERAL), array('htmlstyle','HTMLSTYLE',CONFIG_TYPE_LITERAL), array('kilo','KILO',CONFIG_TYPE_LITERAL), array('keyfont','KEYFONT',CONFIG_TYPE_LITERAL), array('timefont','TIMEFONT',CONFIG_TYPE_LITERAL), array('titlefont','TITLEFONT',CONFIG_TYPE_LITERAL), array('title','TITLE',CONFIG_TYPE_LITERAL), array('htmloutputfile','HTMLOUTPUTFILE',CONFIG_TYPE_LITERAL), array('htmlstylesheet','HTMLSTYLESHEET',CONFIG_TYPE_LITERAL), array('imageuri','IMAGEURI',CONFIG_TYPE_LITERAL), array('imageoutputfile','IMAGEOUTPUTFILE',CONFIG_TYPE_LITERAL) ); foreach ($basic_params as $param) { $field = $param[0]; $keyword = $param[1]; if ($this->$field != $this->inherit_fieldlist[$field]) { if($param[2] == CONFIG_TYPE_COLOR) $output.="$keyword " . render_colour($this->$field) . "\n"; if($param[2] == CONFIG_TYPE_LITERAL) $output.="$keyword " . $this->$field . "\n"; } } if (($this->timex != $this->inherit_fieldlist['timex']) || ($this->timey != $this->inherit_fieldlist['timey']) || ($this->stamptext != $this->inherit_fieldlist['stamptext'])) $output.="TIMEPOS " . $this->timex . " " . $this->timey . " " . $this->stamptext . "\n"; if (($this->mintimex != $this->inherit_fieldlist['mintimex']) || ($this->mintimey != $this->inherit_fieldlist['mintimey']) || ($this->minstamptext != $this->inherit_fieldlist['minstamptext'])) $output.="MINTIMEPOS " . $this->mintimex . " " . $this->mintimey . " " . $this->minstamptext . "\n"; if (($this->maxtimex != $this->inherit_fieldlist['maxtimex']) || ($this->maxtimey != $this->inherit_fieldlist['maxtimey']) || ($this->maxstamptext != $this->inherit_fieldlist['maxstamptext'])) $output.="MAXTIMEPOS " . $this->maxtimex . " " . $this->maxtimey . " " . $this->maxstamptext . "\n"; if (($this->titlex != $this->inherit_fieldlist['titlex']) || ($this->titley != $this->inherit_fieldlist['titley'])) $output.="TITLEPOS " . $this->titlex . " " . $this->titley . "\n"; $output.="\n"; foreach ($this->colours as $scalename=>$colours) { // not all keys will have keypos but if they do, then all three vars should be defined if ( (isset($this->keyx[$scalename])) && (isset($this->keyy[$scalename])) && (isset($this->keytext[$scalename])) && (($this->keytext[$scalename] != $this->inherit_fieldlist['keytext']) || ($this->keyx[$scalename] != $this->inherit_fieldlist['keyx']) || ($this->keyy[$scalename] != $this->inherit_fieldlist['keyy']))) { // sometimes a scale exists but without defaults. A proper scale object would sort this out... if($this->keyx[$scalename] == '') { $this->keyx[$scalename] = -1; } if($this->keyy[$scalename] == '') { $this->keyy[$scalename] = -1; } $output.="KEYPOS " . $scalename." ". $this->keyx[$scalename] . " " . $this->keyy[$scalename] . " " . $this->keytext[$scalename] . "\n"; } if ( (isset($this->keystyle[$scalename])) && ($this->keystyle[$scalename] != $this->inherit_fieldlist['keystyle']['DEFAULT']) ) { $extra=''; if ( (isset($this->keysize[$scalename])) && ($this->keysize[$scalename] != $this->inherit_fieldlist['keysize']['DEFAULT']) ) { $extra = " ".$this->keysize[$scalename]; } $output.="KEYSTYLE " . $scalename." ". $this->keystyle[$scalename] . $extra . "\n"; } $locale = localeconv(); $decimal_point = $locale['decimal_point']; foreach ($colours as $k => $colour) { if (!isset($colour['special']) || ! $colour['special'] ) { $top = rtrim(rtrim(sprintf("%f",$colour['top']),"0"),$decimal_point); $bottom= rtrim(rtrim(sprintf("%f",$colour['bottom']),"0"),$decimal_point); if ($bottom > 1000) { $bottom = nice_bandwidth($colour['bottom'], $this->kilo); } if ($top > 1000) { $top = nice_bandwidth($colour['top'], $this->kilo); } $tag = (isset($colour['tag'])? $colour['tag']:''); if( ($colour['red1'] == -1) && ($colour['green1'] == -1) && ($colour['blue1'] == -1)) { $output.=sprintf("SCALE %s %-4s %-4s none %s\n", $scalename, $bottom, $top, $tag); } elseif (!isset($colour['red2'])) { $output.=sprintf("SCALE %s %-4s %-4s %3d %3d %3d %s\n", $scalename, $bottom, $top, $colour['red1'], $colour['green1'], $colour['blue1'],$tag); } else { $output.=sprintf("SCALE %s %-4s %-4s %3d %3d %3d %3d %3d %3d %s\n", $scalename, $bottom, $top, $colour['red1'], $colour['green1'], $colour['blue1'], $colour['red2'], $colour['green2'], $colour['blue2'], $tag); } } else { $output.=sprintf("%sCOLOR %d %d %d\n", $k, $colour['red1'], $colour['green1'], $colour['blue1']); } } $output .= "\n"; } foreach ($this->hints as $hintname=>$hint) { $output .= "SET $hintname $hint\n"; } // this doesn't really work right, but let's try anyway if($this->has_includes) { $output .= "\n# Included files\n"; foreach ($this->included_files as $ifile) { $output .= "INCLUDE $ifile\n"; } } $output.="\n# End of global section\n\n"; fwrite($fd, $output); ## fwrite($fd,$this->nodes['DEFAULT']->WriteConfig()); ## fwrite($fd,$this->links['DEFAULT']->WriteConfig()); # fwrite($fd, "\n\n# Node definitions:\n"); foreach (array("template","normal") as $which) { if($which == "template") fwrite($fd,"\n# TEMPLATE-only NODEs:\n"); if($which == "normal") fwrite($fd,"\n# regular NODEs:\n"); foreach ($this->nodes as $node) { if(!preg_match("/^::\s/",$node->name)) { if($node->defined_in == $this->configfile) { if($which=="template" && $node->x === NULL) { wm_debug("TEMPLATE\n"); fwrite($fd,$node->WriteConfig()); } if($which=="normal" && $node->x !== NULL) { fwrite($fd,$node->WriteConfig()); } } } } if($which == "template") fwrite($fd,"\n# TEMPLATE-only LINKs:\n"); if($which == "normal") fwrite($fd,"\n# regular LINKs:\n"); foreach ($this->links as $link) { if(!preg_match("/^::\s/",$link->name)) { if($link->defined_in == $this->configfile) { if($which=="template" && $link->a === NULL) fwrite($fd,$link->WriteConfig()); if($which=="normal" && $link->a !== NULL) fwrite($fd,$link->WriteConfig()); } } } } fwrite($fd, "\n\n# That's All Folks!\n"); fclose($fd); } else { wm_warn ("Couldn't open config file $filename for writing"); return (FALSE); } return (TRUE); }
function WriteConfig() { $output = ''; # $output .= "# ID ".$this->id." - first seen in ".$this->defined_in."\n"; // This allows the editor to wholesale-replace a single node's configuration // at write-time - it should include the leading NODE xyz line (to allow for renaming) if ($this->config_override != '') { $output = $this->config_override . "\n"; } else { # $defdef = $this->owner->defaultnode; $dd = $this->owner->nodes[$this->template]; wm_debug("Writing config for NODE {$this->name} against {$this->template}\n"); # $field = 'zorder'; $keyword = 'ZORDER'; $basic_params = array(array('label', 'LABEL', CONFIG_TYPE_LITERAL), array('zorder', 'ZORDER', CONFIG_TYPE_LITERAL), array('labeloffset', 'LABELOFFSET', CONFIG_TYPE_LITERAL), array('labelfont', 'LABELFONT', CONFIG_TYPE_LITERAL), array('labelangle', 'LABELANGLE', CONFIG_TYPE_LITERAL), array('overlibwidth', 'OVERLIBWIDTH', CONFIG_TYPE_LITERAL), array('overlibheight', 'OVERLIBHEIGHT', CONFIG_TYPE_LITERAL), array('aiconoutlinecolour', 'AICONOUTLINECOLOR', CONFIG_TYPE_COLOR), array('aiconfillcolour', 'AICONFILLCOLOR', CONFIG_TYPE_COLOR), array('labeloutlinecolour', 'LABELOUTLINECOLOR', CONFIG_TYPE_COLOR), array('labelfontshadowcolour', 'LABELFONTSHADOWCOLOR', CONFIG_TYPE_COLOR), array('labelbgcolour', 'LABELBGCOLOR', CONFIG_TYPE_COLOR), array('labelfontcolour', 'LABELFONTCOLOR', CONFIG_TYPE_COLOR)); # TEMPLATE must come first. DEFAULT if ($this->template != 'DEFAULT' && $this->template != ':: DEFAULT ::') { $output .= "\tTEMPLATE " . $this->template . "\n"; } foreach ($basic_params as $param) { $field = $param[0]; $keyword = $param[1]; # $comparison=($this->name == 'DEFAULT' ? $this->inherit_fieldlist[$field] : $defdef->$field); if ($this->{$field} != $dd->{$field}) { if ($param[2] == CONFIG_TYPE_COLOR) { $output .= "\t{$keyword} " . render_colour($this->{$field}) . "\n"; } if ($param[2] == CONFIG_TYPE_LITERAL) { $output .= "\t{$keyword} " . $this->{$field} . "\n"; } } } // IN/OUT are the same, so we can use the simpler form here # print_r($this->infourl); #$comparison=($this->name == 'DEFAULT' #? $this->inherit_fieldlist['infourl'][IN] : $defdef->infourl[IN]); if ($this->infourl[IN] != $dd->infourl[IN]) { $output .= "\tINFOURL " . $this->infourl[IN] . "\n"; } #$comparison=($this->name == 'DEFAULT' #? $this->inherit_fieldlist['overlibcaption'][IN] : $defdef->overlibcaption[IN]); if ($this->overlibcaption[IN] != $dd->overlibcaption[IN]) { $output .= "\tOVERLIBCAPTION " . $this->overlibcaption[IN] . "\n"; } // IN/OUT are the same, so we can use the simpler form here # $comparison=($this->name == 'DEFAULT' # ? $this->inherit_fieldlist['notestext'][IN] : $defdef->notestext[IN]); if ($this->notestext[IN] != $dd->notestext[IN]) { $output .= "\tNOTES " . $this->notestext[IN] . "\n"; } # $comparison=($this->name == 'DEFAULT' # ? $this->inherit_fieldlist['overliburl'][IN] : $defdef->overliburl[IN]); if ($this->overliburl[IN] != $dd->overliburl[IN]) { $output .= "\tOVERLIBGRAPH " . join(" ", $this->overliburl[IN]) . "\n"; } $val = $this->iconscalew . " " . $this->iconscaleh . " " . $this->iconfile; $comparison = $dd->iconscalew . " " . $dd->iconscaleh . " " . $dd->iconfile; if ($val != $comparison) { $output .= "\tICON "; if ($this->iconscalew > 0) { $output .= $this->iconscalew . " " . $this->iconscaleh . " "; } $output .= ($this->iconfile == '' ? 'none' : $this->iconfile) . "\n"; } # $comparison=($this->name == 'DEFAULT' # ? $this->inherit_fieldlist['targets'] : $defdef->targets); if ($this->targets != $dd->targets) { $output .= "\tTARGET"; foreach ($this->targets as $target) { if (strpos($target[4], " ") == FALSE) { $output .= " " . $target[4]; } else { $output .= ' "' . $target[4] . '"'; } } $output .= "\n"; } # $comparison = ($this->name == 'DEFAULT' ? $this->inherit_fieldlist['usescale'] : $defdef->usescale) . " " . # ($this->name == 'DEFAULT' ? $this->inherit_fieldlist['scalevar'] : $defdef->scalevar); $val = $this->usescale . " " . $this->scalevar . " " . $this->scaletype; $comparison = $dd->usescale . " " . $dd->scalevar . " " . $dd->scaletype; if ($val != $comparison) { $output .= "\tUSESCALE " . $val . "\n"; } # $comparison = ($this->name == 'DEFAULT' # ? $this->inherit_fieldlist['useiconscale'] : $defdef->useiconscale) . " " . # ($this->name == 'DEFAULT' ? $this->inherit_fieldlist['iconscalevar'] : $defdef->iconscalevar); $val = $this->useiconscale . " " . $this->iconscalevar; $comparison = $dd->useiconscale . " " . $dd->iconscalevar; if ($val != $comparison) { $output .= "\tUSEICONSCALE " . $val . "\n"; } #$comparison = ($this->name == 'DEFAULT' #? $this->inherit_fieldlist['labeloffsetx'] : $defdef->labeloffsetx) . " " . ($this->name == 'DEFAULT' # ? $this->inherit_fieldlist['labeloffsety'] : $defdef->labeloffsety); $val = $this->labeloffsetx . " " . $this->labeloffsety; $comparison = $dd->labeloffsetx . " " . $dd->labeloffsety; if ($comparison != $val) { $output .= "\tLABELOFFSET " . $val . "\n"; } #$comparison=($this->name == 'DEFAULT' ? $this->inherit_fieldlist['x'] : $defdef->x) . " " . # ($this->name == 'DEFAULT' ? $this->inherit_fieldlist['y'] : $defdef->y); $val = $this->x . " " . $this->y; $comparison = $dd->x . " " . $dd->y; if ($val != $comparison) { if ($this->relative_to == '') { $output .= "\tPOSITION " . $val . "\n"; } else { if ($this->polar) { $output .= "\tPOSITION " . $this->relative_to . " " . $this->original_x . "r" . $this->original_y . "\n"; } else { $output .= "\tPOSITION " . $this->relative_to . " " . $this->original_x . " " . $this->original_y . "\n"; } } } if ($this->max_bandwidth_in != $dd->max_bandwidth_in || $this->max_bandwidth_out != $dd->max_bandwidth_out || $this->name == 'DEFAULT') { if ($this->max_bandwidth_in == $this->max_bandwidth_out) { $output .= "\tMAXVALUE " . $this->max_bandwidth_in_cfg . "\n"; } else { $output .= "\tMAXVALUE " . $this->max_bandwidth_in_cfg . " " . $this->max_bandwidth_out_cfg . "\n"; } } foreach ($this->hints as $hintname => $hint) { // all hints for DEFAULT node are for writing // only changed ones, or unique ones, otherwise if ($this->name == 'DEFAULT' || isset($dd->hints[$hintname]) && $dd->hints[$hintname] != $hint || !isset($dd->hints[$hintname])) { $output .= "\tSET {$hintname} {$hint}\n"; } } if ($output != '') { $output = "NODE " . $this->name . "\n{$output}\n"; } } return $output; }
function getConfig() { global $WEATHERMAP_VERSION; $output = "# Automatically generated by php-weathermap v{$WEATHERMAP_VERSION}\n\n"; $output .= $this->fonts->getConfig(); $basic_params = array(array('background', 'BACKGROUND', CONFIG_TYPE_LITERAL), array('width', 'WIDTH', CONFIG_TYPE_LITERAL), array('height', 'HEIGHT', CONFIG_TYPE_LITERAL), array('htmlstyle', 'HTMLSTYLE', CONFIG_TYPE_LITERAL), array('kilo', 'KILO', CONFIG_TYPE_LITERAL), array('keyfont', 'KEYFONT', CONFIG_TYPE_LITERAL), array('timefont', 'TIMEFONT', CONFIG_TYPE_LITERAL), array('titlefont', 'TITLEFONT', CONFIG_TYPE_LITERAL), array('title', 'TITLE', CONFIG_TYPE_LITERAL), array('htmloutputfile', 'HTMLOUTPUTFILE', CONFIG_TYPE_LITERAL), array('dataoutputfile', 'DATAOUTPUTFILE', CONFIG_TYPE_LITERAL), array('htmlstylesheet', 'HTMLSTYLESHEET', CONFIG_TYPE_LITERAL), array('imageuri', 'IMAGEURI', CONFIG_TYPE_LITERAL), array('imageoutputfile', 'IMAGEOUTPUTFILE', CONFIG_TYPE_LITERAL)); foreach ($basic_params as $param) { $field = $param[0]; $keyword = $param[1]; if ($this->{$field} != $this->inherit_fieldlist[$field]) { $type = $param[2]; if ($type == CONFIG_TYPE_COLOR) { $output .= "{$keyword} " . render_colour($this->{$field}) . "\n"; } if ($type == CONFIG_TYPE_LITERAL) { $output .= "{$keyword} " . $this->{$field} . "\n"; } } } $output .= $this->getConfigForPosition("TIMEPOS", array("timex", "timey", "stamptext"), $this, $this->inherit_fieldlist); $output .= $this->getConfigForPosition("MINTIMEPOS", array("mintimex", "mintimey", "minstamptext"), $this, $this->inherit_fieldlist); $output .= $this->getConfigForPosition("MAXTIMEPOS", array("maxtimex", "maxtimey", "maxstamptext"), $this, $this->inherit_fieldlist); $output .= $this->getConfigForPosition("TITLEPOS", array("titlex", "titley"), $this, $this->inherit_fieldlist); $output .= "\n"; foreach ($this->colours as $scalename => $colours) { // not all keys will have keypos but if they do, then all three vars should be defined if (isset($this->keyx[$scalename]) && isset($this->keyy[$scalename]) && isset($this->keytext[$scalename]) && ($this->keytext[$scalename] != $this->inherit_fieldlist['keytext'] || $this->keyx[$scalename] != $this->inherit_fieldlist['keyx'] || $this->keyy[$scalename] != $this->inherit_fieldlist['keyy'])) { // sometimes a scale exists but without defaults. A proper scale object would sort this out... if ($this->keyx[$scalename] == '') { $this->keyx[$scalename] = -1; } if ($this->keyy[$scalename] == '') { $this->keyy[$scalename] = -1; } $output .= "KEYPOS " . $scalename . " " . $this->keyx[$scalename] . " " . $this->keyy[$scalename] . " " . $this->keytext[$scalename] . "\n"; } if (isset($this->keystyle[$scalename]) && $this->keystyle[$scalename] != $this->inherit_fieldlist['keystyle']['DEFAULT']) { $extra = ''; if (isset($this->keysize[$scalename]) && $this->keysize[$scalename] != $this->inherit_fieldlist['keysize']['DEFAULT']) { $extra = " " . $this->keysize[$scalename]; } $output .= "KEYSTYLE " . $scalename . " " . $this->keystyle[$scalename] . $extra . "\n"; } } $output .= "# new colourtable stuff (duplicated above right now TODO)\n"; foreach ($this->colourtable as $k => $c) { $output .= sprintf("%sCOLOR %s\n", $k, $c->asConfig()); } $output .= "\n"; foreach ($this->scales as $s) { $output .= $s->getConfig(); } $output .= "\n"; foreach ($this->hints as $hintname => $hint) { $output .= "SET {$hintname} {$hint}\n"; } // this doesn't really work right, but let's try anyway if ($this->has_includes) { $output .= "\n# Included files\n"; foreach ($this->included_files as $ifile) { $output .= "INCLUDE {$ifile}\n"; } } $output .= "\n# End of global section\n\n"; $allMapItems = $this->buildAllItemsList(); usort($allMapItems, array($this, 'getConfigSort')); foreach ($allMapItems as $mapItem) { if ($mapItem->getDefined() == $this->configfile) { if (!preg_match("/^::\\s/", $mapItem->name)) { $output .= $mapItem->getConfig(); } } } $output .= "\n\n# That's All Folks!\n"; return $output; }