Changeset 7775 for trunk/src/inc
- Timestamp:
- Apr 16, 2010, 12:27:16 AM (15 years ago)
- Location:
- trunk/src/inc
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/inc/KMLFile.class.php
r7773 r7775 5 5 * Purpose: Creating of editing KML files 6 6 */ 7 8 define('NODE_STATUS_UP', 0); 9 define('NODE_STATUS_ERROR', 1); 10 define('NODE_STATUS_UNREACHABLE', 2); 7 11 8 12 class KMLFile { … … 13 17 <open>1</open> 14 18 <description>Wireless Leiden Interactive Nodemap 2.0</description> 19 <LookAt> 20 <longitude>%OVERALL_LONGITUDE%</longitude> 21 <latitude>%OVERALL_LATITUDE%</latitude> 22 <altitude>%OVERALL_ALTITUDE%</altitude> 23 <heading>%OVERALL_HEADING%</heading> 24 <tilt>%OVERALL_TILT%</tilt> 25 <range>%OVERALL_RANGE%</range> 26 </LookAt> 27 <Style id="blackLine"> 28 <LineStyle> 29 <color>%LINE_BLACK%</color> 30 <width>3</width> 31 </LineStyle> 32 </Style> 15 33 <Style id="greenArrowIcon"> 16 34 <IconStyle> … … 34 52 </IconStyle> 35 53 </Style> 36 <Style id="blackLine">37 <LineStyle>38 <color>%LINE_BLACK%</color>39 <width>3</width>40 </LineStyle>41 </Style>42 54 <Folder id="nodes"> 43 55 <name>Nodes</name> 44 56 <description>Nodes from the Wireless Leiden network</description> 45 57 <LookAt> 46 <longitude> 4.490153</longitude>47 <latitude> 52.161087</latitude>48 <altitude> 5</altitude>49 <heading> 0</heading>50 <tilt> 0</tilt>51 <range> 500</range>58 <longitude>%OVERALL_LONGITUDE%</longitude> 59 <latitude>%OVERALL_LATITUDE%</latitude> 60 <altitude>%OVERALL_ALTITUDE%</altitude> 61 <heading>%OVERALL_HEADING%</heading> 62 <tilt>%OVERALL_TILT%</tilt> 63 <range>%OVERALL_RANGE%</range> 52 64 </LookAt> 53 65 %NODESCONTENT% … … 57 69 <description>Lines from nodes to nodes from the Wireless Leiden network</description> 58 70 <LookAt> 59 <longitude> 4.490153</longitude>60 <latitude> 52.161087</latitude>61 <altitude> 5</altitude>62 <heading> 0</heading>63 <tilt> 0</tilt>64 <range> 500</range>71 <longitude>%OVERALL_LONGITUDE%</longitude> 72 <latitude>%OVERALL_LATITUDE%</latitude> 73 <altitude>%OVERALL_ALTITUDE%</altitude> 74 <heading>%OVERALL_HEADING%</heading> 75 <tilt>%OVERALL_TILT%</tilt> 76 <range>%OVERALL_RANGE%</range> 65 77 </LookAt> 66 78 %LINESCONTENT% … … 146 158 $toString = str_replace('%LINESCONTENT%', $lineString, $toString); 147 159 160 $toString = str_replace('%OVERALL_LONGITUDE%', $config['overall_longitude'], $toString); 161 $toString = str_replace('%OVERALL_LATITUDE%', $config['overall_latitude'], $toString); 162 $toString = str_replace('%OVERALL_ALTITUDE%', $config['overall_altitude'], $toString); 163 $toString = str_replace('%OVERALL_HEADING%', $config['overall_heading'], $toString); 164 $toString = str_replace('%OVERALL_TILT%', $config['overall_tilt'], $toString); 165 $toString = str_replace('%OVERALL_RANGE%', $config['overall_range'], $toString); 166 148 167 return $toString; 149 168 } … … 218 237 219 238 // Creating a string with the complete description of the node using all data in the location file 220 $descriptionLocation = 'Naam: ' . $name . '<br/>Locatie: ' . $location . '<br/>Status: ' . $status . '<br/>Latitude: ' . $latitude . '<br/>Longitude: ' . $longitude . '<br/>Interfaces: ' . $interfaces . '<br/>Master IP: ' . $masterip . '<br/>Node type: ' . $nodetype . '<br/><br/>'; 239 $dataLocation = ' 240 <Data name="location"> 241 <value> 242 <![CDATA[ 243 ' . $location . ' 244 ]]> 245 </value> 246 </Data> 247 <Data name="status"> 248 <value>' . $status . '</value> 249 </Data> 250 <Data name="interfaces"> 251 <value>' . $interfaces . '</value> 252 </Data> 253 <Data name="masterIP"> 254 <value>' . $masterip . '</value> 255 </Data> 256 <Data name="nodeType"> 257 <value>' . $nodetype . '</value> 258 </Data>'; 221 259 222 260 if ($placemarkPosition = $this->getNodeByName($name)) { 223 261 // Updating an excisting placemark 224 $this->KMLNodes[$placemarkPosition]->setD escriptionLocation($descriptionLocation);262 $this->KMLNodes[$placemarkPosition]->setDataLocation($dataLocation); 225 263 $this->KMLNodes[$placemarkPosition]->setLongitude($longitude); 226 264 $this->KMLNodes[$placemarkPosition]->setLatitude($latitude); … … 230 268 $placemark->setID($name); 231 269 $placemark->setName($name); 232 $placemark->setD escriptionLocation($descriptionLocation);270 $placemark->setDataLocation($dataLocation); 233 271 $placemark->setLongitude($longitude); 234 272 $placemark->setLatitude($latitude); … … 259 297 $this->NetworkList->add($network); 260 298 299 $data = ' 300 <Data name="netmaskDecimal"> 301 <value>' . $network->netmaskDecimal . '</value> 302 </Data> 303 <Data name="netmaskBinary"> 304 <value>' . $network->netmaskBinary . '</value> 305 </Data> 306 <Data name="wildcardDecimal"> 307 <value>' . $network->wildcardDecimal . '</value> 308 </Data> 309 <Data name="wildcardBinary"> 310 <value>' . $network->wildcardBinary . '</value> 311 </Data> 312 <Data name="networkDecimal"> 313 <value>' . $network->networkDecimal . '</value> 314 </Data> 315 <Data name="networkBinary"> 316 <value>' . $network->networkBinary . '</value> 317 </Data> 318 <Data name="broadcastDecimal"> 319 <value>' . $network->broadcastDecimal . '</value> 320 </Data> 321 <Data name="broadcastBinary"> 322 <value>' . $network->broadcastBinary . '</value> 323 </Data> 324 <Data name="hostMinDecimal"> 325 <value>' . $network->hostminDecimal . '</value> 326 </Data> 327 <Data name="hostMinBinary"> 328 <value>' . $network->hostminBinary . '</value> 329 </Data> 330 <Data name="hostMaxDecimal"> 331 <value>' . $network->hostmaxDecimal . '</value> 332 </Data> 333 <Data name="hostMaxBinary"> 334 <value>' . $network->hostmaxBinary . '</value> 335 </Data> 336 <Data name="hosts"> 337 <value>' . $network->numberHosts . '</value> 338 </Data>'; 339 261 340 $line = new KMLLine(); 262 $line->setID( $network->networkDecimal);341 $line->setID(str_replace('.', '', $network->networkDecimal)); 263 342 $line->setName('Link: Van ' . $name . ' naar '); 264 $line->setD escription($network->toString());343 $line->setData($data); 265 344 $line->setLongitude1($longitude); 266 345 $line->setLatitude1($latitude); … … 334 413 335 414 // Creating a string with the complete description of the node using all data in the status file 336 $descriptionStatus = 'Type: ' . $lineContent[0] . '<br/>Host name: ' . $lineContent[1] . '<br/>Has been checked: ' . $lineContent[2] . '<br/>Check execution time: ' . $lineContent[3] . '<br/>Currenr state: ' . $lineContent[4] . '<br/>Last hard state: ' . $lineContent[5] . '<br/>Last check: ' . $lineContent[6] . '<br/>Problem has been acknowledged: ' . $lineContent[7] . '<br/><br/>'; 415 $dataStatus = ' 416 <Data name="type"> 417 <value>' . $lineContent[0] . '</value> 418 </Data> 419 <Data name="hostName"> 420 <value>' . $lineContent[1] . '</value> 421 </Data> 422 <Data name="hasBeenChecked"> 423 <value>' . $lineContent[2] . '</value> 424 </Data> 425 <Data name="checkExecutionTime"> 426 <value>' . $lineContent[3] . '</value> 427 </Data> 428 <Data name="currentState"> 429 <value>' . $lineContent[4] . '</value> 430 </Data> 431 <Data name="lastHardState"> 432 <value>' . $lineContent[5] . '</value> 433 </Data> 434 <Data name="lastCheck"> 435 <value>' . $lineContent[6] . '</value> 436 </Data> 437 <Data name="problemHasBeenAcknowledged"> 438 <value>' . $lineContent[7] . '</value> 439 </Data>'; 440 441 $style = NODE_RED; 442 if ($lineContent[4] == NODE_STATUS_ERROR) { 443 $style = NODE_ORANGE; 444 } elseif ($lineContent[4] == NODE_STATUS_UP) { 445 $style = NODE_GREEN; 446 } 337 447 338 448 if ($placemarkPosition = $this->getNodeByName($lineContent[1])) { 339 449 // Updating an excisting placemark 340 $this->KMLNodes[$placemarkPosition]->setDescriptionStatus($descriptionStatus); 450 $this->KMLNodes[$placemarkPosition]->setDataStatus($dataStatus); 451 $this->KMLNodes[$placemarkPosition]->setStyle($style); 341 452 } else { 342 453 // Adding a new placemark … … 344 455 $placemark->setID($lineContent[1]); 345 456 $placemark->setName($lineContent[1]); 346 $placemark->setDescriptionStatus($descriptionStatus); 457 $placemark->setDataStatus($dataStatus); 458 $placemark->setStyle($style); 347 459 $this->addNode($placemark); 348 460 } -
trunk/src/inc/KMLLine.class.php
r7773 r7775 6 6 */ 7 7 8 define('LINE_BLACK', ' blackLine');8 define('LINE_BLACK', '#blackLine'); 9 9 10 10 class KMLLine { … … 12 12 <Placemark id="%ID%"> 13 13 <name>%NAME%</name> 14 <description> 15 <![CDATA[ 16 <img src="http://www.wirelessleiden.nl/sites/wirelessleiden.nl/files/garland-wl_logo.png" alt="Wireless Leiden" title="Wireless Leiden" style="float: right;"/> 17 %DESCRIPTION% 18 ]]> 19 </description> 14 <description>%NAME%</description> 20 15 <LookAt> 21 16 <longitude>%LONGITUDE1%</longitude> 22 17 <latitude>%LATITUDE1%</latitude> 23 <altitude> 0</altitude>24 <heading> 0</heading>25 <tilt> 0</tilt>26 <range> 500</range>18 <altitude>%OVERALL_ALTITUDE%</altitude> 19 <heading>%OVERALL_HEADING%</heading> 20 <tilt>%OVERALL_TILT%</tilt> 21 <range>%OVERALL_RANGE%</range> 27 22 </LookAt> 23 <ExtendedData> 24 %EXTENDEDDATA% 25 </ExtendedData> 28 26 <styleUrl>%STYLE%</styleUrl> 29 27 <LineString> 30 28 <coordinates> 31 %LONGITUDE1%, %LATITUDE1%,0.32 %LONGITUDE2%, %LATITUDE2%,0.29 %LONGITUDE1%,%LATITUDE1%,0. 30 %LONGITUDE2%,%LATITUDE2%,0. 33 31 </coordinates> 34 32 </LineString> … … 37 35 private $id; // ID of the line 38 36 private $name; // Name of the line 39 private $d escription; // Description of the line37 private $data; // Extra information of the line 40 38 private $style; // Style of the line 41 39 private $longitude1; // Start longitude of line … … 94 92 95 93 /* 96 * Function: setD escription97 * Description: Setting the descriptionof the placemark98 * Parameters: string $newD escription94 * Function: setData 95 * Description: Setting the extra data of the placemark 96 * Parameters: string $newData 99 97 * Returns: - 100 98 */ 101 function setD escription($newDescription) {102 $this->d escription = (string) $newDescription;99 function setData($newData) { 100 $this->data = (string) $newData; 103 101 } 104 102 … … 179 177 $toString = str_replace('%ID%', $this->id, $toString); 180 178 $toString = str_replace('%NAME%', $this->name, $toString); 181 $toString = str_replace('% DESCRIPTION%', $this->description, $toString);179 $toString = str_replace('%EXTENDEDDATA%', $this->data, $toString); 182 180 $toString = str_replace('%STYLE%', $this->style, $toString); 183 181 $toString = str_replace('%LONGITUDE1%', $this->longitude1, $toString); -
trunk/src/inc/KMLNode.class.php
r7765 r7775 6 6 */ 7 7 8 define('NODE_GREEN', ' greenArrowIcon');9 define('NODE_ORANGE', ' orangeArrowIcon');10 define('NODE_RED', ' redArrowIcon');8 define('NODE_GREEN', '#greenArrowIcon'); 9 define('NODE_ORANGE', '#orangeArrowIcon'); 10 define('NODE_RED', '#redArrowIcon'); 11 11 12 12 class KMLNode { … … 14 14 <Placemark id="%ID%"> 15 15 <name>%NAME%</name> 16 <description> 17 <![CDATA[ 18 <img src="http://www.wirelessleiden.nl/sites/wirelessleiden.nl/files/garland-wl_logo.png" alt="Wireless Leiden" title="Wireless Leiden" style="float: right;"/> 19 %DESCRIPTION% 20 ]]> 21 </description> 16 <description>%NAME%</description> 22 17 <LookAt> 23 18 <longitude>%LONGITUDE%</longitude> 24 19 <latitude>%LATITUDE%</latitude> 25 <altitude> 0</altitude>26 <heading> 0</heading>27 <tilt> 0</tilt>28 <range> 500</range>20 <altitude>%OVERALL_ALTITUDE%</altitude> 21 <heading>%OVERALL_HEADING%</heading> 22 <tilt>%OVERALL_TILT%</tilt> 23 <range>%OVERALL_RANGE%</range> 29 24 </LookAt> 25 <ExtendedData> 26 %EXTENDEDDATA% 27 </ExtendedData> 30 28 <styleUrl>%STYLE%</styleUrl> 31 29 <Point> … … 35 33 </Placemark>'; 36 34 37 private $id; 38 private $name; 39 private $d escriptionLocation;// Location information of the node40 private $d escriptionStatus; // Status information of the node41 private $longitude; 42 private $latitude; 43 private $style; 35 private $id; // ID of the node 36 private $name; // Name of the node 37 private $dataLocation; // Location information of the node 38 private $dataStatus; // Status information of the node 39 private $longitude; // Longitude of the node 40 private $latitude; // Latitude of the node 41 private $style; // Style of the node 44 42 45 43 /* … … 52 50 $this->id = ''; 53 51 $this->name = ''; 54 $this->d escriptionLocation = '';55 $this->d escriptionStatus = '';52 $this->dataLocation = ''; 53 $this->dataStatus = ''; 56 54 $this->longitude = 0; 57 55 $this->latitude = 0; 58 $this->style = 'orangeArrowIcon';56 $this->style = NODE_RED; 59 57 } 60 58 … … 95 93 * Returns: - 96 94 */ 97 function setD escriptionLocation($newDescriptionLocation) {98 $this->d escriptionLocation = (string) $newDescriptionLocation;95 function setDataLocation($newDataLocation) { 96 $this->dataLocation = (string) $newDataLocation; 99 97 } 100 98 … … 105 103 * Returns: - 106 104 */ 107 function setD escriptionStatus($newDescriptionStatus) {108 $this->d escriptionStatus = (string) $newDescriptionStatus;105 function setDataStatus($newDataStatus) { 106 $this->dataStatus = (string) $newDataStatus; 109 107 } 110 108 … … 150 148 $toString = str_replace('%ID%', $this->id, $toString); 151 149 $toString = str_replace('%NAME%', $this->name, $toString); 152 $toString = str_replace('% DESCRIPTION%', $this->descriptionLocation . $this->descriptionStatus, $toString);150 $toString = str_replace('%EXTENDEDDATA%', $this->dataLocation . $this->dataStatus, $toString); 153 151 $toString = str_replace('%LONGITUDE%', $this->longitude, $toString); 154 152 $toString = str_replace('%LATITUDE%', $this->latitude, $toString);
Note:
See TracChangeset
for help on using the changeset viewer.