All pastes #771050 Raw Edit

Someone

public text v1 · immutable
·published 2007-11-12 19:45 UTC
rendered paste body
<?php

class displayMessage {

    var $type = 'error',
		$header,
        $content,
		$style,
		$halt = 0;

	function add($lineStr){
		if(!is_array($this->content)) { 
			$this->content = Array();
		}
		
		array_push($this->content, $lineStr);
	}

	function set($typeStr) {
		$this->type = $typeStr;
	}

    function show(){
		if(!empty($this->content)) {
			$htmlOutput = '<div class="'.strtolower($this->type).'" id="'.strtolower($this->type).'MessageBox" style="'.$this->style.'">';
			
			if(!$this->header) {
				if(strtolower($this->type) == 'error') {
					$htmlOutput .= 'Please review and correct following errors:<ul>';
				} else if(strtolower($this->type) == 'success') {
					$htmlOutput .= 'Your request was successfully processed:<ul>';
				}
			} else {
				$htmlOutput .= $this->header.'<ul>';	
			}
		    foreach($this->content as $messageLine) {
				$htmlOutput .= '<li><img src="/images/icons/'.strtolower($this->type).'.gif" alt="'.ucFirst($this->type).': "> '.ucFirst($messageLine).'</li>';
			} 
			
			$htmlOutput .= '</ul></div>';
			
			return $htmlOutput;
		}
    }
	
	function status() {
		if(!empty($this->content)) {
			return 1;
		} else {
			return 0;	
		}	
	}

	function flush() {
		unset($this->content);
	}
	
	function halt() {
		if($this->halt == '1') {
			$this->halt = 0;
		} else {
			$this->halt = 1;
		}		
	}
}
?>