-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinc.data.php
85 lines (69 loc) · 2.22 KB
/
inc.data.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
class Entry{
function __construct($date, $title){
$this->date = $date; //format? date ("d.m.y", filectime($this->path.$file));
$this->title = $title; //$pieces = explode(".",$file); $ext = $pieces[1]; $name = substr($pieces[0], 7,36);
return $this;
}
}
class ImageEntry extends Entry{
function __construct($date, $title, $imagepath){
parent::__construct($date, $title);
$this->imagepath = $imagepath;
return $this;
}
}
class SoundEntry extends Entry{
function __construct($date, $title, $soundpath, $imagepath){
parent::__construct($date, $title, $imagepath);
$this->soundpath = $soundpath;
$this->imagepath = $imagepath;
return $this;
}
}
//-----------------------
class ListEntry{
var $content;
function __construct($start, $items,$path){
$x = $this->scandirectory($start,$items,$path);
$this->content = $x;
return true;
}
function scandirectory($start,$items,$path){
$i = 0; //total file counter
$f = 0; //set file counter
$files = scandir($path,1); //scan and sort 0 = DESC
// echo "<p>IN</p><pre>";
// print_r($files);
// echo "</pre>";
for ($z = 0; ($z < (count($files))-3) && ($f <= $items); $z++){ // -3 because of ".", "..", ".DS_Store"
//extract display content
$pieces = explode(".",$files[$z]);
$ext = $pieces[1];
$name = substr($pieces[0], 7,36); // the title
$year = substr($files[$z], 0,2);
$month = substr($files[$z], 2,2);
$day = substr($files[$z], 4,2);
$dateshow = "$day.$month.$year"; // the date
$y = $z - 1; //last file
$lastpieces = explode(".",$files[$y]);
$lastext = $lastpieces[1];
if (($ext=='gif') && ($lastext == 'mp3')){
if ($i++ >= $start){ // soviele schleifen mit befüllen wareten bis min. erreicht ist
$result[$f] = new SoundEntry($dateshow, $name, "pub/$files[$y]", "pub/$files[$z]"); //SoundEntry: $date, $title, $soundpath, $imagepath
$f++;
}
} else if (($ext=='gif') && ($lastext != 'mp3')) {
if ($i++ >= $start){
$result[$f] = new ImageEntry($dateshow, $name, "pub/$files[$z]");
$f++;
}
}
}
// echo "<p>OUT</p><pre>";
// print_r($result);
// echo "</pre>";
return $result;
}
}
?>