/**
   * This is the method to execute the demo
   */
  function process() {
    // We always call the parent's method
    parent::process();

    $d = $this->getDocument();
    $values = array('Snoopy', 'Sally', 'Chuck', 'Linus');
    $d->setVariable('values', new IterableArray($values));
  }
  /**
   * This is the method to execute the demo
   */
  function process() {
    // We always call the parent's method
    parent::process();

    $d = $this->getDocument();
    $r = $this->getResponce();
    
    // Here we set the lifetime of the responce to 5 seconds
    $r->setLifeTime(10);
    
    // Some variables for the template
    $d->setVariable('time', time());  // time of the responce creation
  }
 /**
  * Here we prepare several links
  */
 function process() {
   parent::process();
   $d = $this->getDocument();
   
   // The first sample link
   $l = new Location('MyAction', array(
     'one'=>1, 
     'two'=>2,
     'three'=>3));
   $d->setVariable('myLink', $l);
   
   // Ten cloned links
   $l = new Location('ViewProduct', array('productid'=>0));
   for($i = 1; $i != 11; $i++) {
     $l2 = clone $l;
     $l2->setParameter('productid', $i);
     $links[] = $l2;
   }
   $d->setVariable('links', new IterableArray($links));
 }
  function process() {
    parent::process();
    
    if(!$this->available) {
      $this->getDocument()->setVariable('notAvailable', true);
      return;
    }
    
    // Prepare the document
    $r = $this->getResponce();
    $rq = $this->getRequest();
    $d = $this->getDocument();
    $d->setVariable('form', $this->form);
    
    try {
      // If the form was submitted...
      if($this->form->isValidSubmission()) {
        // See if the dialect and collation have been selected
        @list($lc, $dc, $collc) = split('_', $rq->getParameter('dialect'));
      
        // Get the selected country code
        $cc = $this->getRequest()->getParameter('country', 'US') or $cc = null;
      
        // Instantiate the locale
        $l = I18N::getLocale($cc, $lc, $dc);
      
        // See if the time zone has been selected
        if($tz = $this->getRequest()->getParameter('tz')) {
          $l->setTimeZone(I18N::getTimeZone($tz));
        }
      } else {
        // the form has not been submitted, get the default locale
        $l = I18N::getLocale();
        $collc = 'Default';
      }
      
      $this->dialect = $l->getDialect();
      $this->collation = $this->dialect->getCollation($collc ? $collc :  'Default');
      $this->caseSensitive = $rq->getParameter('caseSensitive');
      
      // Load the message dictionary
      $mf = new I18NMessageFile($this->getPackage()->getResourcePath('messages'));
      
      // Collate some words in the selected dialect and coolation
      $coll = explode(',', $mf->translateMessage('words', $this->dialect->getLanguage()->getCode()));
      usort($coll, array($this, 'langSort'));
      $d->setVariable('coll', (join(', ', $coll)));
    } catch(I18NException $e) {
      // Smth went wrong
      $d->setVariable('error', $e->getMessage());
      $l = I18N::getLocale();
      $collc = 'Default';
    }
    
    $d->setLocale($l);
    
    // Set some info
    $c = $l->getCountry();
    $d->setVariable('cc', $c->getCode());
    $d->setVariable('cn', $c->getName());
    $d->setVariable('cdc', $c->getDialCode());
    $d->setVariable('ccc', $l->getCurrencyCode());
    $d->setVariable('ccs', $l->getCurrencySymbol());
    $dial = $l->getDialect();
    $d->setVariable('lc', $dial->getLanguage()->getCode());
    $d->setVariable('dc', $dial->getCode());
    $d->setVariable('dn', $dial->getName());    
    $col = $l->getDialect()->getCollation($collc ? $collc :  'Default');
    $d->setVariable('collc', $col->getCode());
    $d->setVariable('colln', $col->getName());
    $tz = $l->getTimeZone();
    $d->setVariable('tzl', join(', ', $tz->getLocations()));
    $d->setVariable('tzo', $tz->formatOffset($tz->getUTCOffset()));
    $d->setVariable('tza', $tz->getStandardAbbrev());
    $d->setVariable('tzco', $tz->formatOffset($tz->getCurrentOffset()));
    $d->setVariable('tzca', $tz->getCurrentAbbrev());
    $d->setVariable('tzt', $tz->isDSTEnabled() ? 'yes' : 'no');
    $d->setVariable('tzs', $tz->isSummerTime() ? 'yes' : 'no');

    $l->setMessageDictionary($mf);
  }