width = $width; $this->height = $height; $this->listOfRectangles = array(); $this->name = "wikimap"; /* default name. We should be able to change it in order to have more than one WikiImage in one page */ } function addRectangle(&$rect) { $this->listOfRectangles[] =& $rect; } function getRectangles() { return $this->listOfRectangles; } function serialize() { return serialize($this); } function unserialize($str) { return unserialize($str); } /* rect: left-x, top-y, right-x, bottom-y. */ function getHTML() { /* using PHP output buffering... */ $divs = ""; $index=0; foreach ($this->listOfRectangles as $rect) { $leftx = $rect->getX(); $topy = $rect->getY(); $rightx = $rect->getX() + $rect->getWidth(); $bottomy = $rect->getY() + $rect->getHeight(); /* visible link */ $divs .= "\n\tgetX()."px;top:".$rect->getY()."px;width:".$rect->getWidth()."px;height:".$rect->getHeight()."px;position:absolute;\" alt=\"".$rect->getTitle()."\" title=\"".$rect->getTitle()."\" href=\"".$rect->getLink()."\" class=\"visiblearealink\">\n\t"; $index++; } return $divs; /** for now, we have two links instead of simply one : one image map, and a CSS div... */ } /* usage : name; } } ?>