PDA

View Full Version : A somewhat simple javascript command that my script just wont agree with!! AHHHH!! lo



mrmason
15 Apr 2011, 04:53 PM
Hi, i am new to this forum but have been meaning to join for a while to offer and recieve help, as it happens i need the latter of those first. so here goes, i've been doing a bit of code editing for a friend who has a site which is structured with html pages calling to a main php server command page if that makes sense, now this has been passed around multiple coders in the past who have lef tthere own litle mark onit in one way or another. Now the problem i'm having is this...

Usually when this page calls to the server for the template page to display an uploaded image it shows the image or icon whilst being an active js link which opens up in a 400x400 window. Now i cant implement this js new window script into the php as it keeps screwing the site up and chucking me erros. can anyone take a look at a working version and the non working version for me and give me a tiny bit of advice... i would really appreciate it, im sure its a simple solution but the simplest are usually the last thing you think of in my case :)

This is the section:

if(in_array($ext, $otherTypes)){ // if not image then display link to doc with icon
$icon = getIcon($ext);
$fsize = getSize($enquiry['enquiry_Image']);
$filename = $enquiry['enquiry_Image'];

$OpenImage = $icon . ' <br /><br /><br /><br />

<a href="uploads/'.$enquiry['enquiry_Image'].'" title="View Document" target="_blank" style="color:#999; font-size:8px;" >Click To View</a>';

}else{ // otherwise display the image and pop-up

$popUpImg = "openImageNews('" . UPLOAD_DIR . $enquiry['enquiry_Image'] . "', '600', '400'); " ;

$OpenImage = '<img width="310" border="0" src="'.UPLOAD_DIR . $enquiry['enquiry_Image'].'" />';
}
}

This is the line:

$OpenImage = '<img width="310" border="0" src="'.UPLOAD_DIR . $enquiry['enquiry_Image'].'" />';
}
}

This is the page that the problem occurs in:


$enquiry = get_enquiry_details($eid);
if(empty($enquiry))
return "The enquiry does not exist";

$details = new XTemplate('templates/biz_my_enquiry_detail.html');
foreach ($enquiry as $k => $v) {
if($k == 'enquiry_description')
$v = nl2br($v);

$details->assign($k, $v);
}
$OpenImage ="";
if($enquiry["enquiry_Image"] !="")
{
$ext = strtolower(substr(strrchr($enquiry['enquiry_Image'], '.'), 1));

if(in_array($ext, $otherTypes)){ // if not image then display link to doc with icon
$icon = getIcon($ext);
$fsize = getSize($enquiry['enquiry_Image']);
$filename = $enquiry['enquiry_Image'];

$OpenImage = $icon . ' <br /><br /><br /><br />

<a href="uploads/'.$enquiry['enquiry_Image'].'" title="View Document" target="_blank" style="color:#999; font-size:8px;" >Click To View</a>';

}else{ // otherwise display the image and pop-up

$popUpImg = "openImageNews('" . UPLOAD_DIR . $enquiry['enquiry_Image'] . "', '600', '400'); " ;

$OpenImage = '<img width="310" border="0" src="'.UPLOAD_DIR . $enquiry['enquiry_Image'].'" />';
}
}

//++if have enquiry attach
$check_enquiry_attached = hasEnquiryAttachedDeatail($eid);
if ($check_enquiry_attached)
{
$details->assign("enquiry_id", $eid);
$details->parse("main.enquiry_attach");
}
//--


$details->assign("buz_goback_url",$buz_goback_url);
$details->assign("Image",$OpenImage);
$details->assign('eid', $eid);
$details->assign('msg', "<br />".$msg."<br />");

if(!$enquiry['enquiry_status'])
{
$details->parse('main.management');
}
else
{
$details->parse('main.no_management');
}

$details->assign('title', $title);
$details->parse('main');

return $details->text('main');
}

/**
* Copy from biz_my_enquiry_detail()
*
* @param sting $msg
* @return string
*/
function infor_of_the_enquiry()
{
global $db, $user, $title, $extra_header;

$title = 'Enquiry Details';
$buz_goback_url = "http://" . READ_SESSION("currentURI");

$eid = (int) $_GET['id'];
if(!$eid)
return "Don't misuse the site";

$extra_header .= <<<EOF



And FINALLY this is the page where the link feature works properly (i will include the exact line underneath this):



$enquiry = get_buz_enquiry_details($eid);

if(empty($enquiry))
return "The enquiry does not exist";

$details = new XTemplate('templates/biz_enquiry_details.html');
foreach ($enquiry as $k => $v) {
if($k == 'enquiry_description')
$v = nl2br($v);

$details->assign($k, $v);
}
if ($enquiry['enquiry_Image'])
{
$ext = strtolower(substr(strrchr($enquiry['enquiry_Image'], '.'), 1));

if(in_array($ext, $otherTypes)){ // if not image then display link to doc with icon
$icon = getIcon($ext);
$fsize = getSize($enquiry['enquiry_Image']);
$filename = $enquiry['enquiry_Image'];

$enquiry['enquiry_Image'] = $icon . ' <br /><br /><br /><br />

<a href="uploads/'.$enquiry['enquiry_Image'].'" title="View Document" target="_blank" style="color:#999; font-size:8px;" >Click To View</a>';

}else{ // otherwise display the image and pop-up
if (file_exists(UPLOAD_DIR."thumb_0_".$enquiry['enquiry_Image']))
{
$enquiry['enquiry_Image'] = "<a href=\"javascript:void(0);\" style=\"color:#999; font-size:8px;\" title=\"Enlarge this image\" onclick=\"openwin('uploads_image_viewer.php?img=".$enquiry['enquiry_Image']."&path=uploads','',400,400)\">"
.'<img src="img/icons/IMG.gif" border="0" width="47" height="60px" /><br />
&nbsp;Click To View'."</a>";
}
else
{
if (file_exists(UPLOAD_DIR.$enquiry['enquiry_Image']))
{
$enquiry['enquiry_Image'] = "<a href=\"javascript:void(0);\" title=\"Enlarge this image\" onclick=\"openwin('uploads_image_viewer.php?img=".$enquiry['enquiry_Image']."&path=uploads','',400,400)\">"
.'<img src="uploads/"'.$enquiry['enquiry_Image'].'" border="0" width="90" />'."</a><br />
<a href=\"javascript:void(0);\" title=\"Enlarge this image\" onclick=\"openwin('uploads_image_viewer.php?img=".$enquiry['enquiry_Image']."&path=uploads','',400,400)\">
<span style=\"color:#0000ff;padding-left:0px;font-size:10px;\">Enlarge Image</span>
</a>";
}
else
{
$enquiry['enquiry_Image'] = " ";
}
}
}
}
else
{
$enquiry['enquiry_Image'] = " ";
}
$OpenImage = $enquiry['enquiry_Image'];
$details->assign("Image",$OpenImage);
if($enquiry['consumer_type'] == 'consumer')
$details->parse('main.consumer_part');

$no_post_quote = no_post_quote($eid);

// If I have posted quote for this enquiry, show it
$quote = get_my_quote($eid);
if(!empty($quote)) {
foreach ($quote as $k => $v) {
$details->assign($k, $v);
}
$details->parse('main.my_quote');
}


if(!$no_post_quote)
{
if (empty($quote)){
$details->assign("q_button", "buz_send_quote" );
}else{
$details->assign("q_button", "buz_update" );
}
$details->assign("buz_goback_url", $buz_goback_url);
$details->parse('main.post_quote');
}
else
{
$details->assign('reason', $no_post_quote);
$details->assign("buz_goback_url", $buz_goback_url);
$details->parse('main.no_post_quote');
$details->parse('main.goback');
}



//++if have enquiry attach
$check_enquiry_attached = hasEnquiryAttachedDeatail($eid);
if ($check_enquiry_attached)
{
$details->assign("enquiry_id", $eid);
$details->parse("main.enquiry_attach");
}
//--


$details->assign("title", $title);
$details->parse('main');

$db->query("UPDATE emg_enquiry_status SET status_value = 1, ad_value = 0 WHERE business_username = '{$user['name']}' AND enquiry_id = $eid");

return $details->text('main');
}

function biz_my_enquiry_detail($msg='')
{
global $db, $user, $title, $extra_header, $otherTypes;

$title = 'Enquiry Details';
$buz_goback_url = "http://" . READ_SESSION("currentURI");

$eid = (int) $_GET['id'];
if(!$eid)
return "Don't misuse the site";

$extra_header .= <<<EOF

<script type='text/javascript'>
var eid = $eid
var addMoreShown = 0
</script>
EOF;

Here is the working line:

$enquiry['enquiry_Image'] = "<a href=\"javascript:void(0);\" title=\"Enlarge this image\" onclick=\"openwin('uploads_image_viewer.php?img=".$enquiry['enquiry_Image']."&path=uploads','',400,400)\">"
.'<img src="uploads/"'.$enquiry['enquiry_Image'].'" border="0" width="90" />'."</a><br />
<a href=\"javascript:void(0);\" title=\"Enlarge this image\" onclick=\"openwin('uploads_image_viewer.php?img=".$enquiry['enquiry_Image']."&path=uploads','',400,400)\">
<span style=\"color:#0000ff;padding-left:0px;font-size:10px;\">Enlarge Image</span>
</a>";

Thankyou for any comments... unless there nasty :D