All pastes #1702849 Raw Edit

Open Realty Lightbox Addon

public php v1 · immutable
#1702849 ·published 2009-12-05 09:03 UTC
rendered paste body
<?PHP/**Lightbox Listing Images AddonBY: Phyrax Designs@: http://www.phyrax.comThis work is licensed under the Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/us/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.**/function listingImages_install_addon(){	$current_version = "0.1";	global $conn, $config;	require_once($config['basepath'].'/include/misc.inc.php');	$misc = new Misc();	//Check Current Installed Version	$sql = 'SELECT addons_version FROM '.$config['table_prefix_no_lang'].'addons WHERE addons_name = \'listingImages\'';	$recordSet = $conn->Execute($sql);	$version = $recordSet->fields[0];	if ($version == '') 	{		// Preform a new install. Create any needed databases etc, and insert version number into addon table.		$sql = 'INSERT INTO '.$config['table_prefix_no_lang'].'addons (addons_version, addons_name) VALUES (\'' . $current_version . '\',\'listingImages\')';		$recordSet = $conn->Execute($sql);				return TRUE; 	}	elseif ($version != $current_version)	{		//Preform Updates to database based on previous installed version.		switch($version)		{			case '0':				break;		} // switch		return TRUE;	}	return FALSE;}function listingImages_uninstall_tables(){	global $conn, $config;	require_once($config['basepath'] . '/include/misc.inc.php');	$misc = new Misc();	$sql_uninstall[] = "DELETE FROM " . $config['table_prefix_no_lang'] . "addons	WHERE addons_name ='listingImages'";	foreach($sql_uninstall as $elementContents) {		$recordSet = $conn->Execute($elementContents);		if ($recordSet === false) {			echo "<strong><span style=\"red\">ERROR -			$elementContents</span></strong><br />";			return FALSE;		} else {			return TRUE;		}	}}function listingImages_show_admin_icons(){	$admin_link='';	return $admin_link;}function listingImages_load_template(){	$template_array = array('addon_listingImages_yes','addon_listingImages_no');	return $template_array;} function listingImages_run_action_user_template(){	$data='';	return $data;} function listingImages_run_action_admin_template(){	$data='';	return $data;}function listingImages_run_template_user_fields($tag = ''){	switch ($tag) {		case 'addon_listingImages_yes':			$data = listingImages("yes");			break;		case 'addon_listingImages_no':			$data = listingImages("no");		default:			$data = '';			break;	} // End switch ($_GET['action'])	return $data;} function listingImages_data_addon_link(){	$data='';	return $data;}function listingImages($showcap){	// shows the images connected to a given image	global $conn, $lang, $config;	require_once($config['basepath'] . '/include/misc.inc.php');	require_once($config['basepath'] . '/include/images.inc.php');	$misc = new misc();	$listingID=@$_GET['listingID'];	// grab the images	$sql = "SELECT listingsimages_id, listingsimages_description, listingsimages_file_name listingsimages_thumb_file_name FROM " . $config['table_prefix'] . "listingsimages WHERE (listingsdb_id = ".$listingID.") ORDER BY listingsimages_rank";	$recordSet = $conn->Execute($sql);	if ($recordSet === false) {		$misc->log_error($sql);	}	$display = "";	$num_images = $recordSet->RecordCount();	if ($num_images > 0) {		while(!$recordSet->EOF) {			$file_name = $misc->make_db_unsafe ($recordSet->fields['listingsimages_file_name']);			$title = $misc->make_db_unsafe ($recordSet->fields['listingsimages_description']);			$thumb_file_name = $misc->make_db_unsafe ($recordSet->fields['listingsimages_thumb_file_name']);			if($showcap == strtolower("yes")){				$data .= "<strong>$lang[images]</strong><br /><hr style=\"width:75%;\" />";			}			if ($thumb_file_name != "" && file_exists($config['listings_upload_path'].'/'.$thumb_file_name)) {				$thumb_imagedata = GetImageSize($config['listings_upload_path'].'/'.$thumb_file_name);				$thumb_imagewidth = $thumb_imagedata[0];				$thumb_imageheight = $thumb_imagedata[1];				$thumb_max_width = $config['thumbnail_width'];				$thumb_max_height = $config['thumbnail_height'];				$resize_by = $config['resize_thumb_by'];				$shrinkage = 1;				if (($thumb_max_width == $thumb_imagewidth) || ($thumb_max_height == $thumb_imageheight)) {					$thumb_datawidth = $thumb_imagewidth;					$thumb_dataheight = $thumb_imageheight;				} else {					if ($resize_by == 'width') {						$shrinkage = $thumb_imagewidth / $thumb_max_width;						$thumb_datawidth = $thumb_max_width;						$thumb_dataheight = round($thumb_imageheight / $shrinkage);					} elseif ($resize_by == 'height') {						$shrinkage = $thumb_imageheight / $thumb_max_height;						$thumb_dataheight = $thumb_max_height;						$thumb_datawidth = round($thumb_imagewidth / $shrinkage);					} elseif ($resize_by == 'both') {						$thumb_dataheight = $thumb_max_height;						$thumb_datawidth = $thumb_max_width;					}				}				$display .= '<a href="'.$config['listings_upload_path'].'/'.$file_name.'" rel="lightbox['.$imageID.']" title="'.$title.'">';				$display .= "<img src=\"$config[listings_view_images_path]/$thumb_file_name\" height=\"$thumb_dataheight\" width=\"$thumb_datawidth\" alt=\"$thumb_file_name\" /></a><br /> ";			} // end if ($thumb_file_name != "")			$recordSet->MoveNext();		} // end while		// $data .= "</td>";	} // end if ($num_images > 0)	else {		if ($config['show_no_photo'] == 1) {			$display .= "<img src=\"$config[baseurl]/images/nophoto.gif\" width=\"$config[thumbnail_width]\" alt=\"$lang[no_photo]\" /><br /> ";		}	}	//var_export($data);	return $display;} // end function listingImages?>