-
Notifications
You must be signed in to change notification settings - Fork 0
/
dirLoad.php
84 lines (74 loc) · 2.4 KB
/
dirLoad.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
<?php
class Archive
{
public $title;
public $urlTitle;
public $date;
public $eventVenue;
public $imgDir;
public $imgCount;
public $link;
public $video;
}
// while ($row = mysqli_fetch_array($result))
// echo '<tr><td><input type="checkbox" name="chknews['.$row['id'].']" /> '.$row['title'].'</td><td>'.$row['link'].'</td><td>'.date("jS F Y", strtotime($row['created'])).'</td></tr>';
function loadArchivesToArray($dir, $tableName, $mysqli)
{
$result = loadTable($mysqli, $tableName);
$arr = array();
while ($row = mysqli_fetch_array($result))
{
$a = copyRowToArchive($dir, $row);
array_push($arr, $a);
}
return $arr;
}
function loadArchive($dir, $tableName, $index, $mysqli)
{
$result = loadTable($mysqli, $tableName . ' WHERE id = {$index}');
$row = mysqli_fetch_row($result);
$a = copyRowToArchive($dir, $row);
return $a;
}
function copyRowToArchive($dir, $row)
{
$imgDirName = $dir . '/images';
$a = new Archive;
$a->title = $row['title'];
$a->urlTitle = $row['url_title'];
$a->link = $dir . '/' . $row['url_title'];
$a->date = $row['date'];
$a->eventVenue = $row['event_venue'] . ' | ' . $row['city_country'];
$a->video = $row['video_url'];
$a->imgDir = $imgDirName . '/' . $row['url_title'] . '/';
$a->imgCount = iterator_count(new FilesystemIterator($a->imgDir . 'hires'));
return $a;
}
function loadFirstAlts($archives, $mysqli)
{
//include 'database.php';
//$mysqli = dbConnect();
$alts = array();
for($i = 0; $i < sizeof($archives); ++$i)
{
$result = loadTable($mysqli, 'alt_' . $archives[$i]->urlTitle . ' WHERE id = 0');
while ($row = mysqli_fetch_array($result))
{
array_push($alts, $row['alt']);
}
}
return $alts;
}
function loadArchiveAlts($archiveName, $mysqli)
{
$tableName = 'alt_' . $archiveName;
$result = loadTable($mysqli, $tableName);
//include 'database.php';
$arr = array();
while ($row = mysqli_fetch_array($result))
{
array_push($arr, $row['alt']);
}
return $arr;
}
?>