jablonka.czprosek.czf

weathermap

Subversion Repositories:
[/] [editor.php] - Blame information for rev 85

 

Line No. Rev Author Line
11simandl<?php
285simandl 
31simandlrequire_once 'editor.inc.php';
4require_once 'Weathermap.class.php';
5 
685simandl// so that you can't have the editor active, and not know about it.
7$ENABLED=false;
8 
9if(! $ENABLED)
10{
11 print "<p>The editor has not been enabled yet. You need to set ENABLED=true at the top of editor.php</p>";
12 print "<p>Before you do that, you should consider using FilesMatch (in Apache) or similar to limit who can access the editor. There is more information in the install guide section of the manual.</p>";
13 exit();
14}
15 
1613simandl// sensible defaults
17$mapdir='configs';
18$cacti_base = '../../';
19$cacti_url = '/';
20$ignore_cacti=FALSE;
2185simandl$configerror = '';
221simandl 
2313simandl$config_loaded = @include_once 'editor-config.php';
24 
2585simandl// these are all set via the Editor Settings dialog, in the editor, now.
26$use_overlay = FALSE; // set to TRUE to enable experimental overlay showing VIAs
27$use_relative_overlay = FALSE; // set to TRUE to enable experimental overlay showing relative-positioning
28$grid_snap_value = 0; // set non-zero to snap to a grid of that spacing
29 
30if( isset($_COOKIE['wmeditor']))
3113simandl{
3285simandl $parts = split(":",$_COOKIE['wmeditor']);
33 
34 if( (isset($parts[0])) && (intval($parts[0]) == 1) ) { $use_overlay = TRUE; }
35 if( (isset($parts[1])) && (intval($parts[1]) == 1) ) { $use_relative_overlay = TRUE; }
36 if( (isset($parts[2])) && (intval($parts[2]) != 0) ) { $grid_snap_value = intval($parts[2]); }
37}
38 
39if( isset($config) )
40{
41 $configerror = 'OLD editor config file format. The format of this file changed in version 0.92 - please check the new editor-config.php-dist and update your editor-config.php file. [WMEDIT02]';
42}
43 
44// check if the goalposts have moved
45if( is_dir($cacti_base) && file_exists($cacti_base."/include/global.php") )
46{
4713simandl // include the cacti-config, so we know about the database
4885simandl include_once($cacti_base."/include/global.php");
49 $config['base_url'] = $cacti_url;
50 $cacti_found = TRUE;
51}
52elseif( is_dir($cacti_base) && file_exists($cacti_base."/include/config.php") )
53{
54 // include the cacti-config, so we know about the database
5513simandl include_once($cacti_base."/include/config.php");
56 
5785simandl $config['base_url'] = $cacti_url;
58 $cacti_found = TRUE;
5913simandl}
60else
61{
62 $cacti_found = FALSE;
63}
64 
6585simandlif($cacti_found && isset($plugins))
66{
67 # here, we know we're part of a plugin - do auth stuff
68}
69 
70if(! is_writable($mapdir))
71{
72 $configerror = "The map config directory is not writable by the web server user. You will not be able to edit any files until this is corrected. [WMEDIT01]";
73}
74 
7513simandlchdir(dirname(__FILE__));
76 
771simandl$action = '';
78$mapname = '';
79$selected = '';
80 
81$newaction = '';
82$param = '';
83$param2 = '';
84$log = '';
85 
86if(!module_checks())
87{
88 print "<b>Required PHP extensions are not present in your mod_php/ISAPI PHP module. Please check your PHP setup to ensure you have the GD extension installed and enabled.</b><p>";
89 print "If you find that the weathermap tool itself is working, from the command-line or Cacti poller, then it is possible that you have two different PHP installations. The Editor uses the same PHP that webpages on your server use, but the main weathermap tool uses the command-line PHP interpreter.<p>";
9085simandl print "<p>You should also run <a href=\"check.php\">check.php</a> to help make sure that there are no problems.</p><hr/>";
911simandl print "Here is a copy of the phpinfo() from your PHP web module, to help debugging this...<hr>";
92 phpinfo();
93 exit();
94}
95 
96if(isset($_REQUEST['action'])) { $action = $_REQUEST['action']; }
9785simandlif(isset($_REQUEST['mapname'])) { $mapname = $_REQUEST['mapname']; $mapname = str_replace('/','',$mapname); }
981simandlif(isset($_REQUEST['selected'])) { $selected = $_REQUEST['selected']; }
99 
10085simandl$weathermap_debugging=FALSE;
101 
1021simandlif($mapname == '')
103{
104 // this is the file-picker/welcome page
105 show_editor_startpage();
106}
107else
108{
109 // everything else in this file is inside this else
110 $mapfile = $mapdir.'/'.$mapname;
111 
11285simandl debug("==========================================================================================================\n");
113 debug("Starting Edit Run: action is $action on $mapname\n");
114 debug("==========================================================================================================\n");
115 
116 # editor_log("\n\n-----------------------------------------------------------------------------\nNEW REQUEST:\n\n");
117 # editor_log(var_log($_REQUEST));
118 
1191simandl $map = new WeatherMap;
120 $map->context = 'editor';
12185simandl 
122 $fromplug = FALSE;
123 if(isset($_REQUEST['plug']) && (intval($_REQUEST['plug'])==1) ) { $fromplug = TRUE; }
124 
1251simandl switch($action)
126 {
127 case 'newmap':
128 $map->WriteConfig($mapfile);
129 break;
130 
13185simandl case 'newmapcopy':
132 if(isset($_REQUEST['sourcemap'])) { $sourcemapname = $_REQUEST['sourcemap']; }
133 $sourcemap = $mapdir.'/'.$sourcemapname;
134 $map->ReadConfig($sourcemap);
135 $map->WriteConfig($mapfile);
136 break;
137 
1381simandl case 'font_samples':
13913simandl $map->ReadConfig($mapfile);
140 ksort($map->fonts);
1411simandl header('Content-type: image/png');
142 
14313simandl $keyfont = 2;
144 $keyheight = imagefontheight($keyfont)+2;
145 
146 $sampleheight = 32;
147 // $im = imagecreate(250,imagefontheight(5)+5);
148 $im = imagecreate(2000,$sampleheight);
149 $imkey = imagecreate(2000,$keyheight);
1501simandl 
151 $white = imagecolorallocate($im,255,255,255);
152 $black = imagecolorallocate($im,0,0,0);
15313simandl $whitekey = imagecolorallocate($imkey,255,255,255);
154 $blackkey = imagecolorallocate($imkey,0,0,0);
1551simandl 
156 $x = 3;
15713simandl #for($i=1; $i< 6; $i++)
158 foreach ($map->fonts as $fontnumber => $font)
1591simandl {
16013simandl $string = "Abc123%";
161 $keystring = "Font $fontnumber";
162 list($width,$height) = $map->myimagestringsize($fontnumber,$string);
163 list($kwidth,$kheight) = $map->myimagestringsize($keyfont,$keystring);
164 
165 if($kwidth > $width) $width = $kwidth;
166 
167 $y = ($sampleheight/2) + $height/2;
168 $map->myimagestring($im, $fontnumber, $x, $y, $string, $black);
169 $map->myimagestring($imkey, $keyfont,$x,$keyheight,"Font $fontnumber",$blackkey);
170 
171 $x = $x + $width + 6;
1721simandl }
17313simandl $im2 = imagecreate($x,$sampleheight + $keyheight);
174 imagecopy($im2,$im, 0,0, 0,0, $x, $sampleheight);
175 imagecopy($im2,$imkey, 0,$sampleheight, 0,0, $x, $keyheight);
1761simandl imagedestroy($im);
17713simandl imagepng($im2);
178 imagedestroy($im2);
1791simandl 
180 exit();
181 break;
18285simandl 
1831simandl case 'draw':
184 header('Content-type: image/png');
185 $map->ReadConfig($mapfile);
186 
187 if($selected != '')
188 {
189 if(substr($selected,0,5) == 'NODE:')
190 {
191 $nodename = substr($selected,5);
192 $map->nodes[$nodename]->selected=1;
193 }
194 
195 if(substr($selected,0,5) == 'LINK:')
196 {
197 $linkname = substr($selected,5);
198 $map->links[$linkname]->selected=1;
199 }
200 }
201 
202 $map->sizedebug = TRUE;
203 // $map->RandomData();
20485simandl $map->DrawMap('','',250,TRUE,$use_overlay,$use_relative_overlay);
2051simandl exit();
206 break;
207 
208 case 'show_config':
209 header('Content-type: text/plain');
210 
211 $fd = fopen($mapfile,'r');
212 while (!feof($fd))
213 {
214 $buffer = fgets($fd, 4096);
215 echo $buffer;
216 }
217 fclose($fd);
218 
219 exit();
220 break;
22185simandl 
222 case 'fetch_config':
223 $map->ReadConfig($mapfile);
224 header('Content-type: text/plain');
225 $item_name = $_REQUEST['item_name'];
226 $item_type = $_REQUEST['item_type'];
227 $ok=FALSE;
2281simandl 
22985simandl if($item_type == 'node'){
230 if (isset($map->nodes[$item_name])) {
231 print $map->nodes[$item_name]->WriteConfig();
232 $ok=TRUE;
233 }
234 }
235 if($item_type == 'link') {
236 if(isset($map->links[$item_name])) {
237 print $map->links[$item_name]->WriteConfig();
238 $ok=TRUE;
239 }
240 }
241 
242 if (! $ok) {
243 print "# the request item didn't exist. That's probably a bug.\n";
244 }
245 
246 exit();
247 break;
248 
249 case "set_link_config":
250 $map->ReadConfig($mapfile);
251 
252 $link_name = $_REQUEST['link_name'];
253 $link_config = fix_gpc_string($_REQUEST['item_configtext']);
254 
255 $map->links[$link_name]->config_override = $link_config;
256 
257 $map->WriteConfig($mapfile);
258 // now clear and reload the map object, because the in-memory one is out of sync
259 // - we don't know what changes the user made here, so we just have to reload.
260 unset($map);
261 $map = new WeatherMap;
262 $map->context = 'editor';
263 $map->ReadConfig($mapfile);
264 break;
265 
266 case "set_node_config":
267 $map->ReadConfig($mapfile);
268 
269 $node_name = $_REQUEST['node_name'];
270 $node_config = fix_gpc_string($_REQUEST['item_configtext']);
271 
272 if (true == function_exists('get_magic_quotes_gpc') && 1 == get_magic_quotes_gpc()) {
273 $link_config = stripslashes($link_config);
274 }
275 
276 $map->nodes[$node_name]->config_override = $node_config;
277 
278 $map->WriteConfig($mapfile);
279 // now clear and reload the map object, because the in-memory one is out of sync
280 // - we don't know what changes the user made here, so we just have to reload.
281 unset($map);
282 $map = new WeatherMap;
283 $map->context = 'editor';
284 $map->ReadConfig($mapfile);
285 break;
286 
2871simandl case "set_node_properties":
288 $map->ReadConfig($mapfile);
289 
290 $node_name = $_REQUEST['node_name'];
291 $new_node_name = $_REQUEST['node_new_name'];
292 
293 if($node_name != $new_node_name)
294 {
295 if(!isset($map->nodes[$new_node_name]))
296 {
297 // we need to rename the node first.
298 $newnode = $map->nodes[$node_name];
299 $newnode->name = $new_node_name;
300 $map->nodes[$new_node_name] = $newnode;
301 unset($map->nodes[$node_name]);
302 
30385simandl // find the references elsewhere to the old node name.
304 // First, relatively-positioned NODEs
305 foreach ($map->nodes as $node)
306 {
307 if($node->relative_to == $node_name)
308 {
309 $map->nodes[$node->name]->relative_to = $new_node_name;
310 }
311 }
312 // Next, LINKs that use this NODE as an end.
3131simandl foreach ($map->links as $link)
314 {
31585simandl if(isset($link->a))
316 {
3171simandl if($link->a->name == $node_name)
318 {
319 $map->links[$link->name]->a = $newnode;
320 }
321 if($link->b->name == $node_name)
322 {
323 $map->links[$link->name]->b = $newnode;
324 }
32585simandl // while we're here, VIAs can also be relative to a NODE,
326 // so check if any of those need to change
327 if( (count($link->vialist)>0) )
328 {
329 $vv=0;
330 foreach($link->vialist as $v)
331 {
332 if(isset($v[2]) && $v[2] == $node_name)
333 {
334 // die PHP4, die!
335 $map->links[$link->name]->vialist[$vv][2] = $new_node_name;
336 }
337 $vv++;
338 }
339 }
340 }
3411simandl }
342 }
343 else
344 {
345 // silently ignore attempts to rename a node to an existing name
346 $new_node_name = $node_name;
347 }
348 }
349 
350 // by this point, and renaming has been done, and new_node_name will always be the right name
351 $map->nodes[$new_node_name]->label = $_REQUEST['node_label'];
35285simandl $map->nodes[$new_node_name]->infourl[IN] = $_REQUEST['node_infourl'];
353 $urls = preg_split('/\s+/', $_REQUEST['node_hover'], -1, PREG_SPLIT_NO_EMPTY);
354 $map->nodes[$new_node_name]->overliburl[IN] = $urls;
355 $map->nodes[$new_node_name]->overliburl[OUT] = $urls;
356 
357 $map->nodes[$new_node_name]->x = intval($_REQUEST['node_x']);
358 $map->nodes[$new_node_name]->y = intval($_REQUEST['node_y']);
3591simandl 
360 if($_REQUEST['node_iconfilename'] == '--NONE--')
361 {
362 $map->nodes[$new_node_name]->iconfile='';
363 }
364 else
365 {
36685simandl // AICONs mess this up, because they're not fully supported by the editor, but it can still break them
367 if($_REQUEST['node_iconfilename'] != '--AICON--')
368 $map->nodes[$new_node_name]->iconfile = stripslashes($_REQUEST['node_iconfilename']);
3691simandl }
370 
371 $map->WriteConfig($mapfile);
372 break;
373 
374 case "set_link_properties":
375 $map->ReadConfig($mapfile);
376 $link_name = $_REQUEST['link_name'];
377 
378 
37985simandl $map->links[$link_name]->width = floatval($_REQUEST['link_width']);
380 $map->links[$link_name]->infourl[IN] = $_REQUEST['link_infourl'];
381 $map->links[$link_name]->infourl[OUT] = $_REQUEST['link_infourl'];
382 $urls = preg_split('/\s+/', $_REQUEST['link_hover'], -1, PREG_SPLIT_NO_EMPTY);
383 $map->links[$link_name]->overliburl[IN] = $urls;
384 $map->links[$link_name]->overliburl[OUT] = $urls;
385 
386 $map->links[$link_name]->comments[IN] = $_REQUEST['link_commentin'];
387 $map->links[$link_name]->comments[OUT] = $_REQUEST['link_commentout'];
388 $map->links[$link_name]->commentoffset_in = intval($_REQUEST['link_commentposin']);
389 $map->links[$link_name]->commentoffset_out = intval($_REQUEST['link_commentposout']);
390 
3911simandl // $map->links[$link_name]->target = $_REQUEST['link_target'];
392 
393 $targets = preg_split('/\s+/',$_REQUEST['link_target'],-1,PREG_SPLIT_NO_EMPTY);
394 $new_target_list = array();
395 
396 foreach ($targets as $target)
397 {
398 // we store the original TARGET string, and line number, along with the breakdown, to make nicer error messages later
399 $newtarget = array($target,'traffic_in','traffic_out',0,$target);
400 
401 // if it's an RRD file, then allow for the user to specify the
402 // DSs to be used. The default is traffic_in, traffic_out, which is
403 // OK for Cacti (most of the time), but if you have other RRDs...
404 if(preg_match("/(.*\.rrd):([\-a-zA-Z0-9_]+):([\-a-zA-Z0-9_]+)$/i",$target,$matches))
405 {
406 $newtarget[0] = $matches[1];
407 $newtarget[1] = $matches[2];
408 $newtarget[2] = $matches[3];
409 }
410 // now we've (maybe) messed with it, we'll store the array of target specs
411 $new_target_list[] = $newtarget;
412 }
413 $map->links[$link_name]->targets = $new_target_list;
414 
415 $bwin = $_REQUEST['link_bandwidth_in'];
416 $bwout = $_REQUEST['link_bandwidth_out'];
417 
418 if(isset($_REQUEST['link_bandwidth_out_cb']) && $_REQUEST['link_bandwidth_out_cb'] == 'symmetric')
419 {
420 $bwout = $bwin;
421 }
422 
42385simandl // $map->links[$link_name]->SetBandwidth($bwin,$bwout);
424 $map->links[$link_name]->max_bandwidth_in_cfg = $bwin;
425 $map->links[$link_name]->max_bandwidth_out_cfg = $bwout;
426 $map->links[$link_name]->max_bandwidth_in = unformat_number($bwin, $map->kilo);
427 $map->links[$link_name]->max_bandwidth_out = unformat_number($bwout, $map->kilo);
4281simandl 
42985simandl 
4301simandl $map->WriteConfig($mapfile);
431 break;
432 
433 case "set_map_properties":
434 $map->ReadConfig($mapfile);
435 
436 $map->title = $_REQUEST['map_title'];
437 $map->keytext['DEFAULT'] = $_REQUEST['map_legend'];
438 $map->stamptext = $_REQUEST['map_stamp'];
439 
440 $map->htmloutputfile = $_REQUEST['map_htmlfile'];
441 $map->imageoutputfile = $_REQUEST['map_pngfile'];
442 
443 $map->width = intval($_REQUEST['map_width']);
444 $map->height = intval($_REQUEST['map_height']);
445 
446 // XXX sanitise this a bit
447 if($_REQUEST['map_bgfile'] == '--NONE--')
448 {
449 $map->background='';
450 }
451 else
452 {
453 $map->background = stripslashes($_REQUEST['map_bgfile']);
454 }
455 
45613simandl $inheritables = array(
457 array('link','width','map_linkdefaultwidth'),
458 );
459 
460 handle_inheritance($map, $inheritables);
46185simandl $map->links['DEFAULT']->width = intval($_REQUEST['map_linkdefaultwidth']);
462 $map->links['DEFAULT']->add_note("my_width", intval($_REQUEST['map_linkdefaultwidth']));
46313simandl 
464 $bwin = $_REQUEST['map_linkdefaultbwin'];
465 $bwout = $_REQUEST['map_linkdefaultbwout'];
466 
46785simandl $bwin_old = $map->links['DEFAULT']->max_bandwidth_in_cfg;
468 $bwout_old = $map->links['DEFAULT']->max_bandwidth_out_cfg;
46913simandl 
470 if( ($bwin_old != $bwin) || ($bwout_old != $bwout) )
4711simandl {
47285simandl $map->links['DEFAULT']->max_bandwidth_in_cfg = $bwin;
473 $map->links['DEFAULT']->max_bandwidth_out_cfg = $bwout;
474 $map->links['DEFAULT']->max_bandwidth_in = unformat_number($bwin, $map->kilo);
475 $map->links['DEFAULT']->max_bandwidth_out = unformat_number($bwout, $map->kilo);
476 
477 // $map->defaultlink->SetBandwidth($bwin,$bwout);
47813simandl foreach ($map->links as $link)
4791simandl {
48013simandl if( ($link->max_bandwidth_in_cfg == $bwin_old) || ($link->max_bandwidth_out_cfg == $bwout_old) )
481 {
48285simandl // $link->SetBandwidth($bwin,$bwout);
483 $link_name = $link->name;
484 $map->links[$link_name]->max_bandwidth_in_cfg = $bwin;
485 $map->links[$link_name]->max_bandwidth_out_cfg = $bwout;
486 $map->links[$link_name]->max_bandwidth_in = unformat_number($bwin, $map->kilo);
487 $map->links[$link_name]->max_bandwidth_out = unformat_number($bwout, $map->kilo);
48813simandl }
4891simandl }
490 }
491 
492 $map->WriteConfig($mapfile);
493 break;
494 
495 case 'set_map_style':
496 $map->ReadConfig($mapfile);
497 
498 $map->htmlstyle = $_REQUEST['mapstyle_htmlstyle'];
499 $map->keyfont = intval($_REQUEST['mapstyle_legendfont']);
500 
50113simandl $inheritables = array(
502 array('link','labelstyle','mapstyle_linklabels'),
503 array('link','bwfont','mapstyle_linkfont'),
504 array('link','arrowstyle','mapstyle_arrowstyle'),
505 array('node','labelfont','mapstyle_nodefont')
506 );
507 
508 handle_inheritance($map, $inheritables);
509 
5101simandl $map->WriteConfig($mapfile);
511 break;
512 
513 case "add_link":
514 $map->ReadConfig($mapfile);
515 
516 $param2 = $_REQUEST['param'];
51785simandl # $param2 = substr($param2,0,-2);
5181simandl $newaction = 'add_link2';
51985simandl # print $newaction;
520 $selected = 'NODE:'.$param2;
521 
5221simandl break;
523 
524 case "add_link2":
525 $map->ReadConfig($mapfile);
526 $a = $_REQUEST['param2'];
527 $b = $_REQUEST['param'];
52885simandl # $b = substr($b,0,-2);
5291simandl $log = "[$a -> $b]";
530 
531 if($a != $b)
532 {
533 $newlink = new WeatherMapLink;
534 $newlink->Reset($map);
53585simandl 
5361simandl $newlink->a = $map->nodes[$a];
537 $newlink->b = $map->nodes[$b];
53885simandl 
539 // $newlink->SetBandwidth($map->defaultlink->max_bandwidth_in_cfg, $map->defaultlink->max_bandwidth_out_cfg);
540 
541 $newlink->width = $map->links['DEFAULT']->width;
5421simandl 
543 // make sure the link name is unique. We can have multiple links between
544 // the same nodes, these days
545 $newlinkname = "$a-$b";
546 while(array_key_exists($newlinkname,$map->links))
547 {
548 $newlinkname .= "a";
549 }
550 $newlink->name = $newlinkname;
55185simandl $newlink->defined_in = $map->configfile;
5521simandl $map->links[$newlinkname] = $newlink;
55385simandl array_push($map->seen_zlayers[$newlink->zorder], $newlink);
5541simandl 
555 $map->WriteConfig($mapfile);
556 }
557 break;
558 
559 case "place_legend":
56085simandl $x = snap( intval($_REQUEST['x']) ,$grid_snap_value);
561 $y = snap( intval($_REQUEST['y']) ,$grid_snap_value);
5621simandl $scalename = $_REQUEST['param'];
563 
564 $map->ReadConfig($mapfile);
565 
566 $map->keyx[$scalename] = $x;
567 $map->keyy[$scalename] = $y;
568 
569 $map->WriteConfig($mapfile);
570 break;
571 
572 case "place_stamp":
57385simandl $x = snap( intval($_REQUEST['x']), $grid_snap_value);
574 $y = snap( intval($_REQUEST['y']), $grid_snap_value);
5751simandl 
576 $map->ReadConfig($mapfile);
577 
578 $map->timex = $x;
579 $map->timey = $y;
580 
581 $map->WriteConfig($mapfile);
582 break;
583 
58485simandl 
585 case "via_link":
5861simandl $x = intval($_REQUEST['x']);
587 $y = intval($_REQUEST['y']);
58885simandl $link_name = $_REQUEST['link_name'];
589 
590 $map->ReadConfig($mapfile);
591 
592 $map->links[$link_name]->vialist = array(array(0 =>$x, 1=>$y));
593 
594 $map->WriteConfig($mapfile);
595 break;
596 
597 
598 case "move_node":
599 $x = snap( intval($_REQUEST['x']), $grid_snap_value);
600 $y = snap( intval($_REQUEST['y']), $grid_snap_value);
6011simandl $node_name = $_REQUEST['node_name'];
602 
603 $map->ReadConfig($mapfile);
604 
60585simandl // This is a complicated bit. Find out if this node is involved in any
606 // links that have VIAs. If it is, we want to rotate those VIA points
607 // about the *other* node in the link
608 foreach ($map->links as $link)
60913simandl {
61085simandl if( (count($link->vialist)>0) && (($link->a->name == $node_name) || ($link->b->name == $node_name)) )
611 {
612 // get the other node from us
613 if($link->a->name == $node_name) $pivot = $link->b;
614 if($link->b->name == $node_name) $pivot = $link->a;
615 
616 if( ($link->a->name == $node_name) && ($link->b->name == $node_name) )
617 {
618 // this is a wierd special case, but it is possible
619 # $log .= "Special case for node1->node1 links\n";
620 $dx = $link->a->x - $x;
621 $dy = $link->a->y - $y;
62213simandl 
62385simandl for($i=0; $i<count($link->vialist); $i++)
62413simandl {
62585simandl $link->vialist[$i][0] = $link->vialist[$i][0]-$dx;
626 $link->vialist[$i][1] = $link->vialist[$i][1]-$dy;
62713simandl }
62885simandl }
629 else
630 {
631 $pivx = $pivot->x;
632 $pivy = $pivot->y;
633 
634 $dx_old = $pivx - $map->nodes[$node_name]->x;
635 $dy_old = $pivy - $map->nodes[$node_name]->y;
636 $dx_new = $pivx - $x;
637 $dy_new = $pivy - $y;
638 $l_old = sqrt($dx_old*$dx_old + $dy_old*$dy_old);
639 $l_new = sqrt($dx_new*$dx_new + $dy_new*$dy_new);
640 
641 $angle_old = rad2deg(atan2(-$dy_old,$dx_old));
642 $angle_new = rad2deg(atan2(-$dy_new,$dx_new));
643 
644 # $log .= "$pivx,$pivy\n$dx_old $dy_old $l_old => $angle_old\n";
645 # $log .= "$dx_new $dy_new $l_new => $angle_new\n";
646 
647 // the geometry stuff uses a different point format, helpfully
648 $points = array();
649 foreach($link->vialist as $via)
65013simandl {
65185simandl $points[] = $via[0];
652 $points[] = $via[1];
653 }
65413simandl 
65585simandl $scalefactor = $l_new/$l_old;
656 # $log .= "Scale by $scalefactor along link-line";
657 
658 // rotate so that link is along the axis
659 RotateAboutPoint($points,$pivx, $pivy, deg2rad($angle_old));
660 // do the scaling in here
661 for($i=0; $i<(count($points)/2); $i++)
662 {
663 $basex = ($points[$i*2] - $pivx) * $scalefactor + $pivx;
664 $points[$i*2] = $basex;
665 }
666 // rotate back so that link is along the new direction
667 RotateAboutPoint($points,$pivx, $pivy, deg2rad(-$angle_new));
668 
669 // now put the modified points back into the vialist again
670 $v = 0; $i = 0;
671 foreach($points as $p)
672 {
673 // skip a point if it positioned relative to a node. Those shouldn't be rotated (well, IMHO)
674 if(!isset($link->vialist[$v][2]))
67513simandl {
676 $link->vialist[$v][$i]=$p;
677 }
67885simandl $i++;
679 if($i==2) { $i=0; $v++;}
68013simandl }
681 }
682 }
683 }
68485simandl 
6851simandl $map->nodes[$node_name]->x = $x;
686 $map->nodes[$node_name]->y = $y;
687 
688 $map->WriteConfig($mapfile);
689 break;
690 
69185simandl case "link_align_horizontal":
692 $map->ReadConfig($mapfile);
6931simandl 
69485simandl $target = $_REQUEST['param'];
695 $log = "align link ".$target;
696 
697 $a_y = $map->links[$target]->a->y;
698 $b_y = $map->links[$target]->b->y;
699 
700 $diff = $b_y - $a_y;
701 $newoffset = "0:$diff";
702 
703 // if we've already done this once, try the other way around...
704 if($map->links[$target]->a_offset == $newoffset)
705 {
706 $diff = $a_y - $b_y;
707 $newoffset = "0:$diff";
708 $map->links[$target]->b_offset = $newoffset;
709 $map->links[$target]->a_offset = "C";
710 }
711 else
712 {
713 // the standard thing
714 $map->links[$target]->a_offset = $newoffset;
715 $map->links[$target]->b_offset = "C";
716 }
717 
718 $map->WriteConfig($mapfile);
719 break;
720 
721 case "link_align_vertical":
7221simandl $map->ReadConfig($mapfile);
723 
72485simandl $target = $_REQUEST['param'];
725 $log = "align link ".$target;
7261simandl 
72785simandl $a_x = $map->links[$target]->a->x;
728 $b_x = $map->links[$target]->b->x;
729 
730 $diff = $b_x - $a_x;
731 $newoffset = "$diff:0";
732 
733 // if we've already done this once, try the other way around...
734 if($map->links[$target]->a_offset == $newoffset)
735 {
736 $diff = $a_x - $b_x;
737 $newoffset = "$diff:0";
738 $map->links[$target]->b_offset = $newoffset;
739 $map->links[$target]->a_offset = "C";
740 }
741 else
742 {
743 // the standard thing
744 $map->links[$target]->a_offset = $newoffset;
745 $map->links[$target]->b_offset = "C";
746 }
7471simandl 
748 $map->WriteConfig($mapfile);
74985simandl break;
7501simandl 
751 case "delete_link":
752 $map->ReadConfig($mapfile);
753 
754 $target = $_REQUEST['param'];
755 $log = "delete link ".$target;
756 
757 unset($map->links[$target]);
75885simandl 
759 $map->WriteConfig($mapfile);
760 break;
7611simandl 
76285simandl case "add_node":
763 $x = snap(intval($_REQUEST['x']), $grid_snap_value);
764 $y = snap(intval($_REQUEST['y']), $grid_snap_value);
765 
766 $map->ReadConfig($mapfile);
767 
768 $newnodename = sprintf("node%05d",time()%10000);
769 while(array_key_exists($newnodename,$map->nodes))
770 {
771 $newnodename .= "a";
772 }
773 
774 $node = new WeatherMapNode;
775 $node->name = $newnodename;
776 $node->template = "DEFAULT";
777 $node->Reset($map);
778 
779 $node->x = $x;
780 $node->y = $y;
781 $node->defined_in = $map->configfile;
782 
783 array_push($map->seen_zlayers[$node->zorder], $node);
784 
785 // only insert a label if there's no LABEL in the DEFAULT node.
786 // otherwise, respect the template.
787 if($map->nodes['DEFAULT']->label == $map->nodes[':: DEFAULT ::']->label)
788 {
789 $node->label = "Node";
790 }
791 
792 $map->nodes[$node->name] = $node;
793 $log = "added a node called $newnodename at $x,$y to $mapfile";
794 
7951simandl $map->WriteConfig($mapfile);
796 break;
797 
79885simandl case "editor_settings":
799 // have to do this, otherwise the editor will be unresponsive afterwards - not actually going to change anything!
800 $map->ReadConfig($mapfile);
801 
802 $use_overlay = (isset($_REQUEST['editorsettings_showvias']) ? intval($_REQUEST['editorsettings_showvias']) : FALSE);
803 $use_relative_overlay = (isset($_REQUEST['editorsettings_showrelative']) ? intval($_REQUEST['editorsettings_showrelative']) : FALSE);
804 $grid_snap_value = (isset($_REQUEST['editorsettings_gridsnap']) ? intval($_REQUEST['editorsettings_gridsnap']) : 0);
805 
806 break;
807 
8081simandl case "delete_node":
809 $map->ReadConfig($mapfile);
810 
811 $target = $_REQUEST['param'];
812 $log = "delete node ".$target;
813 
814 foreach ($map->links as $link)
815 {
81685simandl if( isset($link->a) )
8171simandl {
81885simandl if( ($target == $link->a->name) || ($target == $link->b->name) )
819 {
820 unset($map->links[$link->name]);
821 }
8221simandl }
823 }
824 
825 unset($map->nodes[$target]);
826 
827 $map->WriteConfig($mapfile);
828 break;
829 
83085simandl case "clone_node":
831 $map->ReadConfig($mapfile);
832 
833 $target = $_REQUEST['param'];
834 $log = "clone node ".$target;
835 
836 $newnodename = $target;
837 do
838 {
839 $newnodename = $newnodename."_copy";
840 } while(isset($map->nodes[$newnodename]));
841 
842 $node = new WeatherMapNode;
843 $node->Reset($map);
844 $node->CopyFrom($map->nodes[$target]);
845 
846 $node->name = $newnodename;
847 $node->x += 30;
848 $node->y += 30;
849 $node->defined_in = $mapfile;
850 
851 
852 $map->nodes[$newnodename] = $node;
853 array_push($map->seen_zlayers[$node->zorder], $node);
854 
855 $map->WriteConfig($mapfile);
856 break;
857 
8581simandl // no action was defined - starting a new map?
859 default:
860 $map->ReadConfig($mapfile);
861 break;
86285simandl }
863 
864 //by here, there should be a valid $map - either a blank one, the existing one, or the existing one with requested changes
865 debug("Finished modifying\n");
8661simandl 
86785simandl // now we'll just draw the full editor page, with our new knowledge
8681simandl 
869 $imageurl = '?mapname='.$mapname . '&amp;action=draw';
870 if($selected != '')
871 {
872 $imageurl .= '&amp;selected='.$selected;
873 }
874 
875 $imageurl .= '&amp;unique='.time();
876 
87785simandl // build up the editor's list of used images
878 if($map->background != '') $map->used_images[] = $map->background;
879 foreach ($map->nodes as $n)
880 {
881 if($n->iconfile != '' && ! preg_match("/^(none|nink|inpie|outpie|box|rbox|gauge|round)$/",$n->iconfile))
882 $map->used_images[] = $n->iconfile;
883 }
884 
885 // get the list from the images/ folder too
88613simandl $imlist = get_imagelist("images");
887 
888 $fontlist = array();
889 
89085simandl setcookie("wmeditor", ($use_overlay ? "1":"0") .":". ($use_relative_overlay ? "1":"0") . ":" . intval($grid_snap_value), time()+60*60*24*30 );
8911simandl 
892?>
893<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
894<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
895<head>
89685simandl<style type="text/css">
8971simandl<?php
898 // if the cacti config was included properly, then
899 // this will be non-empty, and we can unhide the cacti links in the Link Properties box
900 if( ! isset($config['cacti_version']) )
901 {
902 echo " .cactilink { display: none; }\n";
90313simandl echo " .cactinode { display: none; }\n";
9041simandl }
905?>
906 </style>
907 <link rel="stylesheet" type="text/css" media="screen" href="editor.css" />
90885simandl<script src="editor-resources/jquery-latest.min.js" type="text/javascript"></script>
909<script src="editor.js" type="text/javascript"></script>
9101simandl <script type="text/javascript">
91185simandl 
912 var fromplug=<?php echo ($fromplug==TRUE ? 1:0); ?>;
913 
9141simandl // the only javascript in here should be the objects representing the map itself
915 // all code should be in editor.js
916 <?php print $map->asJS() ?>
917<?php
918 
919 // append any images used in the map that aren't in the images folder
920 foreach ($map->used_images as $im)
921 {
922 if(! in_array($im,$imlist))
923 {
924 $imlist[]=$im;
925 }
926 }
927 
928 sort($imlist);
929?>
930 </script>
931 <title>PHP Weathermap Editor <?php echo $WEATHERMAP_VERSION; ?></title>
932</head>
933 
934<body id="mainview">
935 <div id="toolbar">
936 <ul>
93785simandl <li class="tb_active" id="tb_newfile">Change<br />File</li>
9381simandl <li class="tb_active" id="tb_addnode">Add<br />Node</li>
939 <li class="tb_active" id="tb_addlink">Add<br />Link</li>
940 <li class="tb_active" id="tb_poslegend">Position<br />Legend</li>
941 <li class="tb_active" id="tb_postime">Position<br />Timestamp</li>
942 <li class="tb_active" id="tb_mapprops">Map<br />Properties</li>
943 <li class="tb_active" id="tb_mapstyle">Map<br />Style</li>
944 <li class="tb_active" id="tb_colours">Manage<br />Colors</li>
945 <li class="tb_active" id="tb_manageimages">Manage<br />Images</li>
946 <li class="tb_active" id="tb_prefs">Editor<br />Settings</li>
94785simandl <li class="tb_coords" id="tb_coords">Position<br />---, ---</li>
9481simandl <li class="tb_help"><span id="tb_help">or click a Node or Link to edit it's properties</span></li>
949 </ul>
950 </div>
951 <form action="editor.php" method="post" name="frmMain">
95285simandl <div align="center" id="mainarea">
953 <input type="hidden" name="plug" value="<?php echo ($fromplug==TRUE ? 1 : 0) ?>" />
9541simandl <input style="display:none" type="image"
955 src="<?php echo $imageurl; ?>" id="xycapture" /><img src=
956 "<?php echo $imageurl; ?>" id="existingdata" alt="Weathermap" usemap="#weathermap_imap"
95785simandl />
958 <div class="debug"><p><strong>Debug:</strong> <a href="?<?php echo ($fromplug==TRUE ? 'plug=1&amp;' : ''); ?>action=nothing&amp;mapname=<?php echo $mapname ?>">Do Nothing</a>
9591simandl <span><label for="mapname">mapfile</label><input type="text" name="mapname" value="<?php echo $mapname; ?>" /></span>
96085simandl <span><label for="action">action</label><input type="text" id="action" name="action" value="<?php echo $newaction; ?>" /></span>
961 <span><label for="param">param</label><input type="text" name="param" id="param" value="" /></span>
962 <span><label for="param2">param2</label><input type="text" name="param2" id="param2" value="<?php echo $param2; ?>" /></span>
9631simandl <span><label for="debug">debug</label><input id="debug" value="" name="debug" /></span>
96485simandl <a target="configwindow" href="?<?php echo ($fromplug==TRUE ? 'plug=1&amp;':''); ?>action=show_config&amp;mapname=<?php echo $mapname ?>">See config</a></p>
96513simandl <pre><?php echo $log ?></pre>
9661simandl </div>
967<?php
968 // we need to draw and throw away a map, to get the
969 // dimensions for the imagemap. Oh well.
970 $map->DrawMap('null');
971 $map->htmlstyle='editor';
972 $map->PreloadMapHTML();
973 
97485simandl print $map->SortedImagemap("weathermap_imap");
975 
976 #print $map->imap->subHTML("LEGEND:");
977 #print $map->imap->subHTML("TIMESTAMP");
978 #print $map->imap->subHTML("NODE:");
979 #print $map->imap->subHTML("LINK:");
980 
9811simandl?>
982 </div><!-- Node Properties -->
983 
984 <div id="dlgNodeProperties" class="dlgProperties">
985 <div class="dlgTitlebar">
986 Node Properties
987 <input size="6" name="node_name" type="hidden" />
988 <ul>
98985simandl <li><a id="tb_node_submit" class="wm_submit" title="Submit any changes made">Submit</a></li>
990 <li><a id="tb_node_cancel" class="wm_cancel" title="Cancel any changes">Cancel</a></li>
9911simandl </ul>
992 </div>
993 
994 <div class="dlgBody">
995 <table>
99685simandl <tr>
997 <th>Position</th>
998 <td><input id="node_x" name="node_x" size=4 type="text" />,<input id="node_y" name="node_y" size=4 type="text" /></td>
999 </tr>
10001simandl <tr>
1001 <th>Internal Name</th>
1002 <td><input id="node_new_name" name="node_new_name" type="text" /></td>
1003 </tr>
1004 <tr>
1005 <th>Label</th>
1006 <td><input id="node_label" name="node_label" type="text" /></td>
1007 </tr>
1008 <tr>
1009 <th>Info URL</th>
1010 <td><input id="node_infourl" name="node_infourl" type="text" /></td>
1011 </tr>
1012 <tr>
1013 <th>'Hover' Graph URL</th>
101413simandl <td><input id="node_hover" name="node_hover" type="text" />
1015 <span class="cactinode"><a id="node_cactipick">[Pick from Cacti]</a></span></td>
10161simandl </tr>
1017 <tr>
1018 <th>Icon Filename</th>
1019 <td><select id="node_iconfilename" name="node_iconfilename">
1020 
1021<?php
1022 if(count($imlist)==0)
1023 {
1024 print '<option value="--NONE--">(no images are available)</option>';
1025 }
1026 else
1027 {
1028 print '<option value="--NONE--">--NO ICON--</option>';
102985simandl print '<option value="--AICON--">--ARTIFICIAL ICON--</option>';
10301simandl foreach ($imlist as $im)
1031 {
1032 print "<option ";
1033 print "value=\"$im\">$im</option>\n";
1034 }
1035 }
1036?>
1037 </select></td>
1038 </tr>
1039 <tr>
1040 <th></th>
1041 <td>&nbsp;</td>
1042 </tr>
1043 <tr>
1044 <th></th>
104585simandl <td><a id="node_move" class="dlgTitlebar">Move</a><a class="dlgTitlebar" id="node_delete">Delete</a><a class="dlgTitlebar" id="node_clone">Clone</a><a class="dlgTitlebar" id="node_edit">Edit</a></td>
10461simandl </tr>
1047 </table>
1048 </div>
1049 
1050 <div class="dlgHelp" id="node_help">
1051 Helpful text will appear here, depending on the current
1052 item selected. It should wrap onto several lines, if it's
1053 necessary for it to do that.
1054 </div>
1055 </div><!-- Node Properties -->
1056 
1057 
1058 
1059 
1060 <!-- Link Properties -->
1061 
1062 <div id="dlgLinkProperties" class="dlgProperties">
1063 <div class="dlgTitlebar">
1064 Link Properties
1065 
1066 <ul>
106785simandl <li><a title="Submit any changes made" class="wm_submit" id="tb_link_submit">Submit</a></li>
1068 <li><a title="Cancel any changes" class="wm_cancel" id="tb_link_cancel">Cancel</a></li>
10691simandl </ul>
1070 </div>
1071 
1072 <div class="dlgBody">
1073 <div class="comment">
1074 Link from '<span id="link_nodename1">%NODE1%</span>' to '<span id="link_nodename2">%NODE2%</span>'
1075 </div>
1076 
1077 <input size="6" name="link_name" type="hidden" />
1078 
107985simandl <table width="100%">
10801simandl <tr>
1081 <th>Maximum Bandwidth<br />
1082 Into '<span id="link_nodename1a">%NODE1%</span>'</th>
1083 <td><input size="8" id="link_bandwidth_in" name="link_bandwidth_in" type=
1084 "text" /> bits/sec</td>
1085 </tr>
1086 <tr>
1087 <th>Maximum Bandwidth<br />
1088 Out of '<span id="link_nodename1b">%NODE1%</span>'</th>
1089 <td><input type="checkbox" id="link_bandwidth_out_cb" name=
1090 "link_bandwidth_out_cb" value="symmetric" />Same As
1091 'In' or <input id="link_bandwidth_out" name="link_bandwidth_out"
1092 size="8" type="text" /> bits/sec</td>
1093 </tr>
1094 <tr>
1095 <th>Data Source</th>
1096 <td><input id="link_target" name="link_target" type="text" /> <span class="cactilink"><a id="link_cactipick">[Pick
1097 from Cacti]</a></span></td>
1098 </tr>
1099 <tr>
1100 <th>Link Width</th>
1101 <td><input id="link_width" name="link_width" size="3" type="text" />
1102 pixels</td>
1103 </tr>
1104 <tr>
1105 <th>Info URL</th>
110685simandl <td><input id="link_infourl" size="30" name="link_infourl" type="text" /></td>
11071simandl </tr>
1108 <tr>
1109 <th>'Hover' Graph URL</th>
111085simandl <td><input id="link_hover" size="30" name="link_hover" type="text" /></td>
11111simandl </tr>
111285simandl 
1113 
1114 <tr>
1115 <th>IN Comment</th>
1116 <td><input id="link_commentin" size="25" name="link_commentin" type="text" />
1117 <select id="link_commentposin" name="link_commentposin">
1118 <option value=95>95%</option>
1119 <option value=90>90%</option>
1120 <option value=80>80%</option>
1121 <option value=70>70%</option>
1122 <option value=60>60%</option>
1123 </select>
1124 </td>
1125 </tr>
1126 <tr>
1127 <th>OUT Comment</th>
1128 <td><input id="link_commentout" size="25" name="link_commentout" type="text" />
1129 <select id="link_commentposout" name="link_commentposout">
1130 <option value=5>5%</option>
1131 <option value=10>10%</option>
1132 <option value=20>20%</option>
1133 <option value=30>30%</option>
1134 <option value=40>40%</option>
1135 <option value=50>50%</option>
1136 </select>
1137 </td>
1138 </tr>
1139 
11401simandl <tr>
1141 <th></th>
1142 <td>&nbsp;</td>
1143 </tr>
1144 <tr>
1145 <th></th>
1146 <td><a class="dlgTitlebar" id="link_delete">Delete
114785simandl Link</a><a class="dlgTitlebar" id="link_edit">Edit</a><a
1148 class="dlgTitlebar" id="link_vert">Vert</a><a
1149 class="dlgTitlebar" id="link_horiz">Horiz</a><a
1150 class="dlgTitlebar" id="link_via">Via</a>
1151 </td>
11521simandl </tr>
1153 </table>
1154 </div>
1155 
1156 <div class="dlgHelp" id="link_help">
1157 Helpful text will appear here, depending on the current
1158 item selected. It should wrap onto several lines, if it's
1159 necessary for it to do that.
1160 </div>
1161 </div><!-- Link Properties -->
1162 
1163 <!-- Map Properties -->
1164 
1165 <div id="dlgMapProperties" class="dlgProperties">
1166 <div class="dlgTitlebar">
1167 Map Properties
1168 
1169 <ul>
117085simandl <li><a title="Submit any changes made" class="wm_submit" id="tb_map_submit">Submit</a></li>
1171 <li><a title="Cancel any changes" class="wm_cancel" id="tb_map_cancel">Cancel</a></li>
11721simandl </ul>
1173 </div>
1174 
1175 <div class="dlgBody">
1176 <table>
1177 <tr>
1178 <th>Map Title</th>
117985simandl <td><input id="map_title" name="map_title" size="25" type="text" value="<?php echo $map->title ?>"/></td>
11801simandl </tr>
1181 <tr>
1182 <th>Legend Text</th>
1183 <td><input name="map_legend" size="25" type="text" value="<?php echo $map->keytext['DEFAULT'] ?>" /></td>
1184 </tr>
1185 <tr>
1186 <th>Timestamp Text</th>
1187 <td><input name="map_stamp" size="25" type="text" value="<?php echo $map->stamptext ?>" /></td>
1188 </tr>
1189 
1190 <tr>
1191 <th>Default Link Width</th>
119285simandl <td><input name="map_linkdefaultwidth" size="6" type="text" value="<?php echo $map->links['DEFAULT']->width ?>" /> pixels</td>
11931simandl </tr>
1194 
1195 <tr>
1196 <th>Default Link Bandwidth</th>
119785simandl <td><input name="map_linkdefaultbwin" size="6" type="text" value="<?php echo $map->links['DEFAULT']->max_bandwidth_in_cfg ?>" /> bit/sec in, <input name="map_linkdefaultbwout" size="6" type="text" value="<?php echo $map->links['DEFAULT']->max_bandwidth_out_cfg ?>" /> bit/sec out</td>
11981simandl </tr>
1199 
1200 
1201 <tr>
1202 <th>Map Size</th>
1203 <td><input name="map_width" size="5" type=
1204 "text" value="<?php echo $map->width ?>" /> x <input name="map_height" size="5" type=
1205 "text" value="<?php echo $map->height ?>" /> pixels</td>
1206 </tr>
1207 <tr>
1208 <th>Output Image Filename</th>
1209 <td><input name="map_pngfile" type="text" value="<?php echo $map->imageoutputfile ?>" /></td>
1210 </tr>
1211 <tr>
1212 <th>Output HTML Filename</th>
1213 <td><input name="map_htmlfile" type="text" value="<?php echo $map->htmloutputfile ?>" /></td>
1214 </tr>
1215 <tr>
1216 <th>Background Image Filename</th>
1217 <td><select name="map_bgfile">
1218 
1219<?php
1220 if(count($imlist)==0)
1221 {
1222 print '<option value="--NONE--">(no images are available)</option>';
1223 }
1224 else
1225 {
1226 print '<option value="--NONE--">--NONE--</option>';
1227 foreach ($imlist as $im)
1228 {
1229 print "<option ";
1230 if($map->background == $im) print " selected ";
1231 print "value=\"$im\">$im</option>\n";
1232 
1233 }
1234 }
1235?>
1236 </select></td>
1237 </tr>
123885simandl 
12391simandl </table>
1240 </div>
1241 
1242 <div class="dlgHelp" id="map_help">
1243 Helpful text will appear here, depending on the current
1244 item selected. It should wrap onto several lines, if it's
1245 necessary for it to do that.
1246 </div>
1247 </div><!-- Map Properties -->
1248 
1249 <!-- Map Style -->
1250 <div id="dlgMapStyle" class="dlgProperties">
1251 <div class="dlgTitlebar">
1252 Map Style
1253 
1254 <ul>
125585simandl <li><a title="Submit any changes made" id="tb_mapstyle_submit" class="wm_submit" >Submit</a></li>
1256 <li><a title="Cancel any changes" class="wm_cancel" id="tb_mapstyle_cancel">Cancel</a></li>
12571simandl </ul>
1258 </div>
1259 
1260 <div class="dlgBody">
1261 <table>
1262 <tr>
1263 <th>Link Labels</th>
126485simandl <td><select id="mapstyle_linklabels" name="mapstyle_linklabels">
1265 <option <?php echo ($map->links['DEFAULT']->labelstyle=='bits' ? 'selected' : '') ?> value="bits">Bits/sec</option>
1266 <option <?php echo ($map->links['DEFAULT']->labelstyle=='percent' ? 'selected' : '') ?> value="percent">Percentage</option>
1267 <option <?php echo ($map->links['DEFAULT']->labelstyle=='none' ? 'selected' : '') ?> value="none">None</option>
12681simandl </select></td>
1269 </tr>
1270 <tr>
1271 <th>HTML Style</th>
1272 <td><select name="mapstyle_htmlstyle">
1273 <option <?php echo ($map->htmlstyle=='overlib' ? 'selected' : '') ?> value="overlib">Overlib (DHTML)</option>
1274 <option <?php echo ($map->htmlstyle=='static' ? 'selected' : '') ?> value="static">Static HTML</option>
1275 </select></td>
1276 </tr>
1277 <tr>
1278 <th>Arrow Style</th>
1279 <td><select name="mapstyle_arrowstyle">
128085simandl <option <?php echo ($map->links['DEFAULT']->arrowstyle=='classic' ? 'selected' : '') ?> value="classic">Classic</option>
1281 <option <?php echo ($map->links['DEFAULT']->arrowstyle=='compact' ? 'selected' : '') ?> value="compact">Compact</option>
12821simandl </select></td>
1283 </tr>
1284 <tr>
1285 <th>Node Font</th>
128685simandl <td><?php echo get_fontlist($map,'mapstyle_nodefont',$map->nodes['DEFAULT']->labelfont); ?></td>
12871simandl </tr>
1288 <tr>
1289 <th>Link Label Font</th>
129085simandl <td><?php echo get_fontlist($map,'mapstyle_linkfont',$map->links['DEFAULT']->bwfont); ?></td>
12911simandl </tr>
1292 <tr>
1293 <th>Legend Font</th>
129413simandl <td><?php echo get_fontlist($map,'mapstyle_legendfont',$map->keyfont); ?></td>
12951simandl </tr>
1296 <tr>
1297 <th>Font Samples:</th>
129885simandl <td><div class="fontsamples" ><img alt="Sample of defined fonts" src="?action=font_samples&mapname=<?php echo $mapname?>" /></div><br />(Drawn using your PHP install)</td>
12991simandl </tr>
1300 </table>
1301 </div>
1302 
1303 <div class="dlgHelp" id="mapstyle_help">
1304 Helpful text will appear here, depending on the current
1305 item selected. It should wrap onto several lines, if it's
1306 necessary for it to do that.
1307 </div>
1308 </div><!-- Map Style -->
1309 
1310 
1311 
1312 <!-- Colours -->
1313 
1314 <div id="dlgColours" class="dlgProperties">
1315 <div class="dlgTitlebar">
1316 Manage Colors
1317 
1318 <ul>
131985simandl <li><a title="Submit any changes made" id="tb_colours_submit" class="wm_submit" >Submit</a></li>
1320 <li><a title="Cancel any changes" class="wm_cancel" id="tb_colours_cancel">Cancel</a></li>
13211simandl </ul>
1322 </div>
1323 
1324 <div class="dlgBody">
1325 Nothing in here works yet. The aim is to have a nice color picker somehow.
1326 <table>
1327 <tr>
1328 <th>Background Color</th>
1329 <td></td>
1330 </tr>
1331 
1332 <tr>
1333 <th>Link Outline Color</th>
1334 <td></td>
1335 </tr>
1336 <tr>
1337 <th>Scale Colors</th>
1338 <td>Some pleasant way to design the bandwidth color scale goes in here???</td>
1339 </tr>
1340 
1341 </table>
1342 </div>
1343 
1344 <div class="dlgHelp" id="colours_help">
1345 Helpful text will appear here, depending on the current
1346 item selected. It should wrap onto several lines, if it's
1347 necessary for it to do that.
1348 </div>
1349 </div><!-- Colours -->
1350 
1351 
1352 <!-- Images -->
1353 
1354 <div id="dlgImages" class="dlgProperties">
1355 <div class="dlgTitlebar">
1356 Manage Images
1357 
1358 <ul>
135985simandl <li><a title="Submit any changes made" id="tb_images_submit" class="wm_submit" >Submit</a></li>
1360 <li><a title="Cancel any changes" class="wm_cancel" id="tb_images_cancel">Cancel</a></li>
13611simandl </ul>
1362 </div>
1363 
1364 <div class="dlgBody">
1365 <p>Nothing in here works yet. </p>
1366 The aim is to have some nice way to upload images which can be used as icons or backgrounds.
1367 These images are what would appear in the dropdown boxes that don't currently do anything in the Node and Map Properties dialogs. This may end up being a seperate page rather than a dialog box...
1368 </div>
1369 
1370 <div class="dlgHelp" id="images_help">
1371 Helpful text will appear here, depending on the current
1372 item selected. It should wrap onto several lines, if it's
1373 necessary for it to do that.
1374 </div>
1375 </div><!-- Images -->
1376 
137785simandl <div id="dlgTextEdit" class="dlgProperties">
1378 <div class="dlgTitlebar">
1379 Edit Map Object
1380 <ul>
1381 <li><a title="Submit any changes made" id="tb_textedit_submit" class="wm_submit" >Submit</a></li>
1382 <li><a title="Cancel any changes" class="wm_cancel" id="tb_textedit_cancel">Cancel</a></li>
1383 </ul>
1384 </div>
1385 
1386 <div class="dlgBody">
1387 <p>You can edit the map items directly here.</p>
1388 <textarea wrap="no" id="item_configtext" name="item_configtext" cols=40 rows=15></textarea>
1389 </div>
1390 
1391 <div class="dlgHelp" id="images_help">
1392 Helpful text will appear here, depending on the current
1393 item selected. It should wrap onto several lines, if it's
1394 necessary for it to do that.
1395 </div>
1396 </div><!-- TextEdit -->
1397 
1398 
1399 <div id="dlgEditorSettings" class="dlgProperties">
1400 <div class="dlgTitlebar">
1401 Editor Settings
1402 <ul>
1403 <li><a title="Submit any changes made" id="tb_editorsettings_submit" class="wm_submit" >Submit</a></li>
1404 <li><a title="Cancel any changes" class="wm_cancel" id="tb_editorsettings_cancel">Cancel</a></li>
1405 </ul>
1406 </div>
1407 
1408 <div class="dlgBody">
1409 <table>
1410 <tr>
1411 <th>Show VIAs overlay</th>
1412 <td><select id="editorsettings_showvias" name="editorsettings_showvias">
1413 <option <?php echo ($use_overlay ? 'selected' : '') ?> value="1">Yes</option>
1414 <option <?php echo ($use_overlay ? '' : 'selected') ?> value="0">No</option>
1415 </select>
1416 </td>
1417 </tr>
1418 <tr>
1419 <th>Show Relative Positions overlay</th>
1420 <td><select id="editorsettings_showrelative" name="editorsettings_showrelative">
1421 <option <?php echo ($use_relative_overlay ? 'selected' : '') ?> value="1">Yes</option>
1422 <option <?php echo ($use_relative_overlay ? '' : 'selected') ?> value="0">No</option>
1423 </select>
1424 </td>
1425 </tr>
1426 <tr>
1427 <th>Snap To Grid</th>
1428 <td><select id="editorsettings_gridsnap" name="editorsettings_gridsnap">
1429 <option <?php echo ($grid_snap_value==0 ? 'selected' : '') ?> value="NO">No</option>
1430 <option <?php echo ($grid_snap_value==5 ? 'selected' : '') ?> value="5">5 pixels</option>
1431 <option <?php echo ($grid_snap_value==10 ? 'selected' : '') ?> value="10">10 pixels</option>
1432 <option <?php echo ($grid_snap_value==15 ? 'selected' : '') ?> value="15">15 pixels</option>
1433 <option <?php echo ($grid_snap_value==20 ? 'selected' : '') ?> value="20">20 pixels</option>
1434 <option <?php echo ($grid_snap_value==50 ? 'selected' : '') ?> value="50">50 pixels</option>
1435 <option <?php echo ($grid_snap_value==100 ? 'selected' : '') ?> value="100">100 pixels</option>
1436 </select>
1437 </td>
1438 </tr>
1439 </table>
1440 
1441 </div>
1442 
1443 <div class="dlgHelp" id="images_help">
1444 Helpful text will appear here, depending on the current
1445 item selected. It should wrap onto several lines, if it's
1446 necessary for it to do that.
1447 </div>
1448 </div><!-- TextEdit -->
1449 
1450 
1451 </form>
14521simandl</body>
1453</html>
1454<?php
1455} // if mapname != ''
1456// vim:ts=4:sw=4:
1457?>

Powered by WebSVN 2.2.1