Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?PHP
- // Gaia Sig Mapper
- // Regions are Defined By Rect Normally
- // Jakobo @ Gaia Online
- // Class Definition
- // This is responsible for the definition of coordinates
- class imageMap {
- var $locale;
- var $defaultURL;
- var $size;
- function imageMap() {
- // makes locale ready for data
- $this->locale = array();
- $this->size = 0;
- }
- function setDefaultURL($inUrl) {
- $this->defaultURL = $inUrl;
- }
- function addToMap($Region) {
- $this->locale[$this->size] = $Region;
- $this->size++;
- }
- function testMap($inX, $inY) {
- foreach($this->locale as $Region) {
- $Region->goIfInside($inX, $inY);
- }
- // we didn't go anywhere, load the default
- header("Location: " . $this->defaultURL);
- }
- }
- class Region {
- var $type; // type of region
- var $url; // url of region
- function Region() {
- // empty constructor
- }
- }
- class Rect extends Region {
- var $x1,
- $y1,
- $x2,
- $y2;
- function Rect($inX1, $inY1, $inX2, $inY2, $inUrl) {
- $this->x1 = $inX1;
- $this->y1 = $inY1;
- $this->x2 = $inX2;
- $this->y2 = $inY2;
- $this->url = $inUrl;
- $this->type = "rect";
- }
- function isInside($clickedX = -1, $clickedY = -1) {
- // if X and Y are not set, -1 is used
- // placing it outside of the image map
- if(($clickedX >= $this->x1 && $clickedX <= $this->x2) && ($clickedY >= $this->y1 && $clickedY <= $this->y2) ) {
- return true;
- }
- else {
- return false;
- }
- }
- function goIfInside($clickedX = -1, $clickedY = -1) {
- // goes to object's URL if inside
- if($this->isInside($clickedX, $clickedY)) {
- header("Location: " . $this->url);
- exit;
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement