-
Notifications
You must be signed in to change notification settings - Fork 36
/
contents_controller.php
94 lines (86 loc) · 3.04 KB
/
contents_controller.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
86
87
88
89
90
91
92
93
94
<?php
class ContentsController extends CmsAppController
{
var $name = 'Contents';
function index()
{
$this->Content->recursive = 0;
$this->set( 'contents', $this->paginate() );
}
function view( $id = null )
{
if ( !$id )
{
$this->Session->setFlash( __( 'Invalid content', true ) );
$this->redirect( array( 'action' => 'index' ) );
}
$this->set( 'content', $this->Content->read( null, $id ) );
}
function admin_index()
{
$this->Content->recursive = 1;
$this->set( 'contents', $this->paginate( null, $this->Filter->filter ) );
}
function admin_view( $id = null )
{
if ( !$id )
{
$this->Session->setFlash( __( 'Invalid content', true ) );
$this->redirect( array( 'action' => 'index' ) );
}
$this->set( 'content', $this->Content->read( null, $id ) );
}
function admin_add()
{
if ( !empty( $this->data ) )
{
$this->Content->create();
if ( $this->Content->save( $this->data ) )
{
$this->Session->setFlash( __( 'The content has been saved', true ) );
$this->redirect( array( 'action' => 'index' ) );
}
else
{
$this->Session->setFlash( __( 'The content could not be saved. Please, try again.', true ) );
}
}
$categories = $this->Content->Category->find( 'list' );
$this->set( compact( 'categories' ) );
}
function admin_edit( $id = null )
{
if ( !$id && empty( $this->data ) )
{
$this->Session->setFlash( __( 'Invalid content', true ) );
$this->redirect( array( 'action' => 'index' ) );
}
if ( !empty( $this->data ) )
{
if ( $this->Content->save( $this->data ) )
{
$this->Session->setFlash( __( 'The content has been saved', true ) );
$this->redirect( array( 'action' => 'index' ) );
}
else
{
$this->Session->setFlash( __( 'The content could not be saved. Please, try again.', true ) );
}
}
if ( empty( $this->data ) )
{
$this->data = $this->Content->lock( null, $id );
if ( $this->data === false )
{
$this->Session->setFlash( __( 'The content item is currently locked', true ) );
$this->redirect( $this->referer() );
}
}
$categories = $this->Content->Category->find( 'list' );
$this->set( compact( 'categories' ) );
}
function admin_toggle( $id = null )
{
}
}
?>