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

Source for file dbctrls.inc.php

Documentation is available at dbctrls.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("db.inc.php");
  27. use_unit("extctrls.inc.php");
  28.  
  29.  
  30.  
  31. define ('noHorizontal''noHorizontal');
  32. define ('noVertical''noVertical');
  33.  
  34. /**
  35.  * DBPaginator class
  36.  *
  37.  * A control to browse through the records of a datasource.
  38.  */
  39. class DBPaginator extends CustomControl
  40. {
  41.         protected $_datasource = null;
  42.  
  43.         protected $_onclick = null;
  44.  
  45.         protected $_captionfirst = "First";
  46.         protected $_captionprevious = "Prev";
  47.         protected $_captionlast = "Last";
  48.         protected $_captionnext = "Next";
  49.         protected $_orientation = noHorizontal;
  50.         protected $_pagenumberformat="%d";
  51.         protected $_showfirst = 1;
  52.         protected $_showlast = 1;
  53.         protected $_shownext = 1;
  54.         protected $_showprevious = 1;
  55.         protected $_shownrecordscount=10;
  56.  
  57.         private $_currentpos = -1;
  58.  
  59.         function __construct($aowner null)
  60.         {
  61.                 //Calls inherited constructor
  62.                 parent::__construct($aowner);
  63.  
  64.                 $this->Width 300;
  65.                 $this->Height 30;
  66.  
  67.                 $this->ControlStyle="csRenderOwner=1";
  68.                 $this->ControlStyle="csRenderAlso=StyleSheet";
  69.         }
  70.  
  71.         function serialize()
  72.         {
  73.                 parent::serialize();
  74.  
  75.                 $owner $this->readOwner();
  76.                 if ($owner != null)
  77.                 {
  78.                         $prefix $owner->readNamePath().".".$this->_name.".";
  79.                         $_SESSION[$prefix."CurrentPos"$this->_currentpos;
  80.                 }
  81.         }
  82.  
  83.         function unserialize()
  84.         {
  85.                 parent::unserialize();
  86.  
  87.                 $owner $this->readOwner();
  88.                 if ($owner != null)
  89.                 {
  90.                         $prefix $owner->readNamePath().".".$this->_name.".";
  91.                         $this->_currentpos $_SESSION[$prefix."CurrentPos"];
  92.                 }
  93.         }
  94.  
  95.         function loaded()
  96.         {
  97.                 parent::loaded();
  98.                 $this->setDataSource($this->_datasource);
  99.         }
  100.  
  101.         //TODO: can we move that to loaded()? Is the data source ready there?
  102.                 function preinit()
  103.         {
  104.                 parent::preinit();
  105.  
  106.                 // go to last position
  107.                 if ($this->_currentpos 0)
  108.                 {
  109.                         $this->gotoPos($this->_currentpos);
  110.                         /*
  111.                         $ds = $this->_datasource->DataSet;
  112.                         for ($x = 0; $x < $this->_currentpos; $x++)
  113.                         {
  114.                                 $ds->next();
  115.                         }
  116.                         */
  117.                 }
  118.  
  119.                 $submittedValue $this->input->{$this->_name};
  120.  
  121.                 if (is_object($submittedValue&& $this->_datasource != null && $this->_datasource->DataSet != null)
  122.                 {
  123.                         $value $submittedValue->asString();
  124.                         $this->linkClicked($value);
  125.                 }
  126.         }
  127.  
  128.         private function gotoPos($pos)
  129.         {
  130.                 if ($pos >= /*&& $this->_datasource->Dataset->Active*/)
  131.                 {
  132.                         $ds $this->_datasource->DataSet;
  133.                         $ds->First();
  134.                         for ($x 0$x $pos$x++)
  135.                         {
  136.                                 $ds->Next();
  137.                         }
  138.                 }
  139.         }
  140.  
  141.         /**
  142.         * Execute the $action of a clicked link.
  143.         * @param mixed $action This param defines which action should be performed.
  144.         *                       If $action is a string then the matching operation
  145.         *                       on the data set is performed. Currently
  146.         *                       first, prev, next and last are supported.
  147.         *                       If $action is a integer the data set cursor is moved
  148.         *                       to this record.
  149.         */
  150.         protected function linkClicked($action)
  151.         {
  152.                 $ds $this->_datasource->DataSet;
  153.  
  154.                 $val "";
  155.                 // check which link was clicked
  156.                 switch ($action)
  157.                 {
  158.                         // first
  159.                         case "first"$ds->First()$val $action$this->_currentpos 0break;
  160.                         // prev
  161.                         case "prev"/*$ds->Prior();*/ $val $action$this->_currentpos--$this->gotoPos($this->_currentpos)break;
  162.                         // next
  163.                         case "next"$ds->Next()$val $actionif($this->_currentpos $ds->RecordCount-1$this->_currentpos++break;
  164.                         // last
  165.                         case "last"$ds->Last()$val $action$this->_currentpos $ds->RecordCount-1break;
  166.                         default:
  167.                         {
  168.                                 // check if it is a integer
  169.                                 if (is_numeric($action&& intval($action== $action)
  170.                                 {
  171.                                         $val $action-1;
  172.                                         $diff $val $this->_currentpos;
  173.  
  174.                                         if ($diff 0)
  175.                                         {
  176.                                                 $this->gotoPos($val);
  177.                                         }
  178.                                         else
  179.                                         {
  180.                                                 for ($x 0$x abs($diff)$x++)
  181.                                                 {
  182.                                                         $ds->Next();
  183.                                                 }
  184.                                         }
  185.  
  186.                                         // move to the clicked record number
  187.                                         //$ds->MoveBy($val - $this->_currentpos);
  188.                                         $this->_currentpos $val;
  189.                                 }
  190.                         }
  191.                 }
  192.  
  193.                 $this->callEvent('onclick'array("action"$val));
  194.         }
  195.  
  196.         /**
  197.         * Simulates a link click on the database navigator, invoking the action of the link.
  198.         * @param mixed $action This param defines which action should be performed.
  199.         *                       If $action is a string then the matching operation
  200.         *                       on the data set is performed. Currently
  201.         *                       first, prev, next and last are supported.
  202.         *                       If $action is a integer the data set cursor is moved
  203.         *                       to this record.
  204.         */
  205.         public function linkClick($action)
  206.         {
  207.                 $this->linkClicked($action);
  208.         }
  209.  
  210.         /**
  211.         * Returns an array with all record numbers to display.
  212.         * Each record number has following properties:
  213.         * - recordnumber => record number to display
  214.         * - currentrecord => true if current record
  215.         * - first => true if first
  216.         * - last => true if last
  217.         *
  218.         * The returned array looks like this:
  219.         * Array
  220.         * (
  221.         *     [1] => Array
  222.         *         (
  223.         *              [recordnumber] =>
  224.         *              [currentrecord] =>
  225.         *              [first] =>
  226.         *              [last] =>
  227.         *         )
  228.         *     [2] => Array
  229.         *         ( ...
  230.         * @return array Returns an array with all record numbers to display.
  231.         */
  232.         protected function getArrayOfRecordNumbers()
  233.         {
  234.                 $result array();
  235.  
  236.                 if (($this->ControlState csDesigning!= csDesigning)
  237.                 {
  238.                         // check if DS is set and active
  239.                         //TODO: Check if DS is active
  240.                         if ($this->_datasource!=null && $this->_datasource->Dataset!=null && $this->_datasource->Dataset->Active)
  241.                         {
  242.                                 $ds $this->_datasource->DataSet;
  243.                                 $currentRecord $this->_currentpos//$ds->RecNo;
  244.                                 $recordCount $ds->RecordCount;
  245.  
  246.                                 // we want to have the current record number in the center (if possible)
  247.                                 $centeroffset round($this->_shownrecordscount/2);
  248.  
  249.                                 // Calculate the range to show (0 = first; $recordCount-1 = last).
  250.                                 // The first few records (till $centeroffset) are treated differently ($end is $this->_shownrecordscount-1).
  251.                                 if ($currentRecord $centeroffset)
  252.                                 {
  253.                                         // check if record count is lower than $this->_shownrecordscount
  254.                                         // if yes, then $end is $recordCount-1, otherwise $this->_shownrecordscount-1
  255.                                         $end min($recordCount$this->_shownrecordscount)-1;
  256.                                 }
  257.                                 else
  258.                                 {
  259.                                         // $end is either $recordCount-1 or the current record plus the offset ($centeroffset floored is case _shownrecordscount is odd)
  260.                                         $end min($recordCount-1$currentRecord floor($this->_shownrecordscount/2));
  261.                                 }
  262.                                 // go no lower than 0 (first) and always show as many numbers as possible
  263.                                 $start max(0,
  264.                                              $currentRecord max($centeroffset 1,
  265.                                                                   $this->_shownrecordscount - ($end $currentRecord1
  266.                                                                  )
  267.                                             );
  268.  
  269.                                 // add the record numbers to the result array
  270.                                 for ($x $start$x <= $end$x++)
  271.                                 {
  272.                                         // use the real record number as key
  273.                                         $result[$xarray("recordnumber" =>  ($x+1),                     // record index starts at 0, so add 1 to the number to print
  274.                                                             "currentrecord" => ($x == $currentRecord),
  275.                                                             "first" =>         ($x == 0),                  // record index starts at 0
  276.                                                             "last" =>          ($x == $recordCount-1)
  277.                                                            );
  278.                                 }
  279.                         }
  280.                 }
  281.                 // only return dummy values when at design-time
  282.                 else if (($this->ControlState csDesigning== csDesigning)
  283.                 {
  284.                         // let's add some dummy values for design-time
  285.                         for ($x 1$x <= $this->_shownrecordscount$x++)
  286.                         {
  287.                                 // use the real record number (starting at 0) as key
  288.                                 $result[$x-1array("recordnumber" =>  $x,
  289.                                                       "currentrecord" => ($x == 1)// first is current record
  290.                                                       "first" =>         ($x == 1),
  291.                                                       "last" =>          false      // last not reached
  292.                                                      );
  293.                         }
  294.                 }
  295.  
  296.                 return $result;
  297.         }
  298.  
  299.         /**
  300.         * Returns a correctly formatted URL string with the given action.
  301.         * @param string $action Action to include in the URL.
  302.         * @return string URL including the given action. Points to the script where
  303.         *                 the DBNavigator is used.
  304.         */
  305.         protected function dbNavLink($action)
  306.         {
  307.                 $script "";
  308.                 if (isset($_SERVER['PHP_SELF']))
  309.                 {
  310.                         $script basename($_SERVER['PHP_SELF']);
  311.                 }
  312.                 return $script."?".urlencode($this->_name)."=".urlencode($action);
  313.         }
  314.  
  315.         /**
  316.         * Get the contents of one cell (of the table).
  317.         * @param string $caption Caption of the item to add to the cell content.
  318.         * @param string $link Link to wrap arounf the caption.
  319.         * @param string $cellalign The cell align depends on the orientation of the DBNavigator.
  320.         *                           If noVertical it's valign, if noHorizontal it's align.
  321.         * @param bool $enabled Set this argument to enable/disable the link.
  322.         * @return string Returns a string with the cell contents.
  323.         */
  324.         protected function cellContents($caption$link$cellalign$enabled true)
  325.         {
  326.                 $result "";
  327.                 if ($this->_orientation == noVertical)
  328.                 {
  329.                         $result .= "<tr valign=\"$cellalign\">\n";
  330.                         if ($enabled)
  331.                         {
  332.                                 $result .= "  <td align=\"center\"><a href=\"$link\">$caption</a></td>\n";
  333.                         }
  334.                         else
  335.                         {
  336.                                 $result .= "  <td align=\"center\">$caption</td>\n";
  337.                         }
  338.  
  339.                         $result .= "</tr>\n";
  340.                 }
  341.                 else
  342.                 {
  343.                         if ($enabled)
  344.                         {
  345.                                 $result .= "  <td align=\"$cellalign\"><a href=\"$link\">$caption</a></td>\n";
  346.                         }
  347.                         else
  348.                         {
  349.                                 $result .= "  <td align=\"$cellalign\">$caption</td>\n";
  350.                         }
  351.                 }
  352.                 return $result;
  353.         }
  354.  
  355.         function dumpContents()
  356.         {
  357.                 $style="";
  358.                 if ($this->Style=="")
  359.                 {
  360.                         // get the Font attributes
  361.                         $style $this->Font->FontString;
  362.  
  363.                         if ($this->_color != "")
  364.                         {
  365.                                 $style .= "background-color: " $this->_color . ";";
  366.                         }
  367.  
  368.                         // add the cursor to the style
  369.                         if ($this->_cursor != "")
  370.                         {
  371.                                 $cr strtolower(substr($this->_cursor2));
  372.                                 $style .= "cursor$cr;";
  373.                         }
  374.                 }
  375.  
  376.                 if ($style != "")  $style "style=\"$style\"";
  377.  
  378.                 $hint $this->getHintAttribute();
  379.  
  380.                 $class ($this->Style != """class=\"$this->StyleClass\""";
  381.  
  382.                 // call on show here so the output can be influenced
  383.                 $this->callEvent('onshow'array());
  384.  
  385.  
  386.                 // get the contents of the record numbers first
  387.                 $numbersstr "";
  388.                 $cellalign ($this->_orientation == noVertical"middle" "center";
  389.                 $numbers $this->getArrayOfRecordNumbers();
  390.                 foreach ($numbers as $number)
  391.                 {
  392.  
  393.                         $numbersstr .= $this->cellContents(sprintf($this->_pagenumberformat$number['recordnumber']),     // caption of the record number
  394.                                                            $this->dbNavLink($number['recordnumber']),                      // create a link to the record number
  395.                                                            $cellalign,                                                     // align of the
  396.                                                            !(bool)$number['currentrecord']);                               // enable all numbers except the current record
  397.                 }
  398.  
  399.                 $currentRecord = -1;
  400.                 if (($this->ControlState csDesigning!= csDesigning)
  401.                 {
  402.                         //TODO: Check if DS is active 
  403.                         // check if DS is set and active
  404.                         if ($this->_datasource!=null && $this->_datasource->Dataset!=null && $this->_datasource->Dataset->Active)
  405.                         {
  406.                                 $ds $this->_datasource->DataSet;
  407.                                 $currentRecord $this->_currentpos//$ds->RecNo;
  408.                         }
  409.                 }
  410.                 else
  411.                 {
  412.                         // show the first record at design time
  413.                         $currentRecord 0;
  414.                 }
  415.  
  416.                 // check if the first number is shown => disable the first and previous links
  417.                 $firstshown ($currentRecord > -&& array_key_exists($currentRecord$numbers&& $numbers[$currentRecord]['first']);
  418.                 // check if the last number is shown => disable the next and last links
  419.                 $lastshown  ($currentRecord > -&& array_key_exists($currentRecord$numbers&& $numbers[$currentRecord]['last']);
  420.  
  421.                                //echo "first: $firstshown last: $lastshown";
  422.                 echo "<table id=\"{$this->_name}_table\" height=\"$this->_height\" width=\"$this->_width\" cellpadding=\"0\" cellspacing=\"0\" $hint $style $class>\n";
  423.                 if ($this->_orientation == noVertical)
  424.                 {
  425.                         if ($this->_showfirst == 1)
  426.                         {
  427.                                 echo $this->cellContents($this->_captionfirst$this->dbNavLink("first")"top"!$firstshown);
  428.                         }
  429.                         if ($this->_showprevious == 1)
  430.                         {
  431.                                 echo $this->cellContents($this->_captionprevious$this->dbNavLink("prev")"top"!$firstshown);
  432.                         }
  433.  
  434.                         if ($this->_pagenumberformat != ""{
  435.                                 // add the page numbers here...
  436.                                 echo $numbersstr;
  437.                         }
  438.  
  439.                         if ($this->_shownext == 1)
  440.                         {
  441.                                 echo $this->cellContents($this->_captionnext$this->dbNavLink("next")"bottom"!$lastshown);
  442.                         }
  443.                         if ($this->_showlast == 1)
  444.                         {
  445.                                 echo $this->cellContents($this->_captionlast$this->dbNavLink("last")"bottom"!$lastshown);
  446.                         }
  447.                 }
  448.                 else
  449.                 {
  450.                         echo "<tr valign=\"middle\">\n";
  451.  
  452.                         if ($this->_showfirst == 1)
  453.                         {
  454.                                 echo $this->cellContents($this->_captionfirst$this->dbNavLink("first")"left"!$firstshown);
  455.                         }
  456.                         if ($this->_showprevious == 1)
  457.                         {
  458.                                 echo $this->cellContents($this->_captionprevious$this->dbNavLink("prev")"left"!$firstshown);
  459.                         }
  460.  
  461.                         if ($this->_pagenumberformat != ""{
  462.                                 // add the page numbers here...
  463.                                 echo $numbersstr;
  464.                         }
  465.  
  466.                         if ($this->_shownext == 1)
  467.                         {
  468.                                 echo $this->cellContents($this->_captionnext$this->dbNavLink("next")"right"!$lastshown);
  469.                         }
  470.                         if ($this->_showlast == 1)
  471.                         {
  472.                                 echo $this->cellContents($this->_captionlast$this->dbNavLink("last")"right"!$lastshown);
  473.                         }
  474.  
  475.                         echo "</tr>\n";
  476.                 }
  477.                  echo "</table>\n";
  478.         }
  479.  
  480.         /**
  481.         * Occurs when a link on the database navigator is clicked,
  482.         * after the action is executed.
  483.         * It passes the executed action as parameter to the event handler. The
  484.         * name of the parameter is "action".
  485.         */
  486.         function getOnClick() { return $this->_onclick}
  487.         /**
  488.         * Occurs when a link on the database navigator is clicked,
  489.         * after the action is executed.
  490.         * It passes the executed action as parameter to the event handler. The
  491.         * name of the parameter is "action".
  492.         */
  493.         function setOnClick($value) { $this->_onclick=$value}
  494.         function defaultOnClick() { return null; }
  495.  
  496.  
  497.         /**
  498.         * Caption of "First" link. Clicking on this link will show the first record
  499.         * of the datasource.
  500.         * @return string
  501.         */
  502.         function getCaptionFirst() { return $this->_captionfirst}
  503.         function setCaptionFirst($value) { $this->_captionfirst=$value}
  504.         function defaultCaptionFirst() { return "First"; }
  505.  
  506.         /**
  507.         * Caption of "Prev" link. Clicking on this link will show the previous record
  508.         * in regard to the current record of the datasource.
  509.         * @return string
  510.         */
  511.         function getCaptionPrevious() { return $this->_captionprevious}
  512.         function setCaptionPrevious($value) { $this->_captionprevious=$value}
  513.         function defaultCaptionPrevious() { return "Prev"; }
  514.  
  515.         /**
  516.         * Caption of "Next" link. Clicking on this link will show the next record
  517.         * in regard to the current record of the datasource.
  518.         * @return string
  519.         */
  520.         function getCaptionNext() { return $this->_captionnext}
  521.         function setCaptionNext($value) { $this->_captionnext=$value}
  522.         function defaultCaptionNext() { return "Next"; }
  523.  
  524.         /**
  525.         * Caption of "Last" link. Clicking on this link will show the last record
  526.         * of the datasource.
  527.         * @return string
  528.         */
  529.         function getCaptionLast() { return $this->_captionlast}
  530.         function setCaptionLast($value) { $this->_captionlast=$value}
  531.         function defaultCaptionLast() { return "Last"; }
  532.  
  533.         function getColor() { return $this->readColor()}
  534.         function setColor($value) { $this->writeColor($value)}
  535.  
  536.         //DataSource property
  537.         function getDataSource() { return $this->_datasource;   }
  538.         function setDataSource($value)
  539.         {
  540.                 $this->_datasource=$this->fixupProperty($value);
  541.         }
  542.  
  543.         function getFont() { return $this->readFont()}
  544.         function setFont($value) { $this->writeFont($value)}
  545.  
  546.         /**
  547.         * Orientation of the Paginator.
  548.         * @return enum (noHorizontal, noVertical)
  549.         */
  550.         function getOrientation() { return $this->_orientation}
  551.         function setOrientation($value) { $this->_orientation = $value}
  552.         function defaultOrientation() { return noHorizontal; }
  553.  
  554.         /**
  555.         * Format of the page numbers. %d defines the location of the number.
  556.         * @return string
  557.         */
  558.         function getPageNumberFormat() { return $this->_pagenumberformat}
  559.         function setPageNumberFormat($value) { $this->_pagenumberformat=$value}
  560.         function defaultPageNumberFormat() { return "%d"; }
  561.  
  562.         function getParentColor() { return $this->readParentColor()}
  563.         function setParentColor($value) { $this->writeParentColor($value)}
  564.  
  565.         function getParentFont() { return $this->readParentFont()}
  566.         function setParentFont($value) { $this->writeParentFont($value)}
  567.  
  568.         function getShowHint() { return $this->readShowHint()}
  569.         function setShowHint($value) { $this->writeShowHint($value)}
  570.  
  571.         /**
  572.         * Indicates if the "First" link is shown.
  573.         * @return bool
  574.         */
  575.         function getShowFirst() { return $this->_showfirst}
  576.         function setShowFirst($value) { $this->_showfirst=$value}
  577.         function defaultShowFirst() { return 1; }
  578.  
  579.         /**
  580.         * Indicates if the "Last" link is shown.
  581.         * @return bool
  582.         */
  583.         function getShowLast() { return $this->_showlast}
  584.         function setShowLast($value) { $this->_showlast=$value}
  585.         function defaultShowLast() { return 1; }
  586.  
  587.         /**
  588.         * Indicates if the "Next" link is shown.
  589.         * @return bool
  590.         */
  591.         function getShowNext() { return $this->_shownext}
  592.         function setShowNext($value) { $this->_shownext=$value}
  593.         function defaultShowNext() { return 1; }
  594.  
  595.         /**
  596.         * Indicates if the "Prev" link is shown.
  597.         * @return bool
  598.         */
  599.         function getShowPrevious() { return $this->_showprevious}
  600.         function setShowPrevious($value) { $this->_showprevious=$value}
  601.         function defaultShowPrevious() { return 1; }
  602.  
  603.         /**
  604.         * Indicates if the control shows the number of records or not
  605.         * @return boolean
  606.         */
  607.         function getShownRecordsCount() { return $this->_shownrecordscount}
  608.         function setShownRecordsCount($value) { $this->_shownrecordscount=$value}
  609.         function defaultShownRecordsCount() { return 10; }
  610.  
  611.         function getStyle()             { return $this->readstyle()}
  612.         function setStyle($value)       { $this->writestyle($value)}
  613.  
  614.         function getVisible() { return $this->readVisible()}
  615.         function setVisible($value) { $this->writeVisible($value)}
  616.  
  617. }
  618.  
  619. define ('rkHorizontal', 'rkHorizontal');
  620. define ('rkVertical', 'rkVertical');
  621.  
  622. /**
  623.  * A class to iterate througha dataset and repeat controls inside it
  624.  *
  625.  */
  626. class <a href="../VCL/DBRepeater.html">DBRepeater</a> extends <a href="../VCL/Panel.html">Panel</a>
  627. {
  628.             private $_kind=<a href="../VCL/_dbctrls.inc.php.html#definerkVertical">rkVertical</a>;
  629.  
  630.         /**
  631.         * Specifies the orientation of the repeater, horizontal or vertical
  632.         * @return enum
  633.         */
  634.             function getKind() { return $this->_kind; }
  635.             function setKind($value) { $this->_kind=$value; }
  636.             function defaultKind() { return <a href="../VCL/_dbctrls.inc.php.html#definerkVertical">rkVertical</a>; }
  637.  
  638.             private $_restartdataset=true;
  639.  
  640.         /**
  641.         * Specifies if the dataset is restarted or not when beginning to dump code
  642.         * @return boolean
  643.         */
  644.             function getRestartDataset() { return $this->_restartdataset; }
  645.             function setRestartDataset($value) { $this->_restartdataset=$value; }
  646.             function defaultRestartDataset() { return true; }
  647.  
  648.             private $_limit=0;
  649.  
  650.         /**
  651.         * Specifies how many records are going to be shown on the repeater
  652.         * @return integer
  653.         */
  654.             function getLimit() { return $this->_limit; }
  655.             function setLimit($value) { $this->_limit=$value; }
  656.             function defaultLimit() { return 0; }
  657.  
  658.  
  659.         private $_datasource=null;
  660.  
  661.         /**
  662.         * DataSource to attach to this component
  663.         * @return DataSource
  664.         */
  665.         function getDataSource() { return $this->_datasource;   }
  666.         function setDataSource($value)
  667.         {
  668.                 $this->_datasource=$this->fixupProperty($value);
  669.         }
  670.  
  671.         function loaded()
  672.         {
  673.                 parent::loaded();
  674.                 $this->setDataSource($this->_datasource);
  675.         }
  676.  
  677.         function dumpContents()
  678.         {
  679.                 if (($this->ControlState & <a href="../VCL/_classes.inc.php.html#definecsDesigning">csDesigning</a>)==<a href="../VCL/_classes.inc.php.html#definecsDesigning">csDesigning</a>)
  680.                 {
  681.                         parent::dumpContents();
  682.                 }
  683.                 else
  684.                 {
  685.                         if ($this->_datasource!=null)
  686.                         {
  687.                                 if ($this->_datasource->DataSet!=null)
  688.                                 {
  689.                                         $ds=$this->_datasource->DataSet;
  690.  
  691.                                         if ($this->_restartdataset) $ds->first();
  692.  
  693.                                         if (!$ds->EOF)
  694.                                         {
  695.                                                 $class = ($this->Style != "") ? "class=\"$this->StyleClass\""";
  696.  
  697.                                                 echo "<table id=\"{$this->_name}_table\" width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" $class>";
  698.                                                 $render=0;
  699.  
  700.                                                 if ($this->_kind==rkHorizontal) echo "<tr>";
  701.                                                 while (!$ds->EOF)
  702.                                                 {
  703.                                                         if ($this->_kind==<a href="../VCL/_dbctrls.inc.php.html#definerkVertical">rkVertical</a>) echo "<tr>";
  704.                                                         echo "<td>";
  705.                                                         parent::dumpContents();
  706.                                                         echo "</td>";
  707.                                                         if ($this->_kind==<a href="../VCL/_dbctrls.inc.php.html#definerkVertical">rkVertical</a>) echo "</tr>";
  708.                                                         $ds->next();
  709.                                                         $render++;
  710.                                                         if ($this->_limit!=0)
  711.                                                         {
  712.                                                                 if ($render>=$this->_limit) break;
  713.                                                         }
  714.                                                 }
  715.                                                 if ($this->_kind==<a href="../VCL/_dbctrls.inc.php.html#definerkHorizontal">rkHorizontal</a>) echo "</tr>";
  716.                                                 echo "</table>";
  717.                                         }
  718.                                 }
  719.                         }
  720.                 }
  721.         }
  722.  
  723.         function __construct($aowner=null)
  724.         {
  725.                 //Calls inherited constructor
  726.                 parent::__construct($aowner);
  727.  
  728.                 $this->Layout->Type=<a href="../VCL/_graphics.inc.php.html#defineXY_LAYOUT">XY_LAYOUT</a>;
  729.         }
  730. }
  731.  

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