forked from anchorcms/anchor-cms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmetadata.php
60 lines (43 loc) · 1.74 KB
/
metadata.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
<?php
Route::collection(array('before' => 'auth'), function() {
/*
List Metadata
*/
Route::get('admin/extend/metadata', function() {
$vars['messages'] = Notify::read();
$vars['token'] = Csrf::token();
$vars['meta'] = Config::get('meta');
$vars['pages'] = Page::dropdown();
$vars['themes'] = Themes::all();
return View::create('extend/metadata/edit', $vars)
->partial('header', 'partials/header')
->partial('footer', 'partials/footer');
});
/*
Update Metadata
*/
Route::post('admin/extend/metadata', function() {
$input = Input::get(array('sitename', 'description', 'home_page', 'posts_page',
'posts_per_page', 'admin_posts_per_page', 'auto_published_comments', 'theme', 'comment_notifications', 'comment_moderation_keys'));
$validator = new Validator($input);
$validator->check('sitename')
->is_max(3, __('metadata.sitename_missing'));
$validator->check('description')
->is_max(3, __('metadata.sitedescription_missing'));
$validator->check('posts_per_page')
->is_regex('#^[0-9]+$#', __('metadata.missing_posts_per_page', 'Please enter a number for posts per page'));
if($errors = $validator->errors()) {
Input::flash();
Notify::error($errors);
return Response::redirect('admin/extend/metadata');
}
// convert double quotes so we dont break html
$input['sitename'] = htmlspecialchars($input['sitename'], ENT_COMPAT, Config::app('encoding'), false);
$input['description'] = htmlspecialchars($input['description'], ENT_COMPAT, Config::app('encoding'), false);
foreach($input as $key => $value) {
Query::table('meta')->where('key', '=', $key)->update(array('value' => $value));
}
Notify::success(__('metadata.updated'));
return Response::redirect('admin/extend/metadata');
});
});