setpath('template', 'tpl'); // tpl dir /** ImageNode */ $title = isset($_GET['title']) ? @$_GET['title'] : 'Test'; $tpl->assign('title', $title); $tpl->assign('pagetitle', $title); /* mode */ $mode = @$_GET['mode']; /** * Get image and its map from DB */ $result = $DB->getRow("SELECT * FROM node WHERE title = '$title' LIMIT 1"); if (DB::isError($result)) { echo($result->getMessage()); } $image_src = "data/images/" . $result['image']; if (empty($result['map'])) { if (!empty($result['image'])) { list($width, $height, $type, $attr) = getimagesize($image_src); $map = new ImageMap($width, $height); } else $map = new ImageMap(MAX_IMAGEMAP_WIDTH, MAX_IMAGEMAP_HEIGHT); $mode = 'edit'; } else { $map = @unserialize($result['map']); if ($map === FALSE) { echo "unserialize error. serialized = " . $result['map']; } } //print "(" . print_r($result,true) . ")"; // image $image_src = "data/images/" . $result['image']; $tpl->assign('image_src', $image_src); $tpl->assign('image', $result['image']); $tpl->assign('self', $_SERVER['PHP_SELF']); if (count($map->getRectangles()) == 0) { //$map->addRectangle(new Rectangle(0,0,20,20)); } $tpl->assign('rectangles', $map->getRectangles()); //[0] $tpl->assign('map', $map); /** MODE (edit/browse) */ if ($mode == 'edit') { $tpl->assign('onload', 'onload="init()"'); $tpl->assign('header', $tpl->fetch('edit.header.tpl.php')); $tpl->assign('content', $tpl->fetch('edit.tpl.php')); } else { /* view mode */ $tpl->assign('map_name', $map->getName()); $tpl->assign('map_html', $map->getHTML()); $tpl->assign('onload', ''); $tpl->assign('header', ''); $tpl->assign('content', $tpl->fetch('view.tpl.php')); } /** display page */ $tpl->display("index.tpl.php"); /** done */ ?>