// this file is called when viewing individual trip pages
# PROD
include "./ra-content/config.php";
include "$function_dir/functions/user.inc.php";
include "./ra-content/modules.php";
require_once($_SERVER['DOCUMENT_ROOT']."/_includes/dbconnection.php"); // establish a persistent connection to db
require_once($_SERVER['DOCUMENT_ROOT']."/_includes/commonutils.php");
// if a tab other than currently open is requested, then pass the default selection parameters for that tab
// passing empty string will eventually cause /ra-content/plug-ins/yelp-api-data/getYelpData.php to use all the filters for that page
// also, we would like to reset the filters on page load not coming from pagination
// links coming from pagination will have GET query parameter ?paging=1
if (($_SESSION['tab'] != $_GET['tab']) || ( ! isset($_GET['paging']))){
$_SESSION['roadTripYelpFilters'] = '';
}
$rhTemplateType = "trip";
// $vars['g'] is $_GET
$itemID = $vars['g']['i']; // 'i' is itable2.id, trip id
$collectID = $vars['g']['c']; // 'c' is the id, stored as itable2.field3, ? collection id
$meta = itemMeta($itemID, $collectID);
item_redirect($_SERVER['REQUEST_URI'], $itemID, $collectID);
getPermissions("i:view:$collectID");
$item = getItemInfo($itemID, $collectID);
$actionArray = itemActions($itemID, $collectID);
$tagArray = getItemTags($itemID, $collectID);
$reviewArray = reviewTypeArray($collectID);
$breadCrumbCode = $item['b'];
$recArray = itemRecommend($collectID, $itemID);
$itemDisplay = getItemDisplay($itemID); // get display value of roadtrip
if (is_array($actionArray)){$actionCode = implode(" | ", $actionArray);}
if (is_array($breadCrumbCode)){$breadCrumbCode = implode("
", $item['b']) . "
";}
if (is_array($tagArray)){
$tagCode .= '
Tags
';
$tagCode .= parseTagCloud($tagArray, $collectID, 10, 18);
}
//////// START CODE FOR RHOMBUS (BK)
if(isset($item['i']['ca'][102]['content']))
{
$allRoutesArray;
$responseJSON = "";
$clean_routeID = GetSQLValueString($item['i']['ca'][102]['content'], "text");
$internal_routeID = $item['i']['ca'][102]['content'];
mysql_select_db($database_roadtrip_connect, $roadtrip_connect) or die("Unable to connect to roadtrip database.");
// GET THE INFO
$query_specificRoute = sprintf("SELECT * FROM mapIndex WHERE external_trip_id = %s LIMIT 1", $clean_routeID);
$specificRoute = mysql_query($query_specificRoute, $roadtrip_connect) or die(mysql_error);
$row_specificRoute = mysql_fetch_assoc($specificRoute);
$totalRows_specificRoute = mysql_num_rows($specificRoute);
if($totalRows_specificRoute == 1)
{
$storedMap = $row_specificRoute['external_trip_id'];
}
$query_autoWaypoints = sprintf("SELECT * FROM autoPoints WHERE external_trip_id = %s ORDER BY auto_order ASC", $clean_routeID);
$autoWaypoints = mysql_query($query_autoWaypoints, $roadtrip_connect) or die(mysql_error);
$row_autoWaypoints = mysql_fetch_assoc($autoWaypoints);
$totalRows_autoWaypoints = mysql_num_rows($autoWaypoints);
$routeDistance = $row_specificRoute['distance'];
$routeQuicklink = $row_specificRoute['external_ql_id'];
$routeActive = $row_specificRoute['active'];
$routeApproved = $row_specificRoute['approved'];
$routeFlagged = $row_specificRoute['flagged'];
$routeAutopoints = array();
$swLat = NULL;
$swLon = NULL;
$neLat = NULL;
$neLon = NULL;
do{
$autoPoint = NULL;
if($swLat == NULL || $row_autoWaypoints['auto_latitude'] < $swLat) $swLat = $row_autoWaypoints['auto_latitude'];
else if($neLat == NULL || $row_autoWaypoints['auto_latitude'] > $neLat) $neLat = $row_autoWaypoints['auto_latitude'];
if($swLon == NULL || $row_autoWaypoints['auto_longitude'] < $swLon) $swLon = $row_autoWaypoints['auto_longitude'];
else if($neLon == NULL || $row_autoWaypoints['auto_longitude'] > $neLon) $neLon = $row_autoWaypoints['auto_longitude'];
$autoPoint->lat = $row_autoWaypoints['auto_latitude'];
$autoPoint->lng = $row_autoWaypoints['auto_longitude'];
array_push($routeAutopoints, $autoPoint);
//$routeAutopoints(".$row_autoWaypoints['auto_latitude'].",".$row_autoWaypoints['auto_longitude']."));\n";
} while($row_autoWaypoints = mysql_fetch_assoc($autoWaypoints));
}
if($routeActive == 1)
{
}
//////// END CODE FOR RHOMBUS
// code for tabs in design, and pagination for results
// extract GET data
$tab = isset($_GET['tab']) ? $_GET['tab'] : ROAD_TRIP_PAGE_DEFAULT_TAB_NUMBER_TO_OPEN ; // using numbers instead of text to keep tabs general
if (isset($_GET['pageno'])){
$page = $_GET['pageno'];
}
else if (isset($_GET['page'])){
$page = $_GET['page'];
}
else{
$page = PAGINATION_DEFAULT_PAGE_NUMBER;
}
// debug
/*
echo './trip.php';
var_dump($_GET);
var_dump($page);
exit;
*/
// sanitise tab requested
if ( ! (($tab == '1') || ($tab == '2') || ($tab == '3') || ($tab == '4') || ($tab == '5')) ){
$tab = ROAD_TRIP_PAGE_DEFAULT_TAB_NUMBER_TO_OPEN;
}
// sanitise page number requested
if( ! preg_match('/^\d+$/', $page)) {
$page = PAGINATION_DEFAULT_PAGE_NUMBER;
}
// set page number and tab in SESSION for use in ./ra-content/plug-ins/yelp-api-data/
// routeId, start stop locations, etc will be set in SESSION after sanitisation in ./ra-content/templates//header.php
$_SESSION['pageno'] = $page;
$_SESSION['tab'] = $tab;
ob_start();
echo helpfulnessAjax();
include "./ra-content/templates/$templateDir/trip.php";
$pageHTML = ob_get_contents();
ob_end_clean();
include "./ra-content/templates/$templateDir/header.php";
echo $pageHTML;
include "./ra-content/templates/$templateDir/footer.php";
?>