Example #1
0
 /**
  * Driver Factory
  *
  * A clever method which loads and instantiate data source drivers.
  *
  * Can be called in various ways :
  *
  * Detect the source type and load the appropriate driver with default
  * options :
  * <code>
  * $driver =& Structures_DataGrid_DataSource::create($source);
  * </code>
  *
  * Detect the source type and load the appropriate driver with custom
  * options :
  * <code>
  * $driver =& Structures_DataGrid_DataSource::create($source, $options);
  * </code>
  *
  * Load a driver for an explicit type (faster, bypasses detection routine) :
  * <code>
  * $driver =& Structures_DataGrid_DataSource::create($source, $type, $options);
  * </code>
  *
  * @access  public
  * @param   mixed   $source     The data source respective to the driver
  * @param   array   $options    An associative array of the form :
  *                              array(optionName => optionValue, ...)
  * @param   string  $type       The data source type constant (of the form 
  *                              DATAGRID_DATASOURCE_*)  
  * @uses    Structures_DataGrid_DataSource::_detectSourceType()     
  * @return  mixed               Returns the source driver object or 
  *                              PEAR_Error on failure
  * @static
  */
 function &create($source, $options = array(), $type = null)
 {
     if (is_null($type) && !($type = Structures_DataGrid_DataSource::_detectSourceType($source))) {
         return new PEAR_Error('Unable to determine the data source type. ' . 'You may want to explicitly specify it.');
     }
     if (!@(include_once "Structures/DataGrid/DataSource/{$type}.php")) {
         return new PEAR_Error("No such data source driver: '{$type}'");
     }
     $classname = "Structures_DataGrid_DataSource_{$type}";
     $driver = new $classname();
     $driver->bind($source, $options);
     return $driver;
 }
Example #2
0
 function Structures_DataGrid_DataSource_Array()
 {
     parent::Structures_DataGrid_DataSource();
 }
Example #3
0
 /**
  * Constructor
  *
  * @param object DB_DataObject
  * @access public
  */
 function Structures_DataGrid_DataSource_DataObject()
 {
     parent::Structures_DataGrid_DataSource();
     $this->_addDefaultOptions(array('labels_property' => 'fb_fieldLabels', 'fields_property' => 'fb_fieldsToRender', 'sort_property' => 'fb_linkOrderFields', 'formbuilder_integration' => false));
 }
Example #4
0
 /**
  * A simple way to add a recod set to the datagrid
  *
  * @access  public
  * @param   mixed   $rs         The record set in any of the supported data
  *                              source types
  * @param   array   $options    Optional. The options to be used for the
  *                              data source
  * @param   string  $type       Optional. The data source type
  * @return  bool                True if successful, otherwise PEAR_Error.
  */
 function bind($rs, $options = array(), $type = null)
 {
     require_once 'Structures/DataGrid/DataSource.php';
     $source =& Structures_DataGrid_DataSource::create($rs, $options, $type);
     if (!PEAR::isError($source)) {
         return $this->bindDataSource($source);
     } else {
         return $source;
     }
 }
Example #5
0
 /**
  * Constructor
  *
  * @param object DB_DataObject
  * @access public
  */
 public function __construct()
 {
     parent::Structures_DataGrid_DataSource();
     $this->_addDefaultOptions(array('use_private_vars' => false, 'labels_property' => 'fb_fieldLabels', 'fields_property' => 'fb_fieldsToRender', 'sort_property' => 'fb_linkOrderFields'));
     $this->_setFeatures(array('multiSort' => true));
 }