2 //define("TAG", "LinkClass");
4 * Clase para crear objetos de NODOS DE TEXTO para elementos del DOM, utiles para insertar texto 'innerHTML' dentro de los
7 class DOM_textNode extends DOM_element {
10 protected $TYPE = "textNode";
11 protected $DESC = "inline DOM text element";
13 //APERTURA Y CIERRE DE ETIQUETAS DE ELEMENTO DOM. (algunos elementos autocontendidos (como '<img />') pueden modificarlas o
14 //incluso anularlas) */
15 protected $OPEN_TAG_LEFT="";
16 protected $OPEN_TAG_RIGHT="";
17 protected $CLOSE_TAG_LEFT="";
18 protected $CLOSE_TAG_RIGHT="";
22 * Texto que contiene este elemento.
25 //----------------- BEGIN: SINGLETON --------------------
27 * PATRON ESTATICO SINGLETON
31 protected static $instance;
34 * PATRON SINGLETON. Tomar una instancia de forma estatica.<br />
35 * <code>$txt = DOM_textNode::getInstance();</code>
37 public static function getInstance() {
38 //if (!isset(self::$instance)) {
39 if (is_null(self::$instance)) {
40 $c = __CLASS__; //self::TAG
42 self::$instance = new $c();
44 return self::$instance;
46 //private function setInstance() {
47 //self::$instance=$this;
49 //----------------- END: SINGLETON --------------------
52 public function __construct($key=null){
53 if($key != null) $this->_key=$key;
54 self::$instance=$this;
57 public static function __set_state($an_array) // A partir de PHP 5.1.0
59 return parent::__set_state($an_array);
63 //OVERRIDE: se sobreescribe porque le afecta a __toString();
64 public function getOpenTag(){
65 return ($this->OPEN_TAG_LEFT . /*$this->TAG . parent::getAttribsStr() .*/ $this->OPEN_TAG_RIGHT);
68 //OVERRIDE: se sobreescribe porque es distinto, para no crear un bucle infinito;
70 * Metodo para establecer el texto de este elemento DOM.
71 * @param string $text para este elemento.
72 * @return string con el texto anterior.
74 public function setText($text){
77 $this->tryingWrite("[".$this->_key."]".$this->TAG);
78 $textoAnterior=$this->_text;
79 $this->_text=addslashes( htmlspecialchars( $text ) );
80 //$this->_text=addslashes( htmlspecialchars( $text, ENT_NOQUOTES ) );
81 //$this->_text= $text ;
82 //parent::setText($text); //NO ACTIVAR PROVOCA BUCLE INFINITO!!
84 $this->writeLog($e->getMessage(), $e->getTrace());
86 //return $textoAnterior;