Source for file OCSP_FRMVIEW_LIST_FLEXGRID.phpclass

Documentation is available at OCSP_FRMVIEW_LIST_FLEXGRID.phpclass

  1. <?php
  2. /**
  3.   * openCSP class file
  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-29.05.2008
  12.   * @version $Id: OCSP_FRMVIEW_LIST_FLEXGRID.phpclass,v 1.6 2008/12/03 21:32:42 pitlinz Exp $
  13.   */
  14.  
  15. // ---------------------------------------------------------
  16. // requirements
  17. // ---------------------------------------------------------
  18.  
  19.     pcf_require_class('OCSP_FRMVIEW_LIST',dirname(__FILE___OCSP_DIRSEP_ "OCSP_FRMVIEW_LIST.phpclass");
  20.  
  21. /**
  22.   * openCSP class file
  23.   *
  24.   * @project Open CSP-Management
  25.   * @package default
  26.   *
  27.   * @author Peter Krebs <pitlinz@users.sourceforge.net>
  28.   * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  29.   *
  30.   * @since pk-29.05.2008
  31.   * @version $Id: OCSP_FRMVIEW_LIST_FLEXGRID.phpclass,v 1.6 2008/12/03 21:32:42 pitlinz Exp $
  32.   */
  33.     extends OCSP_FRMVIEW_LIST 
  34. {
  35.     /*** class constants  --------------------------------------------- */
  36.  
  37.     /**
  38.      * @constant string CLASS_SRC_FILE
  39.      *
  40.      * @abstract
  41.      */
  42.     const CLASS_SRC_FILE = __FILE__;
  43.     
  44.     /*** compostion --------------------------------------------------- */
  45.     
  46.     /*** attributes  -------------------------------------------------- */
  47.     
  48.     /**
  49.      * @var string $gridDOMId 
  50.      */
  51.     protected $gridDOMId = "";
  52.     
  53.     // flexgrid layout attributes
  54.     
  55.     /**
  56.      * @var boolean $grid_showTableToggleBtn 
  57.      */
  58.     protected $grid_showTableToggleBtn = True;
  59.     
  60.     
  61.     protected $grid_attributes = array();
  62.         
  63.     
  64.     /*** factory / construct  ----------------------------------------- */
  65.     
  66.     /*** getter / setter ---------------------------------------------- */
  67.     
  68.     /**
  69.      * @param string $aDOMId 
  70.      */
  71.     public function setGridDOMId($aDOMId)
  72.     {
  73.         $this->gridDOMId = $aDOMId;
  74.     }
  75.     
  76.     /**
  77.      * @return string 
  78.      */
  79.     public function getGridDOMId()
  80.     {
  81.         if (empty($this->gridDOMId))
  82.         {
  83.             $this->gridDOMId = trim($this->getControl()->getTableId())
  84.         }
  85.         return $this->gridDOMId;
  86.     }
  87.  
  88.     /**
  89.      * sets a jQuery.flexgrid attribute
  90.      *
  91.      *         height: 200, //default height
  92.      *         width: 'auto', //auto width
  93.      *         striped: true, //apply odd even stripes
  94.      *         novstripe: false,
  95.      *         minwidth: 30, //min width of columns
  96.      *         minheight: 100, //min height of columns
  97.      *         resizable: true, //resizable table
  98.      *         url: false, //ajax url
  99.      *         method: 'POST', // data sending method
  100.      *         dataType: 'xml', // type of data loaded
  101.      *         errormsg: 'Connection Error',
  102.      *         usepager: false, //
  103.      *         nowrap: true, //
  104.      *         page: 1, //current page
  105.      *         total: 1, //total pages
  106.      *         useRp: true, //use the results per page select box
  107.      *         rp: 15, // results per page
  108.      *         rpOptions: [10,15,20,25,40],
  109.      *         title: false,
  110.      *         pagestat: 'Displaying {from} to {to} of {total} items',
  111.      *         procmsg: 'Processing, please wait ...',
  112.      *         query: '',
  113.      *         qtype: '',
  114.      *         nomsg: 'No items',
  115.      *         minColToggle: 1, //minimum allowed column to be hidden
  116.      *          showToggleBtn: true, //show or hide column toggle popup
  117.      *         hideOnSubmit: true,
  118.      *         autoload: true,
  119.      *         blockOpacity: 0.5,
  120.      *         onToggleCol: false,
  121.      *         onChangeSort: false,
  122.      *         onSuccess: false,
  123.      *         onSubmit: false // using a custom populate function
  124.      *  
  125.      * @param string $settingName 
  126.      * @param string $value (js escaped
  127.      */
  128.     public function setGridAttribute($settingName,$value)
  129.     {
  130.         $this->grid_attributes[$settingName$value;
  131.     }
  132.     
  133.     /*** jQuery Flexgrid definitions ----------------------------------- */
  134.     
  135.     
  136.     /**
  137.      * returns the jQuery js to init the flexgrid
  138.      *
  139.      * @param int $buttonColPos  0 not show -1 left 1 right
  140.      * @param boolean $debug 
  141.      * 
  142.      * @return string 
  143.      */
  144.     public function getJQueryDefinition($debug=False)
  145.     {
  146.         $str_ret "
  147.             jQuery('#" $this->getGridDOMId()"').flexigrid
  148.             (
  149.             {
  150.             url: '" $this->myControl->getJsonUrl("',
  151.             dataType: 'json'
  152.             ";
  153.         
  154.         $arr_colModel         array();
  155.         $arr_searchItems    array();
  156.         
  157.         $arr_LeftButtons     $this->getPosButtons(-1);
  158.         $arr_RightButtons     $this->getPosButtons(1);
  159.                 
  160.         if (sizeof($arr_LeftButtons))
  161.         {
  162.             $arr_colModel['lst_buttons_left'array(
  163.                     'display'     => "'Aktionen'",
  164.                     'name'          => "'lst_buttons_left'",
  165.                     'sortable'     => "false",
  166.                     'width'        => (sizeof($arr_LeftButtons22),
  167.                     'hide'        => "false"
  168.                 );
  169.         }
  170.         
  171.         if ($arr_fields $this->myForm->getFields(Null,$debug))
  172.         {
  173.             foreach($arr_fields as &$obj_fld)
  174.             {
  175.                 if (!$obj_fld->isHidden('flexgrid'))
  176.                 {
  177.                     $arr_colModel[$obj_fld->getName()array(
  178.                         'display'     => "'" str_replace("'","\\'",$obj_fld->getLstLabel()) "'"
  179.                         'name'          => "'" $obj_fld->getName("'",
  180.                         'sortable'     => ($obj_fld->isSearchable('true' 'false')
  181.                         'width'        => (intval($obj_fld->getLstWidth()) $obj_fld->getLstWidth(($obj_fld->getSize(5)),
  182.                         'hide'         => ($obj_fld->isHidden('list''true' 'false')
  183.                     );
  184.                     
  185.                     if ($obj_fld->isSearchable())
  186.                     {
  187.                         $arr_searchItems[$obj_fld->getName()array(
  188.                             'display'     => "'" $obj_fld->getLstLabel("'"
  189.                             'name'          => "'" $obj_fld->getName("'"                        
  190.                         );
  191.                     }
  192.                 
  193.             }
  194.         }        
  195.  
  196.         if (sizeof($arr_RightButtons))
  197.         {
  198.             $arr_colModel['lst_buttons_right'array(
  199.                     'display'     => "' Aktionen '",
  200.                     'name'          => "'lst_buttons_right'",
  201.                     'sortable'     => "false",
  202.                     'width'        => (sizeof($arr_RightButtons22),
  203.                     'hide'        => "false"
  204.                 );
  205.         }
  206.         
  207.         
  208.         $str_ret .= ",\ncolModel : [";
  209.         $cha_sep "";
  210.         foreach($arr_colModel as $arr_colDesc)
  211.         {
  212.             $str_ret .= "$cha_sep{";
  213.             $cha_sepInner "";
  214.             foreach($arr_colDesc as $str_key => $mix_val)
  215.             {
  216.                 $str_ret .= $cha_sepInner .  $str_key " : " $mix_val;
  217.                 $cha_sepInner ","
  218.             }
  219.             $str_ret .= "}";
  220.             $cha_sep ",";
  221.         }
  222.         $str_ret .= "]";
  223.         
  224.         if (sizeof($arr_searchItems))
  225.         {
  226.             $cha_SISep '';
  227.             $str_ret .= ",\nsearchitems:[";
  228.             foreach($arr_searchItems as $arr_itemDesc)
  229.             {
  230.                 $str_ret .= $cha_SISep "{";
  231.                 $cha_sep '';
  232.                 foreach($arr_itemDesc as $str_key => $mix_val)
  233.                 {
  234.                     $str_ret .= $cha_sep .  $str_key " : " $mix_val;
  235.                     $cha_sep ","
  236.                 }
  237.                 $str_ret .= "}";        
  238.                 $cha_SISep ",";
  239.             }            
  240.             $str_ret .= "]";
  241.         }
  242.         
  243.         /*
  244.             buttons : [
  245.                 {name: 'Add', bclass: 'add', onpress : test},
  246.                 {name: 'Delete', bclass: 'delete', onpress : test},
  247.                 {separator: true}
  248.                 ],
  249.             sortname: "iso",
  250.             sortorder: "asc",
  251.         */
  252.         
  253.         
  254.         foreach($this->grid_attributes as $str_attName => $str_value)
  255.         {
  256.             $str_ret .= "," $str_attName ": " $str_value;
  257.         }        
  258.     
  259.         $str_ret .= "});";
  260.  
  261.         return $str_ret;
  262.     }
  263.     
  264.     /**
  265.      * returns the list HTML code
  266.      * 
  267.      * @param boolean $debug 
  268.      * 
  269.      * @return string 
  270.      */
  271.     function getList($debug=False)
  272.     {  
  273.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_FRMVIEW_LIST::getList()");
  274.         $str_ret "<table id=\"".$this->getGridDOMId(."\"></table>";
  275.         return $str_ret;
  276.     }    
  277.     
  278. }
  279.  
  280. ?>

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