summaryrefslogtreecommitdiff
path: root/utils/album.php
diff options
context:
space:
mode:
authordeva <deva>2010-02-27 13:52:39 +0000
committerdeva <deva>2010-02-27 13:52:39 +0000
commit39d6dd59160aa8b836309743950e5c5bf9d2a459 (patch)
tree825484d07e4a86bcf50bc588f0fe22d008804cea /utils/album.php
parent35562f519abaece77746381b73dea0fa0d13ed3e (diff)
Remove some old unused admin files.
Diffstat (limited to 'utils/album.php')
-rw-r--r--utils/album.php139
1 files changed, 0 insertions, 139 deletions
diff --git a/utils/album.php b/utils/album.php
deleted file mode 100644
index 696e75e..0000000
--- a/utils/album.php
+++ /dev/null
@@ -1,139 +0,0 @@
-<?php
-include_once("thumbnail.php");
-
-class Photo {
- public $file;
- public $text;
-
- function Photo($file, $text) {
- $this->file = $file;
- $this->text = $text;
- }
-}
-
-class Album {
- // Album directory (and identifier)
- public $album;
-
- // Photo array
- public $photos;
-
- // Album data
- public $title;
- public $icon;
- public $copyright;
-
- public function add($photo) {
- // First added image is automatically made album icon.
- if($this->icon == "") $this->icon = $photo->file;
-
- $key = $photo->file;
- $this->photos[$key] = $photo;
- }
-
- public function write()
- {
- $fp = fopen($this->file, "w");
- fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
-
- fwrite($fp, "<album title=\"". $this->title . "\" icon=\"".$this->icon."\" copyright=\"" . $this->copyright . "\">\n");
- foreach($this->photos as $photo) {
- fwrite($fp, " <photo file=\"" . $photo->file . "\"\n");
- fwrite($fp, " text=\"" . $photo->text . "\">\n");
- fwrite($fp, " </photo>\n");
- }
- fwrite($fp, "</album>\n");
-
- fclose($fp);
- }
-
- private function read()
- {
-
- $dom = new DomDocument;
- $dom->preserveWhiteSpace = FALSE;
- $dom->load($this->file);
-
- $params = $dom->getElementsByTagName('album');
- foreach ($params as $param) {
- $this->title = $param->getAttribute('title');
- $this->icon = $param->getAttribute('icon');
- $this->copyright = $param->getAttribute('copyright');
- }
-
- $params = $dom->getElementsByTagName('photo');
- foreach ($params as $param) {
- $photo = new Photo($param->getAttribute('file'), $param->getAttribute('text'));
- $this->add($photo);
- }
-
- // Key sort
- if(sizeof($this->photos) > 0) ksort($this->photos);
- }
-
- public function Album($album)
- {
- global $ALBUMS_DIR;
- $this->album = $album;
- $this->file = $ALBUMS_DIR ."/". $album . "/album.xml";
- $this->read();
- }
-
-}
-
-
-function getAllAlbums()
-{
- global $ALBUMS_DIR;
- $albums = array();
-
- $handle = opendir($ALBUMS_DIR . "/");
- $albumdirs = array();
- while($albumdir = readdir($handle)) {
- array_push($albumdirs, $albumdir);
- }
-
- rsort($albumdirs);
-
- foreach($albumdirs as $albumdir) {
- if(!strstr($albumdir, ".") && !strstr($albumdir, "..")) {
- $album = new Album($albumdir);
- array_push($albums, $album);
- }
- }
-
- return $albums;
-}
-
-function getRandomPhoto()
-{
- $album;
- $photo;
-
- $albums = getAllAlbums();
-
- $numalbums = sizeof($albums);
- $ralbum = rand(0, sizeof($albums)-1);
- foreach($albums as $a) {
- $album = $a;
- $ralbum--;
- if(!$ralbum) break;
- }
-
- $numphotos = sizeof($album->photos);
- $rphoto = rand(0, $numphotos-1);
- if($album->photos) {
- foreach($album->photos as $p) {
- $photo = $p;
- $rphoto--;
- if(!$rphoto) break;
- }
- }
-
- // echo "<p>".$numalbums . " " .$ralbum . " ".$numphotos . " ".$rphoto . "</p>";
-
- return array($album, $photo);
-}
-
-
-?> \ No newline at end of file