[ka-Map-dev] [Bug 1303] New: variable substitution

bugzilla-daemon at bugzilla.maptools.org bugzilla-daemon at bugzilla.maptools.org
Fri Feb 24 19:45:56 EST 2006


http://bugzilla.maptools.org/show_bug.cgi?id=1303

           Summary: variable substitution
           Product: ka-Map
           Version: 0.3
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: core
        AssignedTo: ka-map-dev at lists.maptools.org
        ReportedBy: tim at commenspace.org


If ka-Map handled variable substitution similar to MapServer CGI, there would be
less of a need for people to customize the "core" - especially for including
dynamic data.  This would require a solutions to bug #1290 as well.

I'm thinking that something like the following in tile.php (just before
$oMap->draw()) would do the trick [Note that this is untested code].  In
addition, all calls to tile.php would have to have additional variables added to
the query string.

        /* Variable substitution
         * Looks through the mapfile for any pattern like %variable%
         * and then replaces that with the value of $_REQUEST['variable'].
         * Works for layer->data, layer->connection, layer->filter, and
         * for class->expression.  If %variable% exists in a layer but not
         * in the request, then the layer is turned off before drawing.
         */
        for($i = 0; $i < $nLayers; ++$i) {
            $oLayer = $oMap->getLayer($i);
            if($oLayer->status != MS_OFF) {
                $data = $oLayer->data;
                if(preg_match_all("/%(\w+)%/", $data, $matches, PREG_SET_ORDER)
> 0) {
                    foreach($matches as $match) {
                        $key = $match[1];
                        if(isset($_REQUEST[$key])) {
                            $oLayer->set("data", str_replace($match[0],
$_REQUEST[$key], $data));
                        } else {
                            $oLayer->set("status", MS_OFF);
                        }
                    }
                }
                $connection = $oLayer->connection;
                if(preg_match_all("/%(\w+)%/", $connection, $matches,
PREG_SET_ORDER) > 0) {
                    foreach($matches as $match) {
                        $key = $match[1];
                        if(isset($_REQUEST[$key])) {
                            $oLayer->set("connection", str_replace($match[0],
$_REQUEST[$key], $connection));
                        } else {
                            $oLayer->set("status", MS_OFF);
                        }
                    }
                }
                $filter = $oLayer->getFilter();
                if(preg_match_all("/%(\w+)%/", $filter, $matches,
PREG_SET_ORDER) > 0) {
                    foreach($matches as $match) {
                        $key = $match[1];
                        if(isset($_REQUEST[$key])) {
                            $oLayer->setFilter(str_replace($match[0],
$_REQUEST[$key], $filter));
                        } else {
                            $oLayer->set("status", MS_OFF);
                        }
                    }
                }
                for($j = 0; $j < $oLayer->numclasses; ++$j) {
                    $oClass = $oLayer->getClass($j);
                    $expression = $oClass->getExpression();
                    if(preg_match_all("/%(\w+)%/", $expression, $matches,
PREG_SET_ORDER) > 0) {
                        foreach($matches as $match) {
                            $key = $match[1];
                            if(isset($_REQUEST[$key])) {
                                $oLayer->setExpression(str_replace($match[0],
$_REQUEST[$key], $expression));
                            } else {
                                $oLayer->set("status", MS_OFF);
                            }
                        }
                    }
                }
            }
        }



------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.


Please do NOT reply to this email, use the link above instead to 
login to bugzilla and submit your comment. Any email reply to this
address will be lost.


More information about the ka-Map-dev mailing list