Location: PHPKode > projects > Jarida > jarida_1.0/photo.php
<?php

include("header.php");

if(!$_GET['id'])
{
  //Now lets display the Thumbnails
  //////////////////////////////////
  
  $query = "SELECT photo_id FROM tblPhoto
                 ORDER BY photo_id DESC";
  
  $result = $db->doQuery($query);
  
  $result->setPaging($config['num_thumbs'], $_GET['page']);
  $template->assign('nav', $result->getPageNav());
  
  while($row = $result->getArray())
    {
      $photo = new Photo($db, $row['photo_id']);
      $photo->setDescription(replaceSmilies($photo->getDescription(), $db));
      $photos[] = array('title' => $photo->getTitle(),
			'description' => $photo->getDescription(),
			'thumb' =>$photo->getThumbnail(),
			'numComments' => $photo->getNumComments(),
			'id' => $photo->getId());

    }
  
  $template->assign('photos', $photos);
  
}

if($_GET['id'])
{
  //Now lets display the Photo in Full
  //////////////////////////////////
  
  $query = "SELECT photo_id FROM tblPhoto
                 WHERE photo_id = " . $_GET['id'];
  
  $result = $db->doQuery($query);
  $row = $result->getArray();

  $photo = new Photo($db, $row['photo_id']);
  $photo->setDescription(replaceSmilies($photo->getDescription(), $db));

  $img_size = getimagesize("img/upload/" . $photo->getFile());

  if(($img_size[0] > 600 ) OR ($img_size[1] > 600))
    {
      $dimensions = imageResize($img_size[0], $img_size[1], 600);
    }
  else
    {
      $dimensions = array('width' => $img_size[0],
			  'height' => $img_size[1]);
    }
      
  $photo_arr = array('title' => $photo->getTitle(),
		     'file' =>$photo->getFile(),
		     'dimensions' => $dimensions,
		     'numComments' => $photo->getNumComments(),
		     'description' => $photo->getDescription());
  
  $template->assign('photo', $photo_arr);
  
  if($comments = $photo->getComments())
    {
      foreach($comments as $comment)
	{
	  $comment->setBody(replaceSmilies($comment->getBody(), $db));
	  $comment->setBody(replaceBadWords($comment->getBody(), $db));
	  $comments_arr[] = array('title' => $comment->getTitle(),
				  'name' => $comment->getName(),
				  'web' => $comment->getWeb(),
				  'body' => $comment->getBody(),
				  'date' => $comment->getDate());
	}
    }

  $template->assign('comments', $comments_arr);

  //Lets display the available smilies
  $query = "SELECT * FROM tblSmilie";
  
  $result = $db->doQuery($query);
  
  while($row = $result->getarray())
    {
      $smilie = new Smilie($db, $row['smilie_id']);
      $smilies[] = array('file' => $smilie->getFile(),
			 'code' => $smilie->getCode());
    }
  
  
  $template->assign('smilies', $smilies);


}  
  
$template->assign('lang', $lang);
  
  
//Lets display the template
$template->display($config['theme'].'/photo.tpl');

include("footer.php");
?>
Return current item: Jarida