Location: PHPKode > scripts > Mapper > mapper/mapper.php
<?PHP
// Mapper V. 0.2.0 21 aprile 2013 PHP 5 compatible IE 9 compatible
// free to use but no warranties
// El Condor - Condor Informatique - Turin
function insertCircle($color="red",$width=10,$shape="circle") {
    global $scriptImg;
    if (preg_match('/.+(\.png|\.gif|\.jpg|\.bmp)$/i',$shape,$mtc)) return "src='".str_replace("\\","/",$shape)."'";
    return "src='$scriptImg?w=$width&c=$color&s=$shape'";
}
function createMap($parms,$handle=false) {
    global $scriptImg;
    // I hope it can works on JOOMLA!
    $GLOBALS['scriptImg'] = (defined('_JEXEC'))? JURI::root(true)."/mapper/genimg.php":((is_file("mapper/genimg.php")) ? "mapper/genimg.php":"genimg.php");
    $aDefaults = array("color"=>"red","alpha"=>"0.5","shape"=>"circle","width"=>10,"image"=>"world.png","link"=>"$scriptImg","event"=>"");
    $prms = array_merge($aDefaults,array_change_key_case($parms));
    $img = $prms["image"];
    if (!is_file($img)) return "$img isn't a graphic file";
    $wh = getimagesize($img);
    $aStyle = array_intersect_key($prms,$aDefaults);     // array with only parameters for symbols
    $r = "<div style=\"position: relative;width:{$wh[0]}px;height:{$wh[1]}px; background: url($img)\" id='m_imgMap'"
        .(($handle)?"onclick='mapper.getMapPos(event)'":"").">";
    foreach ($prms["points"] as $k=>$p) {
        $p = array_change_key_case($p);
        $p = array_merge($aStyle,$p,((isset($p["type"]))? array_change_key_case($prms[$p["type"]]):array()));
        $ID = "ID".$p["x"]."-".$p["y"];
        $halfW = round($p["width"]/2);
        $style = "opacity:{$p["alpha"]};position:absolute;left:".($p["x"]-$halfW)."px;top:".($p["y"]-$halfW)."px"; 
        // handle events
        $evt = "";
        if ($handle) $evt = "onclick='mapper.handlePoint(event,this)'";         // event for handle point's map
        if (isset($p["anchor"])) {
            $r .= "\n<A href={$p["anchor"]} >";
        } else {
            if (preg_match('/^\s*on.+=\s*\'.+\'\s*/i',$p["event"],$mtc)) $evt = $p["event"];                           // on...='...' 
            elseif (preg_match('/^\s*[A-Za-z_]{1}\w+\(.*\)/',$p["event"],$mtc)) $evt = "onclick='".$p["event"]."'";    // function(...)
            elseif (preg_match('/^\s*[A-Za-z_]{1}\w+/',$p["event"],$mtc)) $evt = "onclick='".$p["event"]."(\"$k\")'";  // function
            if ($evt != "") $style .= ";cursor:pointer";
        }
        $r .= "\n<img ID=$ID style='$style' title='$k' ".((isset($evt))?"$evt ":"");
        $r .= insertCircle($p["color"],$p["width"],$p["shape"]).">";
        if (isset($p["anchor"])) $r .= "</A>";
        if ($handle) $aPoints[$k] = array($p["x"],$p["y"],$ID);      // form for handle points
    }
    if ($handle) $r .= "\n<img ID=ID00clone style='position:absolute;cursor:pointer;visibility:hidden' onclick='mapper.handlePoint(event,this)'"
                    .insertCircle($p["color"],$p["width"],$p["shape"]).">";          // for cloning point
    $r .=  "</div>";
    if ($handle) {
        // for delete or modify point
        $r .=  "\n<div style='position:absolute;margin-top:-50px;visibility:hidden' id='m_handlePoint'><form id='m_form'>";
        $r .=  "<input type=text id='m_namePoint'>";
        $r .=  "<select id='m_listNames' onChange='$(\"m_namePoint\").value=this.options[this.selectedIndex].value'></select>";
        $r .=  "<br><span id='m_placeholder'></span><input type=button value='Delete Point' onClick='mapper.deletePoint()' id='m_btnDeletePoint'>";
        $r .=  "<input type=button value='Save Point' onClick='mapper.updatePoint()'>";
        $r .=  "<input type=button value='Ignore' onClick='mapper.ignoreModify()'>";
        $r .=  "<input type=Reset value='Reset'></form>";
        $r .=  "</div>";
        $r .=  "<input type=button value='See Points' onClick='mapper.listPoints()'>";
        $r .=  "<input type=button value='Restore' onClick='mapper.restorePoints()'>";
        $r .= "\n<script type='text/javascript'>\nmapper.Points = ".json_encode(isset($aPoints)?$aPoints:array(),JSON_NUMERIC_CHECK);
        $r .= "\nmapper.origPoints=(JSON.parse(JSON.stringify(mapper.Points)))\n</script>";
    }
    return $r;
}
?>
Return current item: Mapper