3 require_once "phpfspot_cfg.php";
4 require_once "phpfspot_db.php";
5 require_once "phpfspot_tmpl.php";
18 public function __construct()
20 $this->cfg = new PHPFSPOT_CFG;
22 $this->db = new PHPFSPOT_DB(&$this, $this->cfg->db);
23 $this->tmpl = new PHPFSPOT_TMPL(&$this);
28 if(isset($_GET['id']) && is_numeric($_GET['id']))
29 $this->current_photo = $_GET['id'];
33 public function __destruct()
38 public function show()
41 if(isset($this->current_photo)) {
42 $this->tmpl->assign('image_url', 'phpfspot_img.php?idx='. $this->avail_photos[$this->current_photo] ."&width=". $this->cfg->photo_width);
45 if($this->current_photo > 0) {
46 $this->tmpl->assign('previous_url', $_SERVER['PHP_SELF'] ."?mode=showphoto&id=". $this->avail_photos[$this->current_photo-1]);
49 if($this->current_photo < count($this->avail_photos)) {
50 $this->tmpl->assign('next_url', $_SERVER['PHP_SELF'] ."?mode=showphoto&id=". $this->avail_photos[$this->current_photo+1]);
53 $this->tmpl->assign('tags', $this->tags);
54 $this->tmpl->show("index.tpl");
59 private function get_tags()
61 $result = $this->db->db_query("
64 ORDER BY sort_priority ASC
67 while($row = $this->db->db_fetch_object($result)) {
70 $tag_name = $row['name'];
72 $this->tags[$tag_id] = $tag_name;
77 private function get_photos()
79 $this->avail_photos = Array();
82 $result = $this->db->db_query("
88 while($row = $this->db->db_fetch_object($result)) {
90 $photo_id = $row['id'];
91 $photo_name = $row['name'];
93 $this->photos[$photo_id] = $photo_name;
94 $this->avail_photos[$count] = $photo_id;
96 if(!isset($this->current_photo))
97 $this->current_photo = $count;
105 public function get_photo_details($idx)
107 $result = $this->db->db_query("
110 WHERE id='". $idx ."'
113 return $this->db->db_fetch_object($result);
115 } // get_photo_details
117 public function translate_path($path, $width = 0)
119 return str_replace($this->cfg->path_replace_from, $this->cfg->path_replace_to, $path);