Source for file PEAR_DATAGRID_DATASOURCE_OCSP_FRMCONTR_LIST.phpclass

Documentation is available at PEAR_DATAGRID_DATASOURCE_OCSP_FRMCONTR_LIST.phpclass

  1. <?php
  2. /**
  3.   * openCSP class file PEAR_DATAGRID_DATASOURCE_OCSP_FRMCONTR_LIST.phpclass
  4.   *
  5.   * @project Open CSP-Management
  6.   * @package default
  7.   *
  8.   * @author Peter Krebs <pitlinz@users.sourceforge.net>
  9.   * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  10.   *
  11.   * @since pk-26.11.2008
  12.   * @version $Id: PEAR_DATAGRID_DATASOURCE_OCSP_FRMCONTR_LIST.phpclass,v 1.2 2008/11/28 13:20:40 pitlinz Exp $
  13.   */
  14.  
  15.     // ---------------------------------------------------------
  16.     // requirements
  17.     // ---------------------------------------------------------
  18.  
  19.     if (!class_exists('Structures_DataGrid_DataSource'))
  20.     {
  21.         @require_once("Structures" _OCSP_DIRSEP_ "DataGrid" _OCSP_DIRSEP_ "DataSource.php");
  22.         if (!class_exists('Structures_DataGrid_DataSource'))
  23.         {
  24.             throw new Exception("MISSING PEAR:" Structures_DataGrid_DataSource);
  25.         }
  26.     }
  27.     
  28.     pcf_require_class('OCSP_FRMCONTR_PEAR_DATAGRID',"db/forms/");
  29.  
  30. /**
  31.   * openCSP class PEAR_DATAGRID_DATASOURCE_OCSP_FRMCONTR_LIST
  32.   *
  33.   * @project Open CSP-Management
  34.   * @package default
  35.   *
  36.   * @author Peter Krebs <pitlinz@users.sourceforge.net>
  37.   * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  38.   *
  39.   * @since pk-26.11.2008
  40.   * @version $Id: PEAR_DATAGRID_DATASOURCE_OCSP_FRMCONTR_LIST.phpclass,v 1.2 2008/11/28 13:20:40 pitlinz Exp $
  41.   */
  42. class PEAR_DATAGRID_DATASOURCE_OCSP_FRMCONTR_LIST extends Structures_DataGrid_DataSource
  43. {
  44.     // ---------------------------------------------------------------------------
  45.     // constants
  46.     // ---------------------------------------------------------------------------
  47.     
  48.     // ---------------------------------------------------------------------------
  49.     // class (static)
  50.     // ---------------------------------------------------------------------------
  51.     
  52.     /*** class vars ------------------------------------------------------ */
  53.     
  54.     /*** class methods --------------------------------------------------- */
  55.     
  56.     // ---------------------------------------------------------------------------
  57.     // object vars
  58.     // ---------------------------------------------------------------------------
  59.     
  60.     /*** compostion --------------------------------------------------- */
  61.     
  62.     /**
  63.      * list control object
  64.      *
  65.      * @var OCSP_FRMCONTR_PEAR_DATAGRID $myListControl; 
  66.      */
  67.     protected $myListControl = Null;
  68.     
  69.     /*** attributes  -------------------------------------------------- */
  70.     
  71.     // ---------------------------------------------------------------------------
  72.     // factory / construct
  73.     // ---------------------------------------------------------------------------
  74.  
  75.     public function factory(&$aControl,$debug=False)
  76.     {
  77.         if ($debugechoDebugMethod(__FILE__,"static","PEAR_DATAGRID_DATASOURCE_OCSP_FRMCONTR_LIST::factory()");
  78.         if (!pcf_is_instance_of($aControl,'OCSP_FRMCONTR_PEAR_DATAGRID'))
  79.         {
  80.             throw new Exception(_OCSP_EXCEP_WRONGOBJ_TYPE_,": required OCSP_FRMCONTR_PEAR_DATAGRID sent " get_class($aControl));
  81.         }
  82.         $obj_ret new PEAR_DATAGRID_DATASOURCE_OCSP_FRMCONTR_LIST();
  83.         $obj_ret->setListControl($aControl);
  84.         return $obj_ret;
  85.     }
  86.     
  87.     
  88.     // ---------------------------------------------------------------------------
  89.     // getter / setter
  90.     // ---------------------------------------------------------------------------    
  91.  
  92.     public function setListControl(&$aControl)
  93.     {
  94.         $this->myListControl = $aControl;
  95.     }
  96.     
  97.     // ---------------------------------------------------------------------------
  98.     // grid datasource methods
  99.     // ---------------------------------------------------------------------------    
  100.     
  101.     /**
  102.      * returns the total number or records found in the container.
  103.      *
  104.      * @return unknown 
  105.      */
  106.     public function count()
  107.     {                
  108.         $int_ret $this->myListControl->getNofListRows();
  109.         if ($int_ret !== False)
  110.         {
  111.             return $int_ret;
  112.         else {
  113.             return new PEAR_Error("could not count list elements");
  114.         }
  115.     }
  116.     
  117.     /**
  118.      * sort the data according to sortSpec and the optional sortDir
  119.      *
  120.      * @param string $sortSpec 
  121.      * @param string $sortDir 
  122.      */
  123.     public function sort($sortSpec$sortDir 'ASC'
  124.     {
  125.         if (!empty($sortSpec))
  126.         {
  127.             $this->myListControl->setDataGridSort($sortSpec " " $sortDir);
  128.         }
  129.     }
  130.     
  131.     /**
  132.      * returns a 2-dimension array of data, starting from record offset, containing len records
  133.      *
  134.      * @param int $offset 
  135.      * @param int $len 
  136.      */
  137.     public function fetch($offset 0$len null
  138.     {    
  139.         //if ($debug) echoDebugMethod(__FILE__,get_class($this),"PEAR_DATAGRID_DATASOURCE_OCSP_FRMCONTR_LIST::fetch()");
  140.         /*
  141.         $bol_forceReload = False;
  142.         if (!intval($offset) && ($this->myListControl->getOffset() != $offset))
  143.         {
  144.             $this->myListControl->setOffset($offset);
  145.             $this->myListControl->setLimit((intval($len) ? intval($len) : PEAR_DATAGRID_MAXLIMIT));
  146.         } else if (intval($len) && ($this->myListControl->getLimit() != intval($len))) {
  147.             $this->myListControl->setLimit((intval($len) ? intval($len) : PEAR_DATAGRID_MAXLIMIT));
  148.         }
  149.         */
  150.         $arr_ret $this->myListControl->getListRows($offset,$len,$debug);
  151.         
  152.         if ($debugechoDebugLine(__FILE__,__LINE__,"<hr /><h2>fetched data:</h2><pre>" print_r($arr_ret,True"</pre>");
  153.         return $arr_ret;
  154.         
  155.     }
  156.     
  157. }
  158.  
  159. ?>

Documentation generated on Thu, 08 Jan 2009 17:47:51 +0100 by phpDocumentor 1.4.0a2