| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
class CJT_Framework_Html_Dom_Element_Script |
| 7 |
extends CJT_Framework_Html_Dom_Elementbase { |
| 8 |
|
| 9 |
/** |
| 10 |
* put your comment there... |
| 11 |
* |
| 12 |
* @var mixed |
| 13 |
*/ |
| 14 |
protected $vars; |
| 15 |
|
| 16 |
/** |
| 17 |
* put your comment there... |
| 18 |
* |
| 19 |
*/ |
| 20 |
public function __construct() { |
| 21 |
// Create script element. |
| 22 |
parent::__construct('script'); |
| 23 |
// INitialize vars. |
| 24 |
$this->vars = new ArrayObject(array()); |
| 25 |
// INitialize with defauls. |
| 26 |
$this->setType('text/javascript'); |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* put your comment there... |
| 31 |
* |
| 32 |
*/ |
| 33 |
public function __toString() { |
| 34 |
// Set vars. |
| 35 |
$content = ''; |
| 36 |
$vars =& $this->vars(); |
| 37 |
foreach ($vars as $var => $value) { |
| 38 |
$content .= "var {$var}={$value};"; |
| 39 |
} |
| 40 |
$this->setContent($content); |
| 41 |
// Get parent string. |
| 42 |
return parent::__toString(); |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* put your comment there... |
| 47 |
* |
| 48 |
* @param mixed $type |
| 49 |
*/ |
| 50 |
public function & setType($type) { |
| 51 |
// Set type. |
| 52 |
$this->setAttribute('type', $type); |
| 53 |
// chain. |
| 54 |
return $this; |
| 55 |
} |
| 56 |
|
| 57 |
/** |
| 58 |
* put your comment there... |
| 59 |
* |
| 60 |
*/ |
| 61 |
public function & vars() { |
| 62 |
return $this->vars; |
| 63 |
} |
| 64 |
|
| 65 |
} // End class. |
| 66 |
|