src/tools/Image.php
function restore($state=1) {
		$fw=Base::instance();
		if ($this->flag && is_file($file=($path=$fw->get('TEMP').
			$fw->hash($fw->get('ROOT').$fw->get('BASE')).'.'.
			$fw->hash($this->file).'-').$state.'.png')) {
			if (is_resource($this->data))
				imagedestroy($this->data);
			$this->data=imagecreatefromstring($fw->read($file));
			imagesavealpha($this->data,TRUE);
			foreach (glob($path.'*.png',GLOB_NOSORT) as $match)
				if (preg_match('/-(\d+)\.png/',$match,$parts) &&
					$parts[1]>$state)
					@unlink($match);
			$this->count=$state;
		}
		return $this;
	}
function restore($state=1) {
		$fw=Base::instance();
		if ($this->flag && is_file($file=($path=$fw->get('TEMP').
			$fw->hash($fw->get('ROOT').$fw->get('BASE')).'.'.
			$fw->hash($this->file).'-').$state.'.png')) {
			if (is_resource($this->data))
				imagedestroy($this->data);
			$this->data=imagecreatefromstring($fw->read($file));
			imagesavealpha($this->data,TRUE);
			foreach (glob($path.'*.png',GLOB_NOSORT) as $match)
				if (preg_match('/-(\d+)\.png/',$match,$parts) &&
					$parts[1]>$state)
					@unlink($match);
			$this->count=$state;
		}
		return $this;
	}
function restore ( $ state = 1 ) { $ fw = Base :: instance ( ) ; if ( $ this -> flag && is_file ( $ file = ( $ path = $ fw -> get ( 'TEMP' ) . $ fw -> hash ( $ fw -> get ( 'ROOT' ) . $ fw -> get ( 'BASE' ) ) . '.' . $ fw -> hash ( $ this -> file ) . '-' ) . $ state . '.png' ) ) { if ( is_resource ( $ this -> data ) ) imagedestroy ( $ this -> data ) ; $ this -> data = imagecreatefromstring ( $ fw -> read ( $ file ) ) ; imagesavealpha ( $ this -> data , TRUE ) ; foreach ( glob ( $ path . '*.png' , GLOB_NOSORT ) as $ match ) if ( preg_match ( '/-(\d+)\.png/' , $ match , $ parts ) && $ parts [ 1 ] > $ state ) @ unlink ( $ match ) ; $ this -> count = $ state ; } return $ this ; }
Revert to specified state
@return object
@param $state int
Revert to specified state