src/ets.php
function read_container($container, $parse)
	{
		$this->container = $container = trim($container);
		$this->skip = FALSE;
		// content must be parsed...
		if ($parse != _ETS_TEXT) {
			// null containers are avoid
			if ($this->container === '' || strtoupper($this->container) == 'NULL') {
				return array();
			}
			// check if container is already used
			if ($parse == _ETS_ROOT) {
				if (isset($this->containers[$container])) {
					$this->error(16, 50, "container $container already used");
					return array();
				}
			}
			// cache handlers are available...
			if ($this->external_cache_read && $this->external_cache_write) {
				// the cache exists and is not obsolete
				$fct = $this->cache_read_name;
				if ($envelope = $fct($this->container)) {
					// the cache is a valid envelope
					if (isset($envelope) && $envelope{0} == 'E' && $envelope{1} == 'T' && $envelope{2} == 'S' && $envelope{3} == "\1") {
						$masktree = unserialize(substr($envelope, 4));
						// the envelope contains valid templates
						if ($masktree && is_array($masktree)) {
							$this->containers[$container] = TRUE;
							// the container calls other containers
							if (isset($masktree['0include'])) {
								foreach ($masktree['0include'] as $includedname) {
									$included = $this->read_container($includedname, _ETS_ROOT);
									if ($included === FALSE) {
										$this->error(13, 51, $includedname);
									} else {
										$masktree = $this->masktree_merge($masktree, $included, $includedname);
									}
								}
							}
							return $masktree;
						}
					}
				}
				// refresh the cache
				$content = $this->read_content();
				if ($content === FALSE) {
					return FALSE;
				}
				$this->containers[$container] = TRUE;
				$i = 0;
				$line = 1;
				$temp = strlen($content);
				$masktree = $this->parse($parse, $i, $line, $temp, "$content       ");
				$fct = $this->cache_write_name;
				$fct($this->container, "ETS\1" . serialize($masktree));
				return $masktree;
			// .. or not
			} else {
				$content = $this->read_content();
				if ($content === FALSE) {
					return FALSE;
				}
				$this->containers[$container] = TRUE;
				$i = 0;
				$line = 1;
				return $this->parse(
					$parse,
					$i,
					$line,
					(string) strlen($content),
					"$content       ");
			}
		// .. or not
		} else {
			// null containers are avoid
			if ($this->container === '' || strtoupper($this->container) == 'NULL') {
				return '';
			}
			return $this->read_content();
		}
	}
function read_container($container, $parse)
	{
		$this->container = $container = trim($container);
		$this->skip = FALSE;
		// content must be parsed...
		if ($parse != _ETS_TEXT) {
			// null containers are avoid
			if ($this->container === '' || strtoupper($this->container) == 'NULL') {
				return array();
			}
			// check if container is already used
			if ($parse == _ETS_ROOT) {
				if (isset($this->containers[$container])) {
					$this->error(16, 50, "container $container already used");
					return array();
				}
			}
			// cache handlers are available...
			if ($this->external_cache_read && $this->external_cache_write) {
				// the cache exists and is not obsolete
				$fct = $this->cache_read_name;
				if ($envelope = $fct($this->container)) {
					// the cache is a valid envelope
					if (isset($envelope) && $envelope{0} == 'E' && $envelope{1} == 'T' && $envelope{2} == 'S' && $envelope{3} == "\1") {
						$masktree = unserialize(substr($envelope, 4));
						// the envelope contains valid templates
						if ($masktree && is_array($masktree)) {
							$this->containers[$container] = TRUE;
							// the container calls other containers
							if (isset($masktree['0include'])) {
								foreach ($masktree['0include'] as $includedname) {
									$included = $this->read_container($includedname, _ETS_ROOT);
									if ($included === FALSE) {
										$this->error(13, 51, $includedname);
									} else {
										$masktree = $this->masktree_merge($masktree, $included, $includedname);
									}
								}
							}
							return $masktree;
						}
					}
				}
				// refresh the cache
				$content = $this->read_content();
				if ($content === FALSE) {
					return FALSE;
				}
				$this->containers[$container] = TRUE;
				$i = 0;
				$line = 1;
				$temp = strlen($content);
				$masktree = $this->parse($parse, $i, $line, $temp, "$content       ");
				$fct = $this->cache_write_name;
				$fct($this->container, "ETS\1" . serialize($masktree));
				return $masktree;
			// .. or not
			} else {
				$content = $this->read_content();
				if ($content === FALSE) {
					return FALSE;
				}
				$this->containers[$container] = TRUE;
				$i = 0;
				$line = 1;
				return $this->parse(
					$parse,
					$i,
					$line,
					(string) strlen($content),
					"$content       ");
			}
		// .. or not
		} else {
			// null containers are avoid
			if ($this->container === '' || strtoupper($this->container) == 'NULL') {
				return '';
			}
			return $this->read_content();
		}
	}
function read_container ( $ container , $ parse ) { $ this -> container = $ container = trim ( $ container ) ; $ this -> skip = FALSE ; // content must be parsed... if ( $ parse != _ETS_TEXT ) { // null containers are avoid if ( $ this -> container === '' || strtoupper ( $ this -> container ) == 'NULL' ) { return array ( ) ; } // check if container is already used if ( $ parse == _ETS_ROOT ) { if ( isset ( $ this -> containers [ $ container ] ) ) { $ this -> error ( 16 , 50 , "container $container already used" ) ; return array ( ) ; } } // cache handlers are available... if ( $ this -> external_cache_read && $ this -> external_cache_write ) { // the cache exists and is not obsolete $ fct = $ this -> cache_read_name ; if ( $ envelope = $ fct ( $ this -> container ) ) { // the cache is a valid envelope if ( isset ( $ envelope ) && $ envelope { 0 } == 'E' && $ envelope { 1 } == 'T' && $ envelope { 2 } == 'S' && $ envelope { 3 } == "\1" ) { $ masktree = unserialize ( substr ( $ envelope , 4 ) ) ; // the envelope contains valid templates if ( $ masktree && is_array ( $ masktree ) ) { $ this -> containers [ $ container ] = TRUE ; // the container calls other containers if ( isset ( $ masktree [ '0include' ] ) ) { foreach ( $ masktree [ '0include' ] as $ includedname ) { $ included = $ this -> read_container ( $ includedname , _ETS_ROOT ) ; if ( $ included === FALSE ) { $ this -> error ( 13 , 51 , $ includedname ) ; } else { $ masktree = $ this -> masktree_merge ( $ masktree , $ included , $ includedname ) ; } } } return $ masktree ; } } } // refresh the cache $ content = $ this -> read_content ( ) ; if ( $ content === FALSE ) { return FALSE ; } $ this -> containers [ $ container ] = TRUE ; $ i = 0 ; $ line = 1 ; $ temp = strlen ( $ content ) ; $ masktree = $ this -> parse ( $ parse , $ i , $ line , $ temp , "$content       " ) ; $ fct = $ this -> cache_write_name ; $ fct ( $ this -> container , "ETS\1" . serialize ( $ masktree ) ) ; return $ masktree ; // .. or not } else { $ content = $ this -> read_content ( ) ; if ( $ content === FALSE ) { return FALSE ; } $ this -> containers [ $ container ] = TRUE ; $ i = 0 ; $ line = 1 ; return $ this -> parse ( $ parse , $ i , $ line , ( string ) strlen ( $ content ) , "$content       " ) ; } // .. or not } else { // null containers are avoid if ( $ this -> container === '' || strtoupper ( $ this -> container ) == 'NULL' ) { return '' ; } return $ this -> read_content ( ) ; } }
Return container content or masktree in container content
Return container content or masktree in container content