| 1 |
lars |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* TStatements class file
|
|
|
4 |
*
|
|
|
5 |
* @author Qiang Xue <qiang.xue@gmail.com>
|
|
|
6 |
* @link http://www.pradosoft.com/
|
|
|
7 |
* @copyright Copyright © 2005-2008 PradoSoft
|
|
|
8 |
* @license http://www.pradosoft.com/license/
|
|
|
9 |
* @version $Id: TStatements.php 2541 2008-10-21 15:05:13Z qiang.xue $
|
|
|
10 |
* @package System.Web.UI.WebControls
|
|
|
11 |
*/
|
|
|
12 |
|
|
|
13 |
/**
|
|
|
14 |
* TStatements class
|
|
|
15 |
*
|
|
|
16 |
* TStatements executes one or several PHP statements and renders the display
|
|
|
17 |
* generated during the execution. The execution happens during the rendering stage.
|
|
|
18 |
* The PHP statements being executed can be set via the property
|
|
|
19 |
* {@link setStatements Statements}. The context of the statemenets executed
|
|
|
20 |
* is the TStatements object itself.
|
|
|
21 |
*
|
|
|
22 |
* Note, since TStatements allows execution of arbitrary PHP statements,
|
|
|
23 |
* make sure {@link setStatements Statements} does not come directly from user input.
|
|
|
24 |
*
|
|
|
25 |
* @author Qiang Xue <qiang.xue@gmail.com>
|
|
|
26 |
* @version $Id: TStatements.php 2541 2008-10-21 15:05:13Z qiang.xue $
|
|
|
27 |
* @package System.Web.UI.WebControls
|
|
|
28 |
* @since 3.0
|
|
|
29 |
*/
|
|
|
30 |
class TStatements extends TControl
|
|
|
31 |
{
|
|
|
32 |
/**
|
|
|
33 |
* @var string PHP statements
|
|
|
34 |
*/
|
|
|
35 |
private $_s='';
|
|
|
36 |
|
|
|
37 |
/**
|
|
|
38 |
* @return string the statements to be executed
|
|
|
39 |
*/
|
|
|
40 |
public function getStatements()
|
|
|
41 |
{
|
|
|
42 |
return $this->_s;
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
/**
|
|
|
46 |
* @param string the PHP statements to be executed
|
|
|
47 |
*/
|
|
|
48 |
public function setStatements($value)
|
|
|
49 |
{
|
|
|
50 |
$this->_s=$value;
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
/**
|
|
|
54 |
* Renders the evaluation result of the statements.
|
|
|
55 |
* @param THtmlWriter the writer used for the rendering purpose
|
|
|
56 |
*/
|
|
|
57 |
public function render($writer)
|
|
|
58 |
{
|
|
|
59 |
if($this->_s!=='')
|
|
|
60 |
$writer->write($this->evaluateStatements($this->_s));
|
|
|
61 |
}
|
|
|
62 |
}
|
|
|
63 |
|