MapTools.org

[Chameleon] LegendTemplate Widget

Rene Teniere TENIERER@gov.ns.ca
Mon, 12 Jan 2004 11:53:24 -0400
Paul,

Well... Here goes, did a little digging and this is what I came up
with. You can be the judge of the results:

    function InitDefaults()
    {
        if (isset($this->maParams["EMBEDDED"]) &&
            strcasecmp(trim($this->maParams["EMBEDDED"]), "FALSE") ==
0)
        {
            $this->moTextButton = new CWCTextButton($this);
            $this->moPopup = new CWCPopup($this);
            $this->moPopup->mszLink =
"widgets/LegendTemplatePopup.phtml";
            $this->moTextButton->InitDefaults();
            echo 'step1 ';
        }
        
        if (isset($this->maParams["TEMPLATE"]))
        {
            echo 'step2 ';
            $this->mszTemplate = trim($this->maParams["TEMPLATE"]);
            print($this->maParams["TEMPLATE"]);
            //TEMPLATE is relative to the application template, not the
map file :)
            print($this->mszTemplate);
            if (strcmp(substr($this->mszTemplate, 0, 1), "/") ||
                strcmp(substr($this->mszTemplate, 1, 1), ":") ||
                strcmp(substr($this->mszTemplate, 0, 1), "\\") )
            {
                $oChameleon = GetChameleonApplication();
            	$szTemplatePath =
dirname($oChameleon->mszTemplateName);
                $this->mszTemplate =
realpath($szTemplatePath."/".$this->mszTemplate);
                echo ' not HTTP:// ';
                print($this->mszTemplate);
            }
            if (strtoupper(substr($this->mszTemplate, 0, 7)) ==
"http://")
            {
                echo 'step3 ';
                $aszFile = file($this->mszTemplate);
                $szTmpName = tempnam($_SESSION['gszTmpPath'],
"legendtemplate").".html";
                $fh = fopen($szTmpName, "w");
                $nbLine = count($aszFile);

                for($i=0; $i<$nbLine; $i++)
                {
                    fwrite($fh, $aszFile[$i]);
                }
                fclose($fh);

                $this->mszTemplate = $szTmpName;
                print($this->mszTemplate);
            }
        }
    }

Here is the output:

step1
step2
c:/chameleon11a/websites/template/legend_template.html
c:/chameleon11a/websites/template/legend_template.html
not HTTP://

Also, here is another error message:
PHP Notice: Use of undefined constant ERR_ERROR - assumed 'ERR_ERROR'
in c:\chameleon11a\htdocs\widgets\LegendTemplate.widget.php on line 372

P.S. I know the template is pointed into the right direction because
when I put 'c:/chameleon11a/websites/template/legend_template.html' into
my web browser, it will show up.

Rene

>>> pagameba@magma.ca 2004-01-12 10:05:53 AM >>>
Rene,

for some reason, it is not finding your template but I can't figure out

why not.  You can try setting the template as an HTTP:// reference, the

code also handles that.  You can also try adding 'embedded="false"' to

the widget, which will make the legend appear in a popup when you click

the text button.  That does mean that you will need to provide some 
additional parameters for the popup and textbutton though.

Unfortunately, it seems to work fine here.  Are you willing to dig into

the code a little bit?  If yes, the you can edit the 
LegendTemplate.widget.php file in the InitDefaults function and place 
some echo statements at various places to see which code is executing,

ie echo 'step 1'; echo 'step 2'; and so on.

The basic purpose of this is to find out where the code ends up setting

the variable  $this->mszTemplate to an empty string (or fails to set it

to the correct value).

Cheers,

Paul

Rene Teniere wrote:

> Hi All,
> 
> Can't seem to be able to get the LegendTemplate Widget to work.
> ErrorReport says that no legend template is specified, even though
it
> is. The template is a standard MapServer legend template format, and
I
> have used several different ones, as well as
> legend_template_widget.html. I have also tried removing the template
> reference in the mapfile with no results. Anyone know what's up with
> this? I've been working on this for two days and am starting to pull
my
> hair out.
> 
> Rene
> 
> <cwc2 type="legendtemplate" visible="true" enabled="true"
>
template="C:/chameleon11a/websites/template/legend_template_chameleon.html"/>
> 
> 
> Rene J.R. Teniere - BSc., D.GIS
> GIS Technician
> Nova Scotia Department of Natural Resources
> Forestry Division (GIS) - Truro
> 
> Phone: (902) 893-5655
> Mobile: (902) 209-8956
> _______________________________________________
> Chameleon mailing list
> Chameleon@lists.maptools.org 
> http://lists.maptools.org/mailman/listinfo/chameleon 
> 

-- 
  -----------------------------------------------------------------
|Paul Spencer                           spencer@dmsolutions.ca    |
|-----------------------------------------------------------------|
|Applications & Software Development                              |
|DM Solutions Group Inc                 http://www.dmsolutions.ca/| 
  -----------------------------------------------------------------

_______________________________________________
Chameleon mailing list
Chameleon@lists.maptools.org 
http://lists.maptools.org/mailman/listinfo/chameleon


This archive was generated by Pipermail.