[Cartoweb-users] sessionable plugin

giuseppe.derossi at email.it giuseppe.derossi at email.it
Mon Mar 27 09:26:19 EST 2006


Hi,
I'm trying to set my plugin sessionable in order to store the results. 
A long story short, I write a string as input for my plugin, the plugin
looks
for some data and display them in a box. The results are a set of
coordinates and are displayed as clickble links, now if I click on one of
them I get the map to be recentered and some info to be displayed, but at
this point I miss the previous
results and the folder is changed to the default, so I should to click on my
folder plugin and reinsert the input string. 

I'm studying the Query Plugin and maybe it's so good but I don't know how to
plug in my query results, by now, I'm adding the sessionable-logic into my
plugin : in my first attempt I get no results, I send the logic in a
simplified php language:


// my data structure to be stored
class ResultFromDataBase {    
    public $CoordinatesFromDataBase = array();
}

// my plugin main class
class ClientRicercaPar extends ClientPlugin implements Sessionable,
GuiProvider, FilterProvider {

    protected $ResultFromDataBase;    

// implementation of sessionable interface
public function createSession(MapInfo $mapInfo, 
                                  InitialMapState $initialMapState) {
         
        $this->ResultFromDataBase = new ResultFromDataBase();
        $this->clearSession();       
        return;
    }
public function saveSession() {
    
        if (!$this->getConfig()->persistentQueries) {
        
            // Do not store selections
            $this->ResultFromDataBase->CoordinatesFromDataBase = array(); 
        }

        return $this->ResultFromDataBase;
    }  
public function loadSession($sessionObject) {
        $this->ResultFromDataBase = $sessionObject;
    }
protected function clearSession() {
        $this->ResultFromDataBase->CoordinatesFromDataBase = array();
    }

// implementation of filter interface

public function filterPostRequest(FilterRequestModifier $request) {
        
    	  $first_input = $request->getValue('first_input');
          $second_input_from_ResultFromDataBase =
$request->getValue('second_input_from_ResultFromDataBase');

    	  if (!empty($first_input)) {
             $ResultFromDataBase = $this->makeSearch($first_input)
          } 
            
          if (!empty($second_input_from_ResultFromDataBase)){
             $request->setValue('recenter_x', $second_input_x);
             $request->setValue('recenter_y', $second_input_y);
          }            
    }

public function renderForm(Smarty $template) {
    	$template->assign('ricercaPar', $this->drawUserForm());
    }

    protected function drawUserForm() {
      $smarty = new Smarty_Plugin($this->getCartoclient(), $this);    
      $smarty->assign('first_input', $this->first_input );
      $smarty->assign('ResultFromDataBase', $this->ResultFromDataBase );  
      return $smarty->fetch('myPlugin.tpl');
    }

// my method for gathering data
protected function makeSearch($searchString) {
      // query on DB
      return ResultFromDataBase
            
    }
}

Can anybody give me a piece of advice ? In order to get my results is
modifying the query-plugin easier ?

Tnk in advantage.




 
 --
 Email.it, the professional e-mail, gratis per te: http://www.email.it/f
 
 Sponsor:
 Volo Amsterdam A/R con Opodo a partire da 171€ tutto incluso! 
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=4937&d=20060327
 
 --
 Email.it, the professional e-mail, gratis per te: http://www.email.it/f
 
 Sponsor:
 DA NON PERDERE: Prova gratis per 15 giorni DVDNet Rent e ricevi a casa tua
i migliori film!

 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=4633&d=20060327




More information about the Cartoweb-users mailing list