Location: PHPKode > projects > PHP_CON - PHP Design Framework > PHP_CON_OS/exchange/exchangedetail.php
<?PHP
	$rootpath=$_SERVER['DOCUMENT_ROOT'] . "/";
	include_once($rootpath . "common.php");


	$ttem->set_filenames(array("header"=>$rootpath."html_template/header.html"));
	$ttem->set_filenames(array("top_menu"=>$rootpath."html_template/exchange/exchange_menu.html"));
	$ttem->set_filenames(array("body"=>$rootpath."html_template/exchange/exchange_detail.html"));
	if (NSession::check_login()==true)
	{
		$ttem->set_filenames(array("pageleft"=>$rootpath."html_template/left_logined.html"));
	}
	else
	{
		$ttem->set_filenames(array("pageleft"=>$rootpath."html_template/left_login.html"));
	}
	$ttem->set_filenames(array("footer"=>$rootpath."html_template/footer.html"));

	$ttem->assign_var("APP_ROOT", $webappcfg['APPPATH']);


	//echo("<PRE>");
	//print_r($response);
	//echo("</PRE>");

		global $response_log;
		//print_r($response_log);

		$ttem->assign_block_vars("formback", array("REQUEST_URI" => $response_log['loggingobj']->getlogpath()));
		$reqarr = unserialize($response_log['loggingobj']->getrequest());

		foreach($reqarr as $key => $value)
		{
			$ttem->assign_block_vars("formback.inputvar", array(
				"NAME" => $key,
				"VALUE" => $value,
				));
		}

	if (isset($response['sqldata']) && isset($response['sqldata']['exchangeitemdb']))
	{

		if (count($response['sqldata']['exchangeitemdb']) > 0)
		{
			$temp = $response['sqldata']['exchangeitemdb'][0];
			$tempuser = $response['sqldata']['userdb'][0];
			$ttem->assign_var("VAR_ITEMNAME", $temp->getitemname());
			$ttem->assign_var("VAR_VIEWTIMES", $temp->getviewtimes());
			$ttem->assign_var("VAR_POSTTIME", $temp->getposttime());
			$ttem->assign_var("VAR_USERNAME", write_username($tempuser->getusername()));
			$ttem->assign_var("VAR_USERPHOTO", write_photo($tempuser->getid()));
			
			$ttem->assign_var("VAR_AVAQTY", $temp->getavaqty());
			$ttem->assign_var("VAR_LOCATION", $temp->getlocation());
			$ttem->assign_var("VAR_ID", $temp->getid());
			$ttem->assign_var("VAR_USERID", $temp->getuserid());

			if ($temp->getexchangetype()==EX_MONEY)
			{
				$ttem->assign_var("VAR_EXCHANGETYPE", "$" . $temp->getexchangeprice());
			}
			else
				$ttem->assign_var("VAR_EXCHANGETYPE", $temp->getexchangeitem());

			if ($temp->getstatus() == ACTIVE)
			{
				if ($temp->getuserid() != NSession::getuid())
					$ttem->assign_block_vars("exchange_icon", array());
				else
					$ttem->assign_block_vars("owner_exchange", array());
			}
			elseif ($temp->getstatus() == COMPLETED)
			{
				if (isset($response['sqldata']['exchangetouserdb']))
				{
					if (count($response['sqldata']['exchangetouserdb'][0])>0)
					{
						$ttem->assign_var("VAR_GIVE_USERNAME", write_username($response['sqldata']['exchangetouserdb'][0]->getusername()));
						$ttem->assign_block_vars("owner_exchange", array());
					}
				}

				$ttem->assign_block_vars("exchange_result", array());
			}

			$timgobj = $temp->getimgobj();
			if (is_array($timgobj))
			{
				$ttem->assign_var("IMGDATA", "imgdata");
				for ($i = 0; $i < count($timgobj); $i++)
				{
					if (is_file($webappcfg['imgdata'] . "/" . $timgobj[$i]->getimagepath()))
					{
						list($img_width, $img_height) = getimagesize($webappcfg['imgdata'] . "/" . $timgobj[$i]->getimagepath());
						list($img_width, $img_height) = constraintimage($img_width, $img_height, 400, 400);
						$ttem->assign_block_vars("exchange_imagelist", array(
							"VAR_PATH" => $timgobj[$i]->getimagepath(),
							"VAR_WIDTH" => $img_width,
							"VAR_HEIGHT" => $img_height
						));
					}
				}
			}

			if (isset($response['questionmode']))
			{
				for ($i = 0; $i < count($response['sqldata']['exchangequestiondb']); $i++)
				{
					$tempobj = $response['sqldata']['exchangequestiondb'][$i];
					$tempuserobj = $response['sqldata']['questionuserdb'][$i];
					$ttem->assign_block_vars("questionlist", array("COUNT" => ($i+1),
									"QUESTION" => stripslashes($tempobj->getquestion()),
									"ASKTIME" => $tempobj->getasktime(),
									"USERNAME" => write_username($tempuserobj->getusername()),
								));
					if ($temp->getuserid() == NSession::getuid())
					{
						$ttem->assign_block_vars("questionlist.answerform", array(
							"VAR_ANSWER" => $rb['ANSWER'],
							"question_id" => $tempobj->getid()
						));
					}

					$tanswerobj = $tempobj->getanswerobj();
					if (isset($tanswerobj['exchangeanswerdb']) && is_array($tanswerobj['exchangeanswerdb']))
					{
						for ($i_answerobj = 0; $i_answerobj < count($tanswerobj['exchangeanswerdb']); $i_answerobj++)
						{
							$tansobj = $tanswerobj['exchangeanswerdb'][$i_answerobj];
							$ttem->assign_block_vars("questionlist.answerlist", array(
									"COUNT" => ($i_answerobj+1),
									"ANSWER" => $tansobj->getanswer(),
									"ANSWERTIME" => $tansobj->getanswertime(),
								));
						}
					}
				}
				if ($i == 0)
				{
					$ttem->assign_block_vars("emptyanswerlist", array());
				}
			}
			else
				$ttem->assign_var("VAR_DESCRIPTION", nl2br($temp->getdescription()));
		}
	}
	

	assignlang($ttem);

	$ttem->assign_var_from_handle("PAGE_LEFT_MENU", "pageleft");
	$ttem->assign_var_from_handle("PAGE_EXCHANGE_MENU", "top_menu");

	$ttem->pparse("header");
	$ttem->pparse("body");
	$ttem->pparse("footer");
?>
Return current item: PHP_CON - PHP Design Framework