[Cartoweb-users] ExportHtml Always

Alexandre Saunier alexandre.saunier at camptocamp.com
Tue Aug 2 13:22:54 EDT 2005


Fred,

reading this mail and some of your previous ones, it seems that there is 
a problem in your paths but I can't figure out what.

You may indeed fix the problem by replacing $this->getBaseUrl() with 
"http://localhost/cartoweb3/htdocs/" in the PHP code you quoted but I 
would not recommend it since it breaks the compatibility with standard 
CartoWeb3 upstream code. Customization should only be performed within 
projects.

A simple fix would be to:

1. extend the client side of the exportHtml plugin (ClientExportHtml) in 
your project as explained here: 
http://cartoweb.org/doc/xhtml/dev.newplugin.html#dev.newplugin.adapting.extending

2. override the getBaseUrl() method in your extended class as follows :

public function getBaseUrl() {
     return 'http://localhost/cartoweb3/htdocs/';
}

or even something like:

public function getBaseUrl() {
     return $this->getConfig()->cartoclientBaseUrl;
}

Concerning the layers icons, the current exportHtml plugin does not 
support layers icons. I just wrote a little update to add a simplistic 
support for layers that have a valid "icon" parameter set in layers.ini 
(does not work with layerGroups or layerClasses). The fix is available 
in the last CVS version (see http://cartoweb.org/#download).

You may also apply the attached patch ("-" indicates removed lines from 
previous file version and "+", added lines).

I don't know if it can interact with what you suggest in your "icons in 
exportHtml" message
http://lists.maptools.org/pipermail/cartoweb-users/2005-August/000094.html

Alex

Fred Bauer a écrit :
> Ok I make it work.
> In fact I modified a part of the plugin code:
> 
> In this part of the code :
> 
> " $smarty->assign(array('exporthtml_mainmap'  => $this->getBaseUrl()
>                                   . 
> $mapResult->imagesResult->mainmap->path,
>                             'exporthtml_keymap'   => $this->getBaseUrl()
>                                   . $mapResult->imagesResult->keymap->path,
>                             'exporthtml_scalebar' => $this->getBaseUrl()
>                                   . 
> $mapResult->imagesResult->scalebar->path,
>                             'exporthtml_legends' => $legends));
> 
> I replace $this->getBaseUrl() by "http://localhost/cartoweb3/htdocs/". 
> it isn't very fine because the path is not in a variable but it works.
> 
> I have just another question. How can I recover the legend icons. The 
> label is present, but I need the icons too.
> 
> It must be something like label revovering :
> foreach ($mapRequest->layersRequest->layerIds as $layerId) {
>           $layer = $mapInfo->layersInit->getLayerById($layerId);
>           $legends[] = array('label' => $layer->label);
>       }
> 
> a keyword in $layer-> '''icons''''?
> 
> Fred
> 

> 
> From: "Fred Bauer" <kerso68 at hotmail.com>
> To: kerso68 at hotmail.com
> Subject: RE: [Cartoweb-users] export Html
> Date: Mon, 25 Jul 2005 08:57:06 +0200
> 
> Hi,
> 
> Can anybody tell me, if the exportHtml plugin is working or if it exists 
> a problem with it?
> I would know, if it is a problem with the template or with te plugin code.
> 
> I need it, so if sombody can help me !
> 
> Fred
> 
> From: "Fred Bauer" <kerso68 at hotmail.com>
> To: cartoweb-users at lists.maptools.org
> Subject: [Cartoweb-users] export Html
> Date: Mon, 18 Jul 2005 15:12:31 +0200
> 
> Hi,
> I don't soluce the problem, if you can help me !
> 
> When I use the exportHtml plugin. The images don't appear on my page (red
> crosses).
> 
> The images URL are :
> http://10.68.1.16/cartoweb3/r.php?k=g&r=images%2F112045984682058.jpg
> http://10.68.1.16/cartoweb3/r.php?k=g&r=images%2F112045984682059.jpg
> 
> Th URL of the images seems to be right because on the main working page 
> of the site, the url of icons are like this :
> http://10.68.1.16/cartoweb3/htdocs/r.php?k=g&r=icons%2FDDAF14%2FDDAF12%FPPE_class_0.png 
> 
> 
> that means searching the icons in :
> http://10.68.1.16/cartoweb3/www-data/icons/DDAF14/DDAF12/
> 
> So for the images in html export the repertory is :
> http://10.68.1.16/cartoweb3/www-data/images/ .
> The images exist, that means if I write the adresse in the navigator ( 
> http://10.68.1.16/cartoweb3/www-data/images/112045984682058.jpg, for 
> exemple) the image appears.
> 
> The matter must concern the template file. I use the default one.
> 
> Does it work by anyone?
> 
> If somebody can bring me some answers,that would be sympathetic, thanks.
> 
> Fred
> 
> --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------_______________________________________________________________________________ 
> 
> 
> 
> I really don't understand how the mailing-list is working!! Because as 
> you can see, I tryed to use the thread struture by answering my 
> questions, but my messages don't appear in the archive.
> What must I do ?
> 
> Fred

-------------- next part --------------
Index: client/ClientExportHtml.php
===================================================================
RCS file: /var/lib/cvs/projects/cw3/cartoweb3/plugins/exportHtml/client/ClientExportHtml.php,v
retrieving revision 1.13
diff -u -r1.13 ClientExportHtml.php
--- client/ClientExportHtml.php	17 Jun 2005 08:49:44 -0000	1.13
+++ client/ClientExportHtml.php	2 Aug 2005 15:18:08 -0000
@@ -102,13 +102,26 @@
         $smarty = new Smarty_Plugin($this->getCartoclient(), $this);
 
         $mapInfo = $this->cartoclient->getMapInfo();
-        // TODO: Add icons
         
         $legends = array();
         foreach ($mapRequest->layersRequest->layerIds as $layerId) {
             $layer = $mapInfo->layersInit->getLayerById($layerId);
-            $legends[] = array('label' => I18n::gt($layer->label)); 
+        
+            // TODO: Improve icons retrieving (currently very simplified)
+            
+            if (empty($layer->icon)) {
+                $iconUrl = '';
+            } else {
+                $resourceHandler = $this->getCartoclient()->getResourceHandler();
+                $iconUrl = $this->getBaseUrl();
+                $iconUrl .= $resourceHandler->getFinalUrl($layer->icon, false);
+            }
+            
+            $legends[] = array('label' => I18n::gt($layer->label),
+                               'icon'  => $iconUrl,
+                               ); 
         }
+        
         $smarty->assign(array('exporthtml_mainmap'  => $this->getBaseUrl()
                                     . $mapResult->imagesResult->mainmap->path,
                               'exporthtml_keymap'   => $this->getBaseUrl()
Index: templates/export.tpl
===================================================================
RCS file: /var/lib/cvs/projects/cw3/cartoweb3/plugins/exportHtml/templates/export.tpl,v
retrieving revision 1.3
diff -u -r1.3 export.tpl
--- templates/export.tpl	26 Nov 2004 09:22:19 -0000	1.3
+++ templates/export.tpl	2 Aug 2005 15:18:08 -0000
@@ -17,7 +17,7 @@
 <tr>
 <td><table>
 {foreach from=$exporthtml_legends item=legend}
-<tr><td>{$legend.label}</td></tr>
+<tr><td>{if $legend.icon}<img src="{$legend.icon}" alt="" /> {/if}{$legend.label}</td></tr>
 {/foreach}
 </table></td>
 </tr>


More information about the Cartoweb-users mailing list