forked from redbaron76/PongoCMS-Laravel-cms-bundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
site.php
120 lines (83 loc) · 2.34 KB
/
site.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php
class Cms_Site_Controller extends Cms_Base_Controller {
/*
|--------------------------------------------------------------------------
| FRONTEND - Site controller
|--------------------------------------------------------------------------
|
|
*/
//RESTFUL CONTROLLER
public $restful = true;
//FILTERS
public function __construct()
{
parent::__construct();
$this->filter('before', 'init');
}
//SHOW USER LOGIN
public function get_sitemap($lang = LANG)
{
//GET PAGE DATA
$data = CmsPage::with(array('files' => function($query) {
$query->where_is_image(1)->where_is_valid(1);
}))
->where_parent_id(0)
->where_lang($lang)
->order_by('is_home', 'desc')
->order_by('slug', 'asc')
->get();
$new_data = array();
foreach ($data as $value) {
$new_data[$value->id] = $value;
}
foreach ($new_data as $page) {
$recursive = call_user_func_array('CmsPage::recursive_site_sitemap', array($page->id));
$new_data = array_insert($new_data, $page->id, $recursive);
}
$view = View::make('cms::theme.'.THEME.'.templates.sitemap')
->with('encoding', '<?xml version="1.0" encoding="UTF-8" ?>')
->with('base', Config::get('application.url'))
->with('data', $new_data);
$headers = array('Content-Type' => 'text/xml');
return Response::make($view, 200, $headers);
}
//SHOW USER LOGIN
public function get_login()
{
$html = View::make('cms::theme.'.THEME.'.templates.'.TEMPLATE)
->with('title', LL('user.user_title', SITE_LANG))
->with('keyw', 'login')
->with('descr', 'login')
->nest('header', 'cms::theme.'.THEME.'.partials.header_default')
->nest('layout', 'cms::theme.'.THEME.'.user.login')
->nest('footer', 'cms::theme.'.THEME.'.partials.footer_default');
CmsRender::clean_code($html);
}
//PERFORM USER LOGIN
public function post_login()
{
//POST LOGIN
$credentials = array(
'cms' => false,
'username' => Input::get('username'),
'password' => Input::get('password'),
'remember' => (bool) Input::get('remember')
);
//CHECK CREDENTIALS
if(Auth::attempt($credentials)) {
//SUCCESS LOGIN
return Redirect::home();
} else {
//ERROR LOGIN
return Redirect::to_action('user@login')
->with_input('only', array('username'));
}
}
//PERFORM USER LOGOUT
public function get_logout()
{
Auth::logout();
return Redirect::home();
}
}