Location: PHPKode > scripts > NabiCI > CI/TaskSeparate.php
<?php
require_once realpath(dirname(__FILE__))."/".('../include/easy_file.php');

/**
 * class TaskSeparate creates the web page for the result of a Task, wich will be separately executed
 *
 * @author Derya Oez
 * @version 1.0
 * @package NabidooCI
 */


class TaskSeparate
{	
	/**
	 * Object of Task
	 * 
	 * @access private
	 * @var Object of Task
	 */
	
	private $taskObject;
	
	/**
	 * the path and at the same time the name of the file which will be created for the result of the task
	 * 
	 * @access private
	 * @var String
	 */
	
	private $link; 
	
	/**
	 * The status of the Loop is depending on running or finish and will be "Current" or "Result"
	 *  
	 * @access private
	 * @var String
	 */
	
	private $loopStatus;
	
	/**
	 * HTML-Code to create a link for the Nabidoo-Project homepage
	 *  
	 * @access private
	 * @var String
	 */
	
	private $linkNab="<a href=http://www.nabidoo.de target=_blank>made with NabiCI by Nabidoo</a>"; 
	
	/**
	 * the link to the "Resultpage" or "Currentpage"
	 *  
	 * @access private
	 * @var String
	 */
	
	/**
	 * function __construct($taskObj,$loopStatus) calls a method to create the web page for the result of the Task
	 *
	 * @access public
	 * @param Object $taskObj
	 * Object of Task
	 * @param string $loopStatus
	 * The status of the loop depending on running or finish loop
	 */

	public function __construct($taskObj,$loopStatus)
	{
		$this->taskObject = $taskObj;
		$this->loopStatus= $loopStatus;
		$this->createTaskResult();
	}

	/**
	 * function createTaskResult()is used to create the web page for a Task, which was executed separately
	 * 
	 * @access private
	 */

	private function createTaskResult()
	{
		$header = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
						<html xmlns=\"http://www.w3.org/1999/xhtml\">
						<head>
						<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8889-1\" />
						<title>NabiCI Continuous Integration Task Result Page</title>
						<link rel=\"stylesheet\" type=\"text/css\" href=\"../../css/styles.css\">
						</head>
						<body>";

		$footer = "</body>
					</html>";
		
		//$task_result_file: the path to the html-file, which is necessary to show the result in the frame of the php-file
		$task_result_file = $this->taskObject->getName()."_result.html";
		//$this->link: the name of the php file which will be created for the result of the task
		$this->link="../../ci_web_pages/".$this->loopStatus."/Separate_Task_Result/".$this->taskObject->getName().".php";

		//$taskResult: source code of the web page
		$taskResult = $header."<table width=100%  border=\"0\" >
								    <tr class=undecorated>
									 <td width=20%><div align=\"left\">".$this->backLink()."</div></td>
									 <td width=60%><h1 align=center> This is the result of Task ".$this->taskObject->getName()."</h1></td>
									 <td width=20%><div align=\"right\">".$this->linkNab."</td>
									</tr>
									<tr>
									 <th></th>
									 <th></th>
									 <th></th>
									</tr>
							   	</table>
								<div align=\"center\">
								<table width=98% border=\"0\">
								 <tr>
									<iframe src=\"".$task_result_file."\"name=\"single_result\" width=\"100%\" height=\"500\"></iframe>
								</tr>"
						.$footer;
	   
		
		//$task_result_file_name: the path to the html-file, which will be created
	   $task_result_file_name = "../../ci_web_pages/".$this->loopStatus."/Separate_Task_Result/".$task_result_file;
	   //create the files
       easy_file::write($task_result_file_name,$this->taskObject->getResult());
       easy_file::write($this->link,$taskResult);
	}

	/**
	 * function getLink() is used to get the path to the 'task result page'
	 * 
	 * @access public
	 * @return String  $this->link
	 * path to the 'task result page'
	 */

	public function getLink()
	{
		return  $this->link;
	}

	/**
	 * function backLink() is used to set a situational "backlink"
	 * 
	 * @access private
	 * @return String $backLink
	 * a situational "backlink"
	 */

	private function backLink()
	{
		if ($this->loopStatus=="Current")
		{
			$backLink = "<a href=../Current.php>Back to the Currentpage</a>";
		}else{
			$backLink = "<a href=../Result.php>Back to the Resultpage</a>";
		}
		return $backLink;
	}
}

?>
Return current item: NabiCI