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
86
87
88
89
90
91
92
93
94
|
<?php
class Controllerart extends Controllerdb
{
/** @var Art2 */
protected $art;
public function __construct($id) {
parent::__construct();
$this->art = new Art2(['id' => $id]);
}
public function importart()
{
if($this->artmanager->exist($this->art->id())) {
$this->art = $this->artmanager->get($this->art);
$this->art->autotaglistupdate($this->artmanager->taglist($this->artmanager->getlister(['id', 'title', 'description', 'tag']), $this->art->autotaglist()));
return true;
} else {
return false;
}
}
public function read()
{
$artexist = $this->importart();
$display = $this->user->level() >= $this->art->secure();
$cancreate = $this->user->cancreate();
$this->showtemplate('read', ['art' => $this->art, 'artexist' => $artexist, 'display' => $display, 'cancreate' => $cancreate]);
}
public function edit()
{
if($this->importart() && $this->user->canedit()) {
$this->showtemplate('edit', ['art' => $this->art, 'artexist' => true]);
} else {
$this->redirect('?id=' . $this->art->id());
}
}
public function log()
{
$this->importart();
var_dump($this->art);
}
public function add()
{
echo '<h2>Add</h2>';
$this->art->reset();
$this->artmanager->add($this->art);
}
public function delete()
{
echo '<h2>Delete</h2>';
$this->artmanager->delete($this->art);
}
public function update()
{
if($this->importart()) {
$this->art->hydrate($_POST);
}
// $this->art->updatelinkfrom();
// $this->art->autotaglistcalc($this->artmanager->taglist($this->artmanager->getlister(['id', 'title', 'tag']), $this->art->autotaglist()));
$this->artmanager->update($this->art);
$this->redirect('?id=' . $this->art->id() . '&aff=edit');
}
}
?>
|