* @version SVN: $Id$ */ class Album { public $id; public $path; public $colleciton; public $date; public $caption; public $caption_safe; public $isAlbumGroup; public $numImages; public function __construct($db, $row) { $this->id = $row['album_id']; $this->path = $row['album_path']; $this->collection = $row['collection']; $this->date = $row['album_date']; $this->caption = $row['album_caption']; $this->caption_safe = htmlentities(strip_tags($row['album_caption']), ENT_QUOTES); $this->numImages = $row['num_images']; $this->isAlbumGroup = $db->isAlbumGroup( $this->path ); } public function getUrl() { return '/pics/index.php?group=' . $this->id; } public function getUrlForPage($page) { return '/pics/index.php?group=' . $this->id . '&page=' . $page; } public function getFriendlyUrlForPage($page) { $sep = ""; if ( $page != 1 ) { $sep = "/page_" . $page ; } $url = '/pics' . $this->path . $sep . '.html'; $to_replace_from = array( '(', ')', '_', '-', ' ', "'"); $to_replace_to = array( '', '', ' ', ' ', '_', ''); $clean_url = str_replace($to_replace_from, $to_replace_to, strtolower( $url ) ); $clean_url = preg_replace( '/__*/', '_', $clean_url ); $clean_url = preg_replace( '/&.*;/', '', $clean_url ); return $clean_url; } public function getFriendlyUrl() { $url = '/pics' . $this->path . '.html'; $to_replace_from = array( '(', ')', '_', '-', ' ', "'"); $to_replace_to = array( '', '', ' ', ' ', '_', ''); $clean_url = str_replace($to_replace_from, $to_replace_to, strtolower( $url ) ); $clean_url = preg_replace( '/__*/', '_', $clean_url ); $clean_url = preg_replace( '/&.*;/', '', $clean_url ); return $clean_url; } public function getName() { $name = $this->path; if( $this->isAlbumGroup() ) { $name .= " Galleries"; } $name = preg_replace("/^.*\/(.*)/", "$1", $name); $name = preg_replace("/^....-..-.. /", "", $name); return htmlentities($name, ENT_QUOTES); } public function isAlbumGroup() { return $this->isAlbumGroup; } public function getHierarchy() { return explode( "/", $this->path ); } public function getNumPages() { return round($this->numImages / 21, 0, PHP_ROUND_HALF_DOWN) + 1; } } ?>