[Cartoweb-users] several shortcuts..

Valerio Noti valerionoti at yahoo.it
Thu Jan 26 14:16:59 EST 2006


Thank you very much Oliver,
I'll try your suggestions for new plugin.
As another way for solving this problem do you think possible one of these 
solutions ?

1)
I save several views with view plugin and I call cartoweb project with a 
combo box changing the url with javascript

2)
is it possible to run via url a cartoweb project directly with coordinates 
values?
 (i.e. .../htdocs/italy.php?bbox=x1,y1,x2,y2)
This would be the best solutions for me....

Thanks again

Valerio



----- Original Message ----- 
From: "oliver.christen" <oliver.christen at camptocamp.com>
To: "Valerio Noti" <valerionoti at yahoo.it>; 
<cartoweb-users at lists.maptools.org>
Sent: Thursday, January 26, 2006 7:55 PM
Subject: Re: [Cartoweb-users] several shortcuts..


>I forgot to say:
>
> the filename of the php file depend of the name of the plugin, hence the 
> class you want to use. I my exemple, the class was 
> 'ClientMyProjectLocation', the plugin name will be 'myProjectLocation', 
> and the filename will be 'ClientMyProjectLocation.php'
> Create a folder named 'myProjectLocation' in the coreplugin folder OF YOUR 
> PROJECT ( not in the main coreplugin folder of cartoweb)(in coreplugin 
> because you extend 'location' which is a coreplugin). In that folder, 
> create a folder named 'client', put the 'ClientMyProjectLocation.php' 
> inside.
>
> Let me know if that was usefull to you.
>
> Regards,
> Oliver
>
>> Hi Valerio,
>>
>> you cant do that directly in the location plugin, but it is quite easy to 
>> extend that plugin to do what you want.
>>
>> basically, you create a new plugin, lets call it MyProjectLocation
>>
>> the template would look like this:
>>
>>
>> <?php
>> /**
>> * @package CorePlugins
>> * @version $Id: ClientMyProjectLocation.php,v 1.8 2005/02/23 11:52:43 
>> Exp $
>> */
>>
>> class ClientMyProjectLocation extends ClientLocation {
>>
>>    public function replacePlugin() {
>>        return 'location';
>>    }
>>
>>    // here redefine the function you need, most probably drawShortcuts() 
>> /**     * Draws shortcuts form     * @return string     */    protected 
>> function drawShortcuts() {        $this->smarty = new 
>> Smarty_Plugin($this->getCartoclient(), $this);        $shortcutValues = 
>> array(-1);        $shortcutLabels = array('');        $shortcuts = 
>> $this->shortcuts;        if (!is_array($shortcuts)) $shortcuts = array(); 
>> /* do what you want with the array containing the shortcuts, list 
>> spliting, sorting, etc....             below is the original function 
>> code, allowing to treat the shortcuts values and labels */        foreach 
>> ($shortcuts as $key => $shortcut) {            $shortcutValues[] = $key; 
>> $shortcutLabels[] = I18n::gt($shortcut->label);                    } /* 
>> now let say you cuted your shortcuts in 3 arrays (hence 3 for values and 
>> 3 for labels),         you assign them to your template vis smarty */ /* 
>> below the original code */ $this->smarty->assign(array('shortcut_values' 
>> => $shortcutValues, 'shortcut_labels' => $shortcutLabels));        /* you 
>> would have to do something like this */ 
>> $this->smarty->assign(array('shortcut_values_1' => $shortcutValues_1, 
>> 'shortcut_labels_1' => $shortcutLabels_1, 'shortcut_values_2' => 
>> $shortcutValues_2, 'shortcut_labels_2' => $shortcutLabels_2, 
>> 'shortcut_values_3' => $shortcutValues_3, 'shortcut_labels_3' => 
>> $shortcutLabels_3));        return 
>>  >smarty->fetch('shortcuts.tpl');    }    /* you will also have to 
>> redefine the function handleShortcuts, because only one input (select) 
>> can have one id,     so you need to tell the plugin to treat the value 
>> returned by these inputs too */    protected function 
>> handleShortcuts($request, $useDoit = true, $check = false) {        if 
>> (isset($this->getHttpValue($request, 'shortcut_id')) { 
>> $shortcut_id  = isset($this->getHttpValue($request, 
>> ut_id');        } else if (isset($this->getHttpValue($request, 
>> 'shortcut_id1')){ $shortcut_id  = isset($this->getHttpValue($request, 
>> ut_id1');        } else if (isset($this->getHttpValue($request, 
>> 'shortcut_id2')){ $shortcut_id  = isset($this->getHttpValue($request, 
>> ut_id2');        } else if (isset($this->getHttpValue($request, 
>> 'shortcut_id3')){            $shortcut_id  = 
>> isset($this->getHttpValue($request, 'shortcut_id3');        } 
>> $shortcutDoit = $this->getHttpValue($request, 'shortcut_doit'); if 
>> (is_null($shortcut_id) || ($shortcutDoit != '1' && $useDoit)) 
>> {            return NULL;        }                if ($check) { if 
>> (!$this->checkInt($shortcut_id, 'shortcut_id'))                return 
>> NULL;                            if (!array_key_exists($shortcut_id, 
>> $this->shortcuts)) { $this->cartoclient->addMessage('Shortcut ID not 
>> found'); return NULL;            }        } $bboxRequest = new 
>> BboxLocationRequest();        $bboxRequest->bbox = 
>> $this->shortcuts[$request['shortcut_id']]->bbox;        $locationRequest 
>> = new LocationRequest(); $locationRequest->locationType = 
>> LocationRequest::LOC_REQ_BBOX; $locationRequest->bboxLocationRequest = 
>> $bboxRequest; return $locationRequest;            }}?>
>>
>> and in your shortcuts.tpl simply put the smarty variable 
>> $shortcut_values_1
>> $shortcut_labels_1 $shortcut_values_2 $shortcut_labels_2 
>> $shortcut_values_3
>> $shortcut_labels_3 as needed
>>
>> <select name="shortcut_id1" id="shortcut_id1"
>> onchange="javascript:document.carto_form.shortcut_doit.value=1;FormItemSelected();">
>> {html_options values=$shortcut_values_1 output=$shortcut_labels_1}
>> </select>
>> <select name="shortcut_id2" id="shortcut_id2"
>> onchange="javascript:document.carto_form.shortcut_doit.value=1;FormItemSelected();">
>> {html_options values=$shortcut_values_2 output=$shortcut_labels_2}
>> </select>
>> <select name="shortcut_id3" id="shortcut_id3"
>> onchange="javascript:document.carto_form.shortcut_doit.value=1;FormItemSelected();">
>> {html_options values=$shortcut_values_3 output=$shortcut_labels_3}
>> </select>
>>
>> Finally, dont forget tp load your new plugin. In the file 
>> client_conf/client.ini add it to the loadPlugins list
>>
>> That should cover most of it.
>>
>> All references are there:
>> http://www.cartoweb.org/doc_head/docbook/xhtml/dev.newplugin.html#dev.newplugin.adapting.extending
>>
>> Regards,
>>
>> Oliver Christen
>> Camptocamp SA
>>
>>> Hi,
>>> is it possible to split shortcuts in two or more combo boxes (i.e. tows 
>>> shortcuts and lakes shortcuts)?
>>> Do I have to modify php files or can I configure this in location.ini or 
>>> similar?
>>>
>>>
>>> Thanks
>>>
>>> Valerio
>>> _______________________________________________
>>> Cartoweb-users mailing list
>>> Cartoweb-users at lists.maptools.org
>>> http://lists.maptools.org/mailman/listinfo/cartoweb-users
>>>
>>
>> _______________________________________________
>> Cartoweb-users mailing list
>> Cartoweb-users at lists.maptools.org
>> http://lists.maptools.org/mailman/listinfo/cartoweb-users
>>
> 



More information about the Cartoweb-users mailing list