/
actions.inc.php
40 lines (40 loc) · 967 Bytes
/
actions.inc.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
<?php
switch($_POST['action']){
case 'order':
$titles = $_POST['order'];
foreach($titles as $title){
$dvd = new DVD($title);
$dvd->buy();
}
break;
case 'anthology':
$band = trim(strip_tags($_POST['band']));
$type = (int)($_POST['bonus']) ? 'bonus' : '';
$tracks = array_map(function($val){return (int)$val;}, $_POST['order']);
// $dvd = new DVD();
$dvd = DVDFactory::create($type);
$dvd->setBand($band);
foreach ($tracks as $track) {
$dvd->addTrack($track);
}
break;
case 'list':
$id = abs((int)$_POST['id']);
$type = (int)$_POST['format'];
$band = trim(strip_tags($_POST['band']));
$title = trim(strip_tags($_POST['title']));
// $dvd = new DVD();
$dvd = new DVDStrategy();
if($type)
$dvd->setStrategy(new DVDAsJSON($id));
else
$dvd->setStrategy(new DVDAsXML($id));
$dvd->setTitle($title);
$dvd->setBand($band);
// $dvd->getXML($id);
$dvd->get();
break;
}
header('Location: catalog.php');
exit;
?>