Beispiel #1
0
 /**
  * @brief   Retourne une collection des paramètres du contexte
  * @return  Hashtable
  */
 public function &getParams()
 {
     System::import('System.ADT.Hashtable');
     $rv =& new Hashtable();
     foreach ($this->_params as $key => $value) {
         $rv->put($key, $this->_params[$key]);
     }
     return $rv;
 }
 /**
  * @brief   Instancie la classe concrête adéquate pour le driver fournit
  * @param   $driver   IDataSourceDriver   driver de connexion
  * @return  DbmsDataSource
  */
 private static function createNew(IDataSourceDriver &$driver)
 {
     $rv = null;
     if ('mysql' == $driver->getScheme()) {
         System::import('System.DataSource.Dbms.DbmsMysql');
         $rv =& new DbmsMysql($driver);
     } else {
         throw new Exception('Unsupported dbms driver scheme');
     }
     return $rv;
 }
 /**
  * @brief   Instancie et retourne un �l�ment de formulaire
  * @param   $enum_const   const     \ref FormInputType
  * @param   $input_name   string    Nom de l'�l�ment
  * @return  FormInput
  * @throw   Exception
  */
 public static function createNew($enum_const, $input_name)
 {
     $rv = null;
     if (FormInputEnumeration::TYPE_TEXT == $enum_const) {
         System::import('System.FormInput.Inputs.TextField');
         $rv =& new TextField($input_name);
     } elseif (FormInputEnumeration::TYPE_CHECKBOX == $enum_const) {
         System::import('System.FormInput.Inputs.Checkbox');
         $rv =& new Checkbox($input_name);
     }
     if (!is_null($rv)) {
         FormInput::registerItem($rv);
     }
     return $rv;
 }
 /**
  * @brief   Instancie la classe concrête correspondante à la signature de driver fournie
  * @param   $driverSignature   string   signature du driver
  * @return  DataGridSource
  * @throw   Exception
  */
 public final function &createNew($driverSignature)
 {
     $rv = null;
     $dgDriver =& DataSourceDriver::createNew($driverSignature);
     if ('xml' == $dgDriver->getScheme()) {
         System::import('System.DataGrid.DataSources.XmlDataGridSource');
         $rv =& new XmlDataGridSource($dgDriver);
         /**
          * @todo    Supprimer ce if = 'mysql' car on devrait pas avoir a connaitre le type de dbms
          *  modification du driver ?
          *  appel à une méthode statique de dbmsdatasource/dbmsdatagridsource ?
          */
     } elseif ('mysql' == $dgDriver->getScheme()) {
         System::import('System.DataGrid.DataSources.DbmsDataGridSource');
         $rv =& new DbmsDataGridSource($dgDriver);
     } else {
         throw new Exception('Unsupported datasource scheme');
     }
     return $rv;
 }
<?php

/**
 * @package       ADT.Iterators
 * @class         AbstractCollectionIterator
 * @author        Jimmy CHARLEBOIS
 * @date          21-02-2007
 * @brief         Classe abstraire pour iterateur de collection
 */
System::import('System.Interfaces.Iteration.IDynamicIterator');
System::import('System.Exceptions.IllegalArgumentException');
abstract class AbstractCollectionIterator implements IDynamicIterator
{
    private $_collection;
    private $_pointeur;
    public function __construct(ICollection &$collection)
    {
        $this->_collection =& $collection;
        $this->_pointeur = -1;
    }
    public function __clone()
    {
        $this->_collection = clone $this->_collection;
        $this->rewind();
    }
    public function rewind()
    {
        $this->_pointeur = -1;
    }
    public function hasNext()
    {
<?php

/**
 * @package       ADT
 * @class         AbstractScalar
 * @author        Jimmy CHARLEBOIS
 * @date          21-02-2007
 * @brief         Classe abstraite pour les objets ADT scalaire
 */
System::import('System.Interfaces.ADT.IADT');
System::import('System.Interfaces.Comparator.IComparable');
abstract class AbstractScalar implements IADT, IComparable
{
    private $_value;
    protected function __construct($value)
    {
        $this->_value = $value;
    }
    public function getValue()
    {
        return $this->_value;
    }
    public function toString()
    {
        return (string) $this;
    }
    public function compareTo(IComparable $o)
    {
        $rv = 0;
        if ($this->getValue() < $o->getValue()) {
            $rv = -1;
Beispiel #7
0
<?php

/**
 * @package     	Table
 * @interface     ITableModel
 * @author      	Jimmy CHARLEBOIS
 * @date        	28-02-2007
 * @brief       	
 */
System::import('System.Interfaces.MVC.IModel');
interface ITableModel extends IModel
{
    //    public function addTableModelListener( ITableListener &$listener );
    //    public function removeTableModelListener( ITableListener &$listener );
    /**
     * @brief   Retourne le nombre de colonne pr�sentes dans le mod�le
     * @return  integer
     */
    public function getColumnCount();
    /**
     * @brief   Retourne le libell� associ�e � une colonne
     * @param   $columnIndex    integer   le num�ro de la colonne
     * @return  string
     */
    public function getColumnName($columnIndex);
    /**
     * @brief   Retourne le nombre de lignes pr�sentes dans le mod�le
     * @return  integer
     */
    public function getRowCount();
    /**
System::export($caddyId, '-- Caddy ID --');
/*
System::export( $s->delete( $caddyId ), '-- Delete caddy --' );
*/
$caddy =& $s->loadById($caddyId);
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());
Beispiel #9
0
<?php

/**
 * @package     	IO
 * @class       	SysFile
 * @author      	Jimmy CHARLEBOIS
 * @date        	24-01-2007
 * @brief       	Manipulation de fichier
 */
System::import('System.Interfaces.IResource');
System::import('System.Exceptions.IOException');
class SysFile implements IResource
{
    private $_filename;
    private $_path;
    private $_extension;
    protected $_filepath;
    protected $_resource;
    /** @defgroup   FileAccessType   Constantes pour définir le type d'accès au log */
    /*@{*/
    /** @brief  Accès en écriture seule (mode écrasement) */
    const WRITE_ACCESS = 1;
    /** @brief  Accès en lecture seule */
    const READ_ACCESS = 2;
    /** @brief  Accès en écriture seule (mode ajout) */
    const APPEND_ACCESS = 4;
    /** @brief  Permet l'écriture de données binaires */
    const BINARY_ACCESS = 8;
    /*@}*/
    public function __construct($filepath)
    {
Beispiel #10
0
<?php

/**
 * @package   	Context
 * @class   		RuntimeContext
 * @author        Jimmy CHARLEBOIS
 * @date          04-12-2006
 * @brief         Décoration de contexte pour contexte d'exécution
 */
System::import('System.Interfaces.Context.IContext');
class RuntimeContext implements IContext
{
    private $_context;
    private $_runtime_vars;
    public function __construct(IContext $context)
    {
        $this->_context =& $context;
        $this->_runtime_vars = array();
    }
    public function __call($methodName, $args)
    {
        if (is_callable(array($this->_context, $methodName))) {
            return call_user_func_array(array($this->_context, $methodName), $args);
        }
    }
    public function &getParams()
    {
        return $this->_context->getParams();
    }
    public function hasParam($key)
    {
Beispiel #11
0
<?php

/**
 * @package       Form
 * @class         FormChecker
 * @author        Jimmy CHARLEBOIS
 * @date          13-06-2006
 * @brief         Représentation d'un formulaire à vérifier
 */
System::import('System.Interfaces.MVC.IModel');
System::import('System.Form.FormChecker.Field');
System::import('System.Form.FormChecker.Helper.*');
System::import('System.Form.FormChecker.Modifier.*');
class FormChecker implements IModel
{
    private $_ItsFields;
    private $_ItsErrors;
    /** @brief    Contexte d'exécution partagé par tous les éléments */
    private static $_context = null;
    const REQUIRED = true;
    const TYPE_TEXT = 1;
    const TYPE_SELECT = 2;
    const TYPE_NUMERIC = 4;
    const TYPE_FLOAT = 8;
    const TYPE_RADIO = 16;
    const TYPE_CHECKBOX = 32;
    const TYPE_UPLOAD = 64;
    public function __construct()
    {
        if (is_null(self::$_context)) {
            throw new Exception('Context must be defined');
<?php

/**
 * @package       ADT
 * @class         AbstractTypedList
 * @author        Jimmy CHARLEBOIS
 * @date          21-02-2007
 * @brief         Classe abstraite pour gérer des List avec des éléments typés
 * @example       adt-typedlist-loader.php
 */
System::import('System.Interfaces.ADT.IList');
System::import('System.ADT.AbstractTypedCollection');
System::import('System.Exceptions.TypeMismatchException');
abstract class AbstractTypedList extends AbstractTypedCollection implements IList
{
    protected function __construct($type, IList &$list)
    {
        parent::__construct($type, $list);
    }
    public function set($index, $o)
    {
        if (!is_a($o, $this->_type)) {
            throw new TypeMismatchException(sprintf('Argument must be an instance of %s object', $this->_type));
        }
        $this->_collection->set($index, $o);
    }
    public function &get($index)
    {
        return $this->_collection->get($index);
    }
    public function indexOf($o)
Beispiel #13
0
<?php

/**
 * @package     	DataSource
 * @class       	DbmsMysql
 * @author      	Jimmy CHARLEBOIS
 * @date        	02-01-2007
 * @brief       	Implémentation concrête de DbmsDataSource pour MySQL
 */
System::import('System.DataSource.Dbms.ResultSets.ResultSetMysql');
class DbmsMysql extends DbmsDataSource
{
    public function __construct(IDataSourceDriver $driver)
    {
        parent::__construct($driver);
    }
    public function connect()
    {
        if (is_resource($this->getResource())) {
            return true;
        }
        $driver =& $this->getDriver();
        $res = @mysql_connect($driver->getHost(), $driver->getUsername(), $driver->getPassword());
        if (!$res) {
            throw new Exception('Unable to connect with ' . $driver->toString());
        }
        $this->setResource($res);
        return @mysql_select_db($driver->getDbName(), $res);
    }
    public function close()
    {
Beispiel #14
0
<?php

/**
 * @package       Network.Http
 * @class         HttpMessage
 * @author        Jimmy CHARLEBOIS
 * @date          14-02-2007
 * @brief         Classe sous jacente encapsulant un message HTTP (requête ou réponse)
 */
System::import('System.Interfaces.Network.IHttpMessage');
class HttpMessage implements IHttpMessage
{
    private $_type;
    private $_url;
    private $_method;
    private $_version;
    private $_raw;
    private $_headers;
    private $_body;
    private $_querystring;
    private $_response_code;
    private $_response_statut;
    const EOL = "\r\n";
    /** @defgroup   HttpMessageType   Constantes pour les méthodes d'envoi d'un message Http */
    /*@{*/
    const REQUEST = 1;
    const RESPONSE = 2;
    /*@}*/
    /** @defgroup   HttpMessageMethod   Constantes pour les méthodes d'envoi d'un message Http */
    /*@{*/
    const METHOD_POST = 'post';
Beispiel #15
0
<?php

/**
 * @package     	Log
 * @class       	FileLog
 * @author      	Jimmy CHARLEBOIS
 * @date        	24-01-2007
 * @brief       	Fichier de journalisation
 * @code
 *   $log =& new FileLog( 'test.log' );
 *   $log->write( 'Un message à logguer !' );
 *   $log->dispose();
 * @endcode
 */
System::import('System.Interfaces.Log.ILog');
System::import('System.IO.SysFile');
class FileLog implements ILog, IResource
{
    private $_resource;
    public function __construct($filename)
    {
        $this->_resource = new SysFile($filename);
        $this->_resource->open(SysFile::APPEND_ACCESS);
    }
    public function write($data)
    {
        $data = sprintf('[%s] %s%s', date('Y-m-d H:i:s'), $data, System::crlf);
        return $this->_resource->write($data);
    }
    public function dispose()
    {
Beispiel #16
0
<?php

/**
 * @package       Xml
 * @class         xmlComment
 * @author        Jimmy CHARLEBOIS
 * @date          08-03-2007
 * @brief         Classe représentant une section cdata xml
 */
System::import('System.Xml.xmlAbstractNode');
System::import('System.Xml.xmlEnumeration');
System::import('System.Xml.xmlTextNode');
class xmlComment extends xmlAbstractNode
{
    private $_value;
    public function __construct($text)
    {
        parent::__construct(xmlEnumeration::TYPE_COMMENT);
        $this->appendChild(new xmlTextNode($text));
    }
    public function toString()
    {
        $children = $this->childNodes();
        $rv = '<!' . $this->nodeName();
        foreach ($children as $childId => $child) {
            $rv .= $child->toString();
        }
        $rv .= '>';
        return $rv;
    }
}
<?php

/**
 * @package     DataGrid
 * @class       DataGridController
 * @author      Jimmy CHARLEBOIS
 * @date        16-11-2006
 * @brief       Controlleur basique pour DataGrid
 */
System::import('System.MVC.AbstractController');
System::import('System.DataGrid.View.Read.DataGridReadView');
System::import('System.DataGrid.View.Edit.DataGridEditView');
class DataGridController extends AbstractController
{
    private $_context;
    public function __construct(IContext &$context, DataGrid &$model)
    {
        parent::__construct($model);
        $this->_context =& $context;
    }
    public function &getContext()
    {
        return $this->_context;
    }
    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
         */
<?php

/**
 * @package       Calendar
 * @class         AnnualCalendarReadView
 * @author        Jimmy CHARLEBOIS
 * @date          04-01-2007
 * @brief         
 */
System::import('System.MVC.AbstractView');
System::import('System.Calendar.Views.Read.AnnualCalendarDateReadView');
class AnnualCalendarReadView extends AbstractView
{
    public function __construct()
    {
        parent::__construct();
    }
    public function render()
    {
        $calendar =& $this->getModel();
        $bounds = $calendar->getBounds();
        $days = $calendar->getDays($bounds['low'], $bounds['high']);
        //      system::export( $days );
        $month_labels = $calendar->getMonthLabels();
        $html = '<div class="calendar">' . System::crlf;
        if (count($days) > 0) {
            $html .= '<table border="1" cellspacing="0" cellpadding="0" class="annual_view">' . System::crlf . '<thead>' . System::crlf . '<tr>' . System::crlf;
            foreach ($month_labels as $idx => $label) {
                $html .= '<th>' . htmlspecialchars($label) . '</th>' . System::crlf;
            }
            $html .= '</tr>' . System::crlf . '</thead>' . System::crlf . '<tbody>' . System::crlf . '<tr>' . System::crlf;
<?php

/**
 * @author        Jimmy CHARLEBOIS
 * @date          08-03-2007
 * @brief         Exemple d'utilisation de la classe xmlDocument
 */
require 'c.system.php';
System::import('System.Xml.xmlDocument');
//  System::export( '-- creating xml document --' );
$xml =& new xmlDocument('root');
$xml->setEncoding('windows-1252');
//  System::export( htmlspecialchars( (string)$xml ), 'xml' );
$root =& $xml->getDocumentElement();
//  System::export( '-- adding a user --' );
$user =& $xml->createElement('user');
$user->setAttribute('firstname', 'James');
$user->setAttribute('lastname', 'Pota"gueule');
$user->setAttribute('birthday', date('Y-m-d'));
$user->appendChild($xml->createTextNode('É<wè Lor>en ip\'sum...'));
$root->appendChild($user);
//  System::export( htmlspecialchars( (string)$xml ), 'xml' );
Header('Content-Type: text/xml; charset="windows-1252"');
echo (string) $xml;
Beispiel #20
0
<?php

/**
 * @class  FormChecker_Helper_BirthdayFormat
 * @date   21-07-2006
 * @author Jimmy CHARLEBOIS
 * @brief  Assistant vérifiant le format d'une date
 */
System::import('System.Interfaces.Form.FormChecker.IFormCheckerHelper');
class FormChecker_Helper_BirthdayFormat implements IFormCheckerHelper
{
    public static function check(FormChecker_Field &$oField, $params)
    {
        $value = $oField->getValue();
        if (is_null($value) && !$oField->isRequired()) {
            return true;
        }
        switch ($params) {
            case 'YYYY-mm-dd':
            case 'Y-m-d':
                $regPattern = '^[0-9]{4}-[0-9]{2}-[0-9]{2}$';
                break;
            case 'jj-mm-aaaa':
            case 'd-m-Y':
                $regPattern = '^[0-9]{2}-[0-9]{2}-[0-9]{4}$';
                break;
        }
        if (!mb_eregi($regPattern, $value)) {
            return $oField->raiseError('Mauvais format de date : ' . $params);
        }
        return true;
<?php

/**
 * @author      	Jimmy CHARLEBOIS
 * @date        	27-04-2007
 * @brief         Scanne les fichiers php d'un répertoire donné et détermine quels fichiers de System devrons être copiés
 */
require_once 'c.system.php';
System::import('System.Context.ShellContext');
System::import('System.Context.RuntimeContext');
System::import('System.IO.SysDirectory');
System::import('System.ADT.Queue');
function help()
{
    echo 'Scanne les fichiers php d\'un projet à la recherche des inclusions System::import() !' . System::crlf . 'Paramètres attendus :' . System::crlf . '1) répertoire de base du projet à scanner' . System::crlf . System::crlf . 'ou' . System::crlf . System::crlf . '--help:  Ce panneau d\'aide' . System::crlf;
}
function error($msg)
{
    echo 'ERROR: ' . $msg . System::crlf;
}
function find_files($path, Queue &$result)
{
    $files = SysDirectory::getFiles($path);
    $iterator =& $files->getIterator();
    while ($iterator->hasNext()) {
        $entry =& $iterator->next();
        if ('php' == $entry->getExtension()) {
            if (!$result->contains($entry)) {
                $result->enqueue($entry);
            }
        }
 public function setAttribute($key, $value)
 {
     System::import('System.Xml.xmlAttribute');
     $this->_attributes[strtolower($key)] =& new xmlAttribute($key, $value);
 }
<?php

/**
 * @package       DataGrid
 * @class   		DataGridComposite
 * @author        Jimmy CHARLEBOIS
 * @date          10-11-2006
 * @brief         
 */
System::import('System.Interfaces.DataGrid.IDataGridComposite');
System::import('System.Interfaces.DataGrid.IDataGridComponent');
abstract class DataGridComposite implements IDataGridComposite, IDataGridComponent
{
    private $_id;
    private $_parent;
    private $_components;
    public function __construct($id)
    {
        $this->_id = $id;
        $this->_parent = null;
        $this->_components = array();
    }
    public function getId()
    {
        return $this->_id;
    }
    public function &getValue()
    {
        throw new Exception('Unsupported operation');
    }
    public function &getParent()
<?php

/**
 * @package   Event
 * @class     EventDispatcher
 * @author    Jimmy CHARLEBOIS
 * @date      29 oct. 06
 * @brief     Source d'évènements qui diffuse, des évènements, à des objets écouteurs
 */
System::import('System.Interfaces.Event.IEventDispatcher');
class EventDispatcher implements IEventDispatcher
{
    private $_eventListeners;
    private $_hasEventListeners;
    private $_parent;
    public $bubbleEvent;
    public function __construct()
    {
        $this->_eventListeners = array();
        $this->_hasEventListeners = false;
        $this->_parent = null;
        $this->bubbleEvent = true;
    }
    public function addEventListener(IEventListener &$oListener)
    {
        if (!in_array($oListener, $this->_eventListeners)) {
            $this->_eventListeners[] =& $oListener;
        }
        $this->_hasEventListeners = true;
    }
    public function removeEventListener(IEventListener &$oListener)
Beispiel #25
0
<?php

/**
 * @class  FormChecker_Modifier_Replace
 * @date   04-10-2006
 * @author Jimmy CHARLEBOIS
 * @brief  Modificateur retirant les caractères ne matchant pas l'expression rationnelle
 */
System::import('System.Interfaces.Form.FormChecker.IFormCheckerModifier');
class FormChecker_Modifier_Replace implements IFormCheckerModifier
{
    public function process(FormChecker_Field &$oField, $params = null)
    {
        if (!isset($params['pattern'])) {
            throw new Exception('Please provide the "pattern" parameter to the Replace modifier');
        }
        if (!isset($params['replacement'])) {
            throw new Exception('Please provide the "replacement" parameter to the Replace modifier');
        }
        $oField->setValue(preg_replace($params['pattern'], $params['replacement'], $oField->getValue()));
    }
}
Beispiel #26
0
<?php

/**
 * @package       Xml
 * @class         xmlElement
 * @author        Jimmy CHARLEBOIS
 * @date          08-03-2007
 * @brief         Classe repr�sentant une section cdata xml
 */
System::import('System.Xml.xmlAbstractNode');
System::import('System.Xml.xmlEnumeration');
class xmlElement extends xmlAbstractNode
{
    public function __construct($nodeName)
    {
        parent::__construct(xmlEnumeration::TYPE_ELEMENT, $nodeName);
    }
}
<?php

/**
 * @package     	FormInput
 * @class       	FormInputConfiguration
 * @author      	Jimmy CHARLEBOIS
 * @date        	25-01-2007
 * @brief       	Classe d'encapsulation des propriétés de configuration d'un élément de formulaire
 */
System::import('System.Interfaces.FormInput.IFormInputConfiguration');
System::import('System.BaseClass');
System::import('System.StoreObject');
class FormInputConfiguration extends BaseClass implements IFormInputConfiguration
{
    private $_items;
    public function __construct()
    {
        parent::__construct();
        $this->_items = array();
    }
    public function store()
    {
        $item_data = array();
        foreach ($this->_items as $key => $value) {
            $item_data[$key] = StoreObject::store($this->_items[$key]);
        }
        return array('items' => $item_data);
    }
    public static function restore($props)
    {
        $rv =& new FormInputConfiguration();
Beispiel #28
0
<?php

/**
 * @package       ADT.Iterators
 * @class         SetIterator
 * @author        Jimmy CHARLEBOIS
 * @date          19-02-2007
 * @brief         Itérateur pour collection de valeurs
 */
System::import('System.ADT.Iterators.AbstractCollectionIterator');
System::import('System.Exceptions.UnsupportedOperationException');
class SetIterator extends AbstractCollectionIterator
{
    public function __construct(ISet &$collection)
    {
        parent::__construct($collection);
    }
    public function &current()
    {
        $rv = null;
        $p = $this->getPointeur();
        $tmp = $this->getCollection()->toArray();
        /**
         * @note    01-05-2007  modification pour avoir une référence et non une copie
         */
        if (array_key_exists($p, $tmp)) {
            $rv =& $tmp[$p];
        }
        return $rv;
    }
    public function &next()
<?php

/**
 * @package     	DataGrid
 * @class       	DbmsDataGridSource
 * @author      	Jimmy CHARLEBOIS
 * @date        	20-11-2006
 * @brief       	Implémentation de source de données MySQL pour DataGrid
 */
System::import('System.DataSource.DbmsDataSource');
System::import('System.DataGrid.Model.DataGrid');
System::import('System.DataGrid.Model.DataGridRow');
System::import('System.DataGrid.Model.DataGridColumn');
System::import('System.DataGrid.DataSources.DataGridSource');
class DbmsDataGridSource extends DataGridSource
{
    public function __construct(IDataSourceDriver $driver)
    {
        parent::__construct($driver);
    }
    public function dispose()
    {
        $db =& DbmsDataSource::getInstance($this->getDriver());
        $db->close();
    }
    public function &getDataGrid(IDataSourceExpression &$expression)
    {
        $rv = null;
        if (!$expression instanceof DbmsExpression) {
            throw new Exception('DbmsExpression missing');
        }
<?php

/**
 * @package     DataGrid
 * @class       DataGridReadView
 * @author      Jimmy CHARLEBOIS
 * @date        10-11-2006
 * @brief       Vue en mode consultation d'un DataGrid
 */
System::import('System.MVC.AbstractView');
System::import('System.DataGrid.View.Read.DataGridRowReadView');
class DataGridReadView extends AbstractView
{
    public function __construct(IDataGridComposite &$datagrid)
    {
        parent::__construct();
        $this->setModel($datagrid);
    }
    public function display()
    {
        $rows = $this->getModel()->getComponents();
        echo '<div class="datagrid read">', System::crlf, '<table border="1" cellspacing="0" cellpadding="0">', System::crlf;
        if (!is_null($this->getModel()->getTitle())) {
            echo '<caption>', $this->getModel()->getTitle(), '</caption>', System::crlf;
        }
        echo '<tbody>', System::crlf;
        foreach ($rows as $rowId => $row) {
            $dgrView =& new DataGridRowReadView($row);
            $dgrView->display();
        }
        echo '</tbody>', System::crlf, '</table>', System::crlf, '<a href="?datagrid-id=' . urlencode($this->getModel()->getId()) . '&datagrid-mode=edit">Edit</a>', System::crlf, '</div>', System::crlf;