VCL
[ class tree: VCL ] [ index: VCL ] [ all elements ]

Source for file grids.inc.php

Documentation is available at grids.inc.php

  1. <?php
  2. /**
  3. *  This file is part of the VCL for PHP project
  4. *
  5. *  Copyright (c) 2004-2007 qadram software <support@qadram.com>
  6. *
  7. *  Checkout AUTHORS file for more information on the developers
  8. *
  9. *  This library is free software; you can redistribute it and/or
  10. *  modify it under the terms of the GNU Lesser General Public
  11. *  License as published by the Free Software Foundation; either
  12. *  version 2.1 of the License, or (at your option) any later version.
  13. *
  14. *  This library is distributed in the hope that it will be useful,
  15. *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17. *  Lesser General Public License for more details.
  18. *
  19. *  You should have received a copy of the GNU Lesser General Public
  20. *  License along with this library; if not, write to the Free Software
  21. *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  22. *  USA
  23. *
  24. */
  25.  
  26. use_unit("controls.inc.php");
  27. use_unit("extctrls.inc.php");
  28.  
  29. /**
  30.  * Column class
  31.  *
  32.  * This class represents a grid column
  33.  */
  34. class Column extends Object
  35. {
  36.         protected $_title;
  37.         public $visible=1;
  38.  
  39.         //Title property
  40.         
  41.         function getTitle(return $this->_title;     }
  42.         function setTitle($value$this->_title=$value}                     
  43. }
  44.  
  45. /**
  46.  * Row class
  47.  *
  48.  * This class represents a grid row
  49.  */
  50. class Row extends Object
  51. {
  52.         protected $_height;
  53.         public $values;
  54.  
  55.         //Height property
  56.         
  57.         function getHeight(return $this->_height;   }
  58.         function setHeight($value$this->_height=$value}
  59. }
  60.  
  61. /**
  62.  * CustomGrid class
  63.  *
  64.  * Base class for Grids
  65.  */
  66. class CustomGrid extends CustomControl
  67. {
  68. /*
  69.         public $columns=null;
  70.         public $rows=null;
  71.         protected $_sortable=1;
  72.         protected $_highlightrows=1;
  73.         protected $_showrownumbers=1;
  74.  
  75.         function __construct($aowner=null)
  76.         {
  77.                 //Calls inherited constructor
  78.                 parent::__construct($aowner);
  79.  
  80.                 //Column list
  81.                 $this->columns=new Collection();
  82.                 
  83.                 //Row list
  84.                 $this->rows=new Collection();
  85.  
  86.                 $this->Width=400;
  87.                 $this->Height=200;
  88.         }
  89.  
  90.         function dumpHeaderCode()
  91.         {
  92.                 echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"".VCL_HTTP_PATH."/os3grid/os3grid.css\" />\n";
  93.                 echo "<script src=\"".VCL_HTTP_PATH."/os3grid/os3grid.js\" type=\"text/javascript\"></script>\n";
  94.         }
  95.  
  96.         protected $_jsonrowselect=null;
  97.         function getjsOnRowSelect               () { return $this->_jsonrowselect; }
  98.         function setjsOnRowSelect($value)          { $this->_jsonrowselect=$value; }
  99.         function defaultjsOnRowSelect           () { return ""; }
  100.  
  101.         protected $_jsoncoldisplay=null;
  102.         function getjsOnColDisplay              () { return $this->_jsoncoldisplay; }
  103.         function setjsOnColDisplay($value)          { $this->_jsoncoldisplay=$value; }
  104.         function defaultjsOnColDisplay          () { return ""; }
  105.  
  106.         function dumpRowSelect($event)
  107.         {
  108.                 if ($event!=null)
  109.                 {
  110.                         echo "function $event(grid, row, selected)\n";
  111.                         echo "{\n\n";
  112.                         $this->owner->$event($this, array());
  113.                         echo "\n}\n";
  114.                         echo "\n";
  115.                 }
  116.         }
  117.  
  118.         function dumpColDisplay($event)
  119.         {
  120.                 if ($event!=null)
  121.                 {
  122.                         echo "function $event(grid, col_num, value)\n";
  123.                         echo "{\n\n";
  124.                         $this->owner->$event($this, array());
  125.                         echo "\n}\n";
  126.                         echo "\n";
  127.                 }
  128.         }
  129.  
  130.         function dumpJsEvents()
  131.         {
  132.                 parent::dumpJSEvents();
  133.                 $this->dumpRowSelect($this->_jsonrowselect);
  134.                 $this->dumpColDisplay($this->_jsoncoldisplay);
  135.         }
  136.  
  137.         function dumpContents()
  138.         {
  139.                 $style="";
  140.  
  141.                 $style.="height:".$this->Height."px;width:".$this->Width."px;";
  142.  
  143.                 if ($style!="") $style="style=\"$style\"";
  144.  
  145.  
  146.  
  147.                 echo "<div id=\"".$this->Name."_grid\" $style></div>\n";
  148.                 echo "<script type=\"text/javascript\">\n";
  149. //                echo "function updatecontrol() {\n";
  150. //                echo "alert('updatecontrol');\n";
  151.                 echo "var g = new OS3Grid ();\n";
  152.  
  153.                 $headers="'column1'";
  154.                 if ($this->columns->count()>=1)
  155.                 {
  156.                         $headers='';
  157.                         $c=0;
  158.                         for ($i=0;$i<=$this->columns->count()-1;$i++)
  159.                         {
  160.                                 $column=$this->columns->items[$i];
  161.                                 if ($column->visible)
  162.                                 {
  163.                                         if ($headers!='') $headers.=',';
  164.                                         $text=$column->Title;
  165.                                         $headers.="'$text'";
  166.                                         //echo "g.set_col_editable ( $c, \"txt\" );\n";
  167.                                         $c++;
  168.                                 }
  169.                         }
  170.                 }
  171.                 echo "g.set_headers ( $headers );\n";
  172.                 echo "g.set_scrollbars ( true );\n";
  173.                 echo "g.start_counter = 1;\n";
  174.  
  175.                 if ($this->_jsonrowselect!=null)
  176.                 {
  177.                         $event=$this->_jsonrowselect;
  178.                         echo "g.onrowselect = $event; \n";
  179.                 }
  180.  
  181.                 if ($this->_jsoncoldisplay!=null)
  182.                 {
  183.                         $event=$this->_jsoncoldisplay;
  184.                         echo "g.oncoldisplay = $event; \n";
  185.                 }
  186.  
  187. //                echo "g.set_row_select ( true );\n";
  188.  
  189.                 echo "g.set_border ( 1, \"solid\", \"#cccccc\" );\n";
  190.                 echo "g.set_sortable(".$this->_sortable.");\n";
  191. //                echo "g.set_highlight(".$this->_highlightrows.");\n";
  192. //                echo "g.show_row_num(".$this->showrownumbers.");\n";
  193.  
  194.                 if ($this->rows->count()>=1)
  195.                 {
  196.                 for ($k=0;$k<=$this->rows->count()-1;$k++)
  197.                 {
  198.                         $row=$this->rows->items[$k];
  199.                         $rowvalues="";
  200.                         for ($i=0;$i<=$this->columns->count()-1;$i++)
  201.                         {
  202.                                 $column=$this->columns->items[$i];
  203.                                 if ($column->visible)
  204.                                 {
  205.                                         if ($rowvalues!="") $rowvalues.=",";
  206.                                         $text=$row->values[$i];
  207.                                         $text=str_replace("\n",'\n',$text);
  208.                                         $text=str_replace("\r",'',$text);
  209.                                         $text=str_replace("'","\\'",$text);
  210.                                         $rowvalues.="'$text'";
  211.                                 }
  212.                         }
  213.                         echo "g.add_row ( $rowvalues );\n";
  214.                 }
  215.                 }
  216.                 else
  217.                 {
  218.                                 // echo "alert('no values');\n";
  219.                         echo "g.add_row ( 'value' );\n";
  220.                 }
  221.  
  222.                 echo "g.render ( '".$this->Name."_grid' );\n";
  223. //                echo "}\n";
  224. //                echo "updatecontrol();\n";
  225.                 echo "</script>\n";
  226.         }
  227.  
  228.         //Sortable property
  229.         function getSortable() { return $this->_sortable;   }
  230.         function setSortable($value) { $this->_sortable=$value; }
  231.  
  232.         //HighLightRows property
  233.         function getHighLightRows() { return $this->_highlightrows;   }
  234.         function setHighLightRows($value) { $this->_highlightrows=$value; }
  235.  
  236.         //ShowRowNumbers property
  237.         function getShowRowNumbers() { return $this->_showrownumbers;   }
  238.         function setShowRowNumbers($value) { $this->_showrownumbers=$value; }
  239. */
  240. }
  241.  
  242.  
  243. /**
  244.  * Not working yet
  245.  *
  246.  */
  247.  /*
  248. class StringGrid extends ListView
  249. {
  250. }
  251. */
  252.  
  253. ?>

Documentation generated on Tue, 27 Mar 2007 13:35:06 +0200 by phpDocumentor 1.3.1