Ejemplo n.º 1
0
 public function process()
 {
     $id = $this->_context->getParam('datagrid-id');
     $mode = $this->_context->getParam('datagrid-mode');
     /**
      * @todo  Réfléchir à l'opportunité d'implémenter État pour gérer ces if
      */
     if (is_null($mode) || 'read' == $mode || $id != $this->getModel()->getId()) {
         $this->setView(new DataGridReadView($this->getModel()));
     } else {
         if ('processInput' == $mode) {
             System::export($this->_context);
         }
         $view = new DataGridEditView($this->getModel());
         $view->setController($this);
         $this->setView($view);
     }
 }
if (is_null($caddy)) {
    $caddy =& new Caddy();
}
System::export($s->getDateUpdate(), '-- Last update time --');
$t =& new CaddyItem('AZERTY', 1, 0);
$caddy->removeCaddyItem($t);
$s->save();
$db->dispose();
System::export('-- saving to caddies.xml --');
System::import('System.DataSource.XmlDataSource');
System::import('System.Caddy.Storage.CaddyXmlBlobStorage');
$xml =& new XmlDataSource(DataSourceDriver::createNew('xml://caddies.xml/'));
$s =& new CaddyXmlBlobStorage($xml, $caddy);
$xml->connect();
System::export($s->save($caddyId));
$caddy =& $s->loadById($caddyId);
if (is_null($caddy)) {
    $caddy =& new Caddy();
}
$xml->dispose();
System::export($caddy->size(), '-- caddy\' size --');
System::export('-- iterate items --');
$iterator =& $caddy->getIterator();
while ($iterator->hasNext()) {
    $caddyItem =& $iterator->next();
    System::export($caddyItem, 'élément n°' . $iterator->key());
    $featIterator =& $caddyItem->getIterator();
    while ($featIterator->hasNext()) {
        System::export($featIterator->next(), 'feat n°' . $featIterator->key());
    }
}
Ejemplo n.º 3
0
<?php

/**
 * @author        Jimmy CHARLEBOIS
 * @date          19-02-2007
 * @brief         Exemple d'utilisation de l'ADT SortedSet
 */
require_once 'c.system.php';
System::import('System.ADT.TreeSet');
System::import('System.ADT.Scalar.Number');
System::import('System.Comparators.NumberComparator');
$tmp = array(30, 3, 0, 10, 6, 12, 8);
$s =& new TreeSet(new NumberComparator());
foreach ($tmp as $idx => $value) {
    $s->add(new Number($value));
}
System::export((string) $s, 'TreeSet');
System::export($s->first(), '-- first --');
System::export($s->last(), '-- last --');
/*
  System::export( '-- iterate --' );
  $iterator =& $s->getIterator();
  while( $iterator->hasNext() )
    System::export( $iterator->next() );
*/
Ejemplo n.º 4
0
$q->enqueue('a');
$q->enqueue('b');
$q->enqueue('c');
System::export((string) $q, 'Queue');
System::export('-- dequeue --');
$q->dequeue();
System::export((string) $q, 'Queue');
System::export('-- adding d --');
$q->enqueue('d');
System::export((string) $q, 'Queue');
System::export('-- peek --');
$element = $q->peek();
System::export($element);
System::export((string) $q, 'Queue');
System::export('-- poll --');
$element = $q->poll();
System::export($element);
System::export((string) $q, 'Queue');
System::export('-- clear --');
$q->clear();
System::export((string) $q, 'Queue');
System::export('-- adding a, b, c, d --');
$q->enqueue('a');
$q->enqueue('b');
$q->enqueue('c');
$q->enqueue('d');
System::export('-- iterate -- ');
$iterator = $q->getIterator();
while ($iterator->hasNext()) {
    System::export($iterator->next(), 'élément n°' . $iterator->key());
}
    if (array_key_exists('configuration', $struct)) {
        ${$name}->setConfiguration($struct['configuration']);
    }
}
/*
  System::export(
    StoreObject::restore(
      'a:2:{s:5:"class";s:9:"TextField";s:5:"props";a:5:{s:4:"name";s:8:"nom_copy";s:4:"type";s:4:"text";s:5:"value";N;s:13:"default_value";s:7:"Abraham";s:13:"configuration";s:200:"a:2:{s:5:"class";s:22:"FormInputConfiguration";s:5:"props";a:1:{s:5:"items";a:1:{s:6:"length";s:95:"a:2:{s:5:"class";s:28:"FormInputLengthConfiguration";s:5:"props";a:1:{s:10:"max_length";i:10;}}";}}}";}}'
    ),
    'restore TextField'
  );
*/
if (FormInput::hasUserInput()) {
    System::export('Des données ont été soumises');
    foreach ($inputs as $name => $struct) {
        System::export(${$name}->getValue(), $name);
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Chargeur d'éléments de formulaire</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="StyleSheet" type="text/css" href="forminput.css" />
</head>
<body>
<form id="my_form" action="<?php 
echo $context->getParam('PHP_SELF');
?>
" method="post">
Ejemplo n.º 6
0
<?php

/**
 * @author        Jimmy CHARLEBOIS
 * @date          21-02-2007
 * @brief         Exemple d'utilisation des collections typées
 */
require 'c.system.php';
System::import('System.ADT.Scalar.String');
System::import('System.ADT.Queue');
System::import('System.ADT.TypedQueue');
System::import('System.ADT.Stack');
System::import('System.ADT.TypedStack');
$q =& new TypedQueue('String', new Queue());
$q->enqueue(new String('hello'));
$q->enqueue(new String('world'));
$q->enqueue(new String(1));
System::export((string) $q, 'TypedQueue');
$s =& new TypedStack('String', new Stack());
$s->push(new String('hello'));
$s->push(new String('world'));
$s->push(new String(1));
System::export((string) $s, 'TypedStack');
Ejemplo n.º 7
0
System::import('System.Comparators.StringComparator');
System::import('System.ADT.Scalar.Date');
System::import('System.Comparators.DateComparator');
System::export('-- Boolean --');
$b1 =& new Boolean(true);
$b2 =& new Boolean(0);
System::export((string) $b1, 'b1');
System::export((string) $b2, 'b2');
$comparator =& new BooleanComparator();
System::export($comparator->compare($b1, $b2), '-- compare b1 & b2 --');
System::export($comparator->compare($b2, $b1), '-- compare b2 & b1 --');
System::export('-- String --');
$s1 =& new String('a');
$s2 =& new String('A');
$s3 =& new String('B');
System::export((string) $s1, 's1');
System::export((string) $s2, 's2');
System::export((string) $s3, 's3');
$comparator =& new StringComparator();
System::export($comparator->compare($s1, $s2), '-- compare s1 & s2 --');
System::export($comparator->compare($s2, $s3), '-- compare s2 & s3 --');
System::export($comparator->compare($s1, $s3), '-- compare s1 & s3 --');
System::export('-- Date --');
$d1 =& new Date(2007, 2, 1);
$d2 =& new Date(2007, 1, 10);
System::export((string) $d1, 'd1');
System::export((string) $d2, 'd2');
$comparator =& new DateComparator();
System::export($comparator->compare($d1, $d2), '-- compare d1 & d2 --');
System::export($comparator->compare($d2, $d1), '-- compare d2 & d1 --');
Ejemplo n.º 8
0
<?php

/**
 * @author        Jimmy CHARLEBOIS
 * @date          11-04-2007
 * @brief         Exemple d'utilisation des cookies
 */
require_once 'c.system.php';
System::import('System.Context.HttpContext');
System::import('System.Session.CookieSession');
$context =& new HttpContext();
if ($context->hasParam('delete')) {
    System::export('-- Delete cookie --');
    System::export(CookieSession::delete('ValeurDeTest'));
}
//  Même s'il implémente l'interface ISession, on ne démarre pas CookieSession -> UnsupportedOperationException
//CookieSession::start();
System::export('-- Retrieve cookie value --');
$test_value = CookieSession::get('ValeurDeTest');
System::export($test_value);
System::export('-- Storing cookie value --');
System::export(CookieSession::set('ValeurDeTest', 'ma valeur qui va bien'));
echo '<a href="?delete=1">delete cookie</a>';
Ejemplo n.º 9
0
$m->put('a', 'Hello');
$m->put('b', 'World');
$m->put('c', 123);
System::export((string) $m, 'Hashtable');
System::export('-- contains key c --');
System::export($m->containsKey('c'));
System::export('-- contains value World --');
System::export($m->containsValue('World'));
System::export('-- removing b --');
$m->remove('b');
System::export((string) $m, 'Hashtable');
System::export('-- contains value World --');
System::export($m->containsValue('World'));
System::export('-- creating Map 2 --');
$m2 =& new Hashtable();
$m2->put(1, 'Tic');
$m2->put('middle', 'Tac');
$m2->put('final', 'Toe');
System::export((string) $m2, 'Hashtable 2');
System::export('-- coping Map 2 elements to Map 1 --');
$m->putAll($m2);
System::export((string) $m, 'Hashtable');
System::export('-- clear Map 2 --');
$m2->clear();
System::export((string) $m2, 'Hashtable 2');
System::export('-- iterate -- ');
$iterator = $m->getIterator();
while ($iterator->hasNext()) {
    $entry =& $iterator->next();
    System::export('key: ' . $entry->getKey() . System::crlf . 'value: ' . (string) $entry->getValue(), 'élément n°' . $iterator->key());
}