<?php require_once('../Connections/telmanik_press.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$currentPage = $_SERVER["PHP_SELF"];

$maxRows_photos = 10;
$pageNum_photos = 0;
if (isset($_GET['pageNum_photos'])) {
  $pageNum_photos = $_GET['pageNum_photos'];
}
$startRow_photos = $pageNum_photos * $maxRows_photos;

mysql_select_db($database_telmanik_press, $telmanik_press);
$query_photos = "SELECT * FROM photos";
$query_limit_photos = sprintf("%s LIMIT %d, %d", $query_photos, $startRow_photos, $maxRows_photos);
$photos = mysql_query($query_limit_photos, $telmanik_press) or die(mysql_error());
$row_photos = mysql_fetch_assoc($photos);

if (isset($_GET['totalRows_photos'])) {
  $totalRows_photos = $_GET['totalRows_photos'];
} else {
  $all_photos = mysql_query($query_photos);
  $totalRows_photos = mysql_num_rows($all_photos);
}
$totalPages_photos = ceil($totalRows_photos/$maxRows_photos)-1;

$queryString_photos = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_photos") == false && 
        stristr($param, "totalRows_photos") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_photos = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_photos = sprintf("&totalRows_photos=%d%s", $totalRows_photos, $queryString_photos);
?>
<?php require("assets/wrapper/header.php"); ?>
<div class="mainlayout"><div id="edithead"><div id="editload">
  
  <p><?php ''.$translate->__('Gallery - '). ' '.$translate->__('image title - ').'  '.$translate->__('Description').'';?></p>
  <?php do { ?>
    <?php echo''.$row_photos['gallery'].' - '.$row_photos['title'].' - '.$row_photos['description'].' <BR> <img src="../photos/'. $row_photos['image_name'].'" width="400" height="300"/><BR>'; ?> <button onclick="window.location='delete_photo_confirm.php?id=<?php echo $row_photos['id']; ?>&amp;lang<?php echo $output;?>'; return false;" class="submit"><?php echo $translate->__('Delete');?></button>
    <?php } while ($row_photos = mysql_fetch_assoc($photos)); ?>
  <p>&nbsp;</p>
<?php echo $translate->__('Records');?> <?php echo ($startRow_photos + 1) ?> <?php echo $translate->__('to');?> <?php echo min($startRow_photos + $maxRows_photos, $totalRows_photos) ?> of <?php echo $totalRows_photos ?>
<table border="0">
  <tr>
    <td><?php if ($pageNum_photos > 0) { // Show if not first page ?>
        <a href="<?php printf("%s?pageNum_photos=%d%s", $currentPage, 0, $queryString_photos); ?>"><?php echo $translate->__('First');?></a>
        <?php } // Show if not first page ?></td>
    <td><?php if ($pageNum_photos > 0) { // Show if not first page ?>
        <a href="<?php printf("%s?pageNum_photos=%d%s", $currentPage, max(0, $pageNum_photos - 1), $queryString_photos); ?>">Previous</a>
        <?php } // Show if not first page ?></td>
    <td><?php if ($pageNum_photos < $totalPages_photos) { // Show if not last page ?>
        <a href="<?php printf("%s?pageNum_photos=%d%s", $currentPage, min($totalPages_photos, $pageNum_photos + 1), $queryString_photos); ?>"><?php echo $translate->__('Next');?></a>
        <?php } // Show if not last page ?></td>
    <td><?php if ($pageNum_photos < $totalPages_photos) { // Show if not last page ?>
        <a href="<?php printf("%s?pageNum_photos=%d%s", $currentPage, $totalPages_photos, $queryString_photos); ?>"><?php echo $translate->__('Last');?></a>
        <?php } // Show if not last page ?></td>
  </tr>
</table>  <p>&nbsp;</p>
  <p>&nbsp;</p>
</div></div>
</div>
<?php require("assets/wrapper/footer.php"); ?>
<?php
mysql_free_result($photos);
?>
