PhpExt : Data [ class tree ] [ index ] [ all elements ]

Source for file Store.php

Documentation is available at Store.php

  1. <?php
  2. /**
  3.  * PHP-Ext Library
  4.  * http://php-ext.googlecode.com
  5.  * @author Sergei Walter <sergeiw[at]gmail[dot]com>
  6.  * @copyright 2008 Sergei Walter
  7.  * @license http://www.gnu.org/licenses/lgpl.html
  8.  * @link http://php-ext.googlecode.com
  9.  * 
  10.  *  Reference for Ext JS: http://extjs.com
  11.  * 
  12.  */
  13. /**
  14.  * @see PhpExt_Observable
  15.  */
  16. include_once 'PhpExt/Observable.php';
  17. /**
  18.  * @see PhpExt_Config_ConfigObject
  19.  */
  20. include_once 'PhpExt/Config/ConfigObject.php';
  21.  
  22. /**
  23.  * The Store class encapsulates a client side cache of {@link PhpExt_Data_Record Record} objects which provide input data for Components such as the {@link PhpExt_Grid_GridPanel GridPanel}, the {@link PhpExt_Form_ComboBox ComboBox}, or the {@link PhpExt_DataView DataView}
  24.  * <p>A Store object uses its configured implementation of {@link PhpExt_Data_DataProxy DataProxy} to access a data object unless you call {@link PhpExt_Data_Store::loadData() loadData} directly and pass in your data.</p>
  25.  * <p>A Store object has no knowledge of the format of the data returned by the Proxy.</p>
  26.  * <p>A Store object uses its configured implementation of {@link PhpExt_Data_DataReader DataReader} to create {@link PhpExt_Data_Record Record} instances from the data object. These Records are cached and made available through accessor functions.</p>
  27.  * @package PhpExt
  28.  * @subpackage Data
  29.  */
  30. {
  31.     // AutoLoad
  32.     /**
  33.      * If passed, this store's load method is automatically called after creation with the autoLoad object
  34.      * @param boolean $value 
  35.      * @return PhpExt_Data_Store 
  36.      */
  37.     public function setAutoLoad($value{
  38.         $this->setExtConfigProperty("autoLoad"$value);
  39.         return $this;
  40.     }    
  41.     /**
  42.      * If passed, this store's load method is automatically called after creation with the autoLoad object
  43.      * @return boolean 
  44.      */
  45.     public function getAutoLoad({
  46.         return $this->getExtConfigProperty("autoLoad");
  47.     }
  48.     
  49.     // BaseParams
  50.     /**
  51.      * An array containing properties which are to be sent as parameters on any HTTP request.
  52.      * Format:
  53.      * <code>array('param1'=>10,'param2'=>'some value')</code>
  54.      * @param array $value 
  55.      * @return PhpExt_Data_Store 
  56.      */
  57.     public function setBaseParams($value{
  58.         $this->setExtConfigProperty("baseParams"$value);
  59.         return $this;
  60.     }    
  61.     /**
  62.      * An object containing properties which are to be sent as parameters on any HTTP request
  63.      * Format:
  64.      * <code>array('param1'=>10,'param2'=>'some value')</code>
  65.      * @return array 
  66.      */
  67.     public function getBaseParams({
  68.         return $this->getExtConfigProperty("baseParams");
  69.     }
  70.     
  71.     // Data
  72.     /**
  73.      * Inline data to be loaded when the store is initialized.
  74.      * @param mixed $value 
  75.      * @return PhpExt_Data_Store 
  76.      */
  77.     public function setData($value{
  78.         $this->setExtConfigProperty("data"$value);
  79.         return $this;
  80.     }    
  81.     /**
  82.      * Inline data to be loaded when the store is initialized.
  83.      * @return mixed 
  84.      */
  85.     public function getData({
  86.         return $this->getExtConfigProperty("data");
  87.     }
  88.     
  89.     // Proxy
  90.     /**
  91.      * The Proxy object which provides access to a data object.
  92.      * @see PhpExt_Data_DataProxy
  93.      * @see PhpExt_Data_HttpProxy
  94.      * @see PhpExt_Data_MemoryProxy
  95.      * @see PhpExt_Data_ScriptTagProxy
  96.      * @param PhpExt_Data_DataProxy $value 
  97.      * @uses PhpExt_Data_DataProxy
  98.      * @return PhpExt_Data_Store 
  99.      */
  100.     public function setProxy($value{
  101.         $this->setExtConfigProperty("proxy"$value);
  102.         return $this;
  103.     }    
  104.     /**
  105.      * The Proxy object which provides access to a data object.
  106.      * @see PhpExt_Data_DataProxy
  107.      * @see PhpExt_Data_HttpProxy
  108.      * @see PhpExt_Data_MemoryProxy
  109.      * @see PhpExt_Data_ScriptTagProxy
  110.      * @return PhpExt_Data_DataProxy 
  111.      */
  112.     public function getProxy({
  113.         return $this->getExtConfigProperty("proxy");
  114.     }
  115.     
  116.     // PruneModifiedRecords
  117.     /**
  118.      * True to clear all modified record information each time the store is loaded or when a record is removed. (defaults to false).
  119.      * @param boolean $value 
  120.      * @return PhpExt_Data_Store 
  121.      */
  122.     public function setPruneModifiedRecords($value{
  123.         $this->setExtConfigProperty("var"$value);
  124.         return $this;
  125.     }    
  126.     /**
  127.      * True to clear all modified record information each time the store is loaded or when a record is removed. (defaults to false).
  128.      * @return boolean 
  129.      */
  130.     public function getPruneModifiedRecords({
  131.         return $this->getExtConfigProperty("var");
  132.     }
  133.     
  134.     // Reader
  135.     /**
  136.      * The Reader object which processes the data object and returns an Array of Ext.data.record objects which are cached keyed by their id property.
  137.      * @see PhpExt_Data_DataReader
  138.      * @see PhpExt_Data_ArrayReader
  139.      * @see PhpExt_Data_JsonReader
  140.      * @see PhpExt_Data_XmlReader
  141.      * @uses PhpExt_Data_DataReader
  142.      * @param PhpExt_Data_DataReader $value 
  143.      * @return PhpExt_Data_Store 
  144.      */
  145.     public function setReader($value{
  146.         $this->setExtConfigProperty("reader"$value);
  147.         return $this;
  148.     }    
  149.     /**
  150.      * The Reader object which processes the data object and returns an Array of Ext.data.record objects which are cached keyed by their id property.
  151.      * @see PhpExt_Data_DataReader
  152.      * @see PhpExt_Data_ArrayReader
  153.      * @see PhpExt_Data_JsonReader
  154.      * @see PhpExt_Data_XmlReader
  155.      * @return PhpExt_Data_DataReader 
  156.      */
  157.     public function getReader({
  158.         return $this->getExtConfigProperty("reader");
  159.     }
  160.     
  161.     // RemoteSort
  162.     /**
  163.      * True if sorting is to be handled by requesting the Proxy to provide a refreshed version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false).
  164.      * If remote sorting is specified, then clicking on a column header causes the current page to be requested from the server with the addition of the following two parameters:
  165.      * - sort : String
  166.      *    The name (as specified in the Record's Field definition) of the field to sort on.
  167.      * - dir : String
  168.      *    The direction of the sort, "ASC" or "DESC".
  169.      *  
  170.      * @param boolean $value 
  171.      * @return PhpExt_Data_Store 
  172.      */
  173.     public function setRemoteSort($value{
  174.         $this->setExtConfigProperty("remoteSort"$value);
  175.         return $this;
  176.     }    
  177.     /**
  178.      * True if sorting is to be handled by requesting the Proxy to provide a refreshed version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false).
  179.      * If remote sorting is specified, then clicking on a column header causes the current page to be requested from the server with the addition of the following two parameters:
  180.      * - sort : String
  181.      *    The name (as specified in the Record's Field definition) of the field to sort on.
  182.      * - dir : String
  183.      *    The direction of the sort, "ASC" or "DESC".
  184.      *  
  185.      * @return boolean 
  186.      */
  187.     public function getRemoteSort({
  188.         return $this->getExtConfigProperty("remoteSort");
  189.     }
  190.     
  191.     // SortInfo
  192.     /**
  193.      * SortInfo Configuration Object
  194.      * @uses PhpExt_Data_SortInfoConfigObject
  195.      * @param PhpExt_Data_SortInfoConfigObject $value 
  196.      * @return PhpExt_Data_Store 
  197.      */
  198.     public function setSortInfo($value{
  199.         $this->setExtConfigProperty("sortInfo"$value);
  200.         return $this;
  201.     }    
  202.     /**
  203.      * SortInfo Configuration Object
  204.      * @return PhpExt_Data_SortInfoConfigObject 
  205.      */
  206.     public function getSortInfo({
  207.         return $this->getExtConfigProperty("sortInfo");
  208.     }
  209.     
  210.     // StoreId
  211.     /**
  212.      * If passed, the id to use to register with the StoreMgr
  213.      * @param string $value 
  214.      * @return PhpExt_Data_Store 
  215.      */
  216.     public function setStoreId($value{
  217.         $this->setExtConfigProperty("storeId"$value);
  218.         return $this;
  219.     }    
  220.     /**
  221.      * If passed, the id to use to register with the StoreMgr
  222.      * @return string 
  223.      */
  224.     public function getStoreId({
  225.         return $this->getExtConfigProperty("storeId");
  226.     }
  227.     
  228.     // Url
  229.     /**
  230.      * If passed, an HttpProxy is created for the passed URL
  231.      * @param string $value 
  232.      * @return PhpExt_Data_Store 
  233.      */
  234.     public function setUrl($value{
  235.         $this->setExtConfigProperty("url"$value);
  236.         return $this;
  237.     }    
  238.     /**
  239.      * If passed, an HttpProxy is created for the passed URL
  240.      * @return string 
  241.      */
  242.     public function getUrl({
  243.         return $this->getExtConfigProperty("url");
  244.     }    
  245.  
  246.     
  247.     
  248.     public function __construct({
  249.         parent::__construct();
  250.         $this->setExtClassInfo("Ext.data.Store"null);        
  251.         
  252.         $validProps array(
  253.             "autoLoad",
  254.             "baseParams",
  255.             "data",
  256.             "proxy",
  257.             "pruneModifiedRecords",
  258.             "reader",
  259.             "remoteSort",
  260.             "sortInfo",
  261.             "storeId",
  262.             "url"
  263.         );
  264.         $this->addValidConfigProperties($validProps);
  265.     }    
  266.     
  267.     /**
  268.      * Loads the Record cache from the configured Proxy using the configured Reader.
  269.      * <p>If using remote paging, then the first load call must specify the start and limit properties in the options.params property to establish the initial position within the dataset, and the number of Records to cache on each read from the Proxy.</p>
  270.      * <p><b>It is important to note that for remote data sources, loading is asynchronous, and this call will return before the new data has been loaded. Perform any post-processing in a callback function, or in a "load" event handler.</b></p>
  271.      * @param PhpExt_Data_StoreLoadOptions $options 
  272.      * @return void 
  273.      */
  274.     public function load(PhpExt_Data_StoreLoadOptions $options null{
  275.         $args func_get_args();
  276.         $ms $this->createMethodSignature("load"$args);
  277.         return $this->getMethodInvokeStm($this->_varName$ms);
  278.     }
  279.     
  280.     /**
  281.      * Loads data from a passed data block. A Reader which understands the format of the data must have been configured in the constructor.
  282.      * @param mixed $data The data block from which to read the Records. The format of the data expected is dependent on the type of Reader that is configured and should correspond to that Reader's readRecords parameter.
  283.      * @param boolean $append (Optional) True to append the new Records rather than replace the existing cache.
  284.      */
  285.     public function loadData($data$append false{
  286.         $args func_get_args();
  287.         $ms $this->createMethodSignature("loadData"$args);
  288.         return $this->getMethodInvokeStm($this->_varName$ms);
  289.     }    
  290.      
  291.     
  292. }

Documentation generated on Fri, 08 Aug 2008 16:00:31 -0500 by phpDocumentor 1.4.0