<?php Route::collection(array('before' => 'auth,csrf,install_exists'), function () { /* List Fields */ Route::get(array('admin/extend/fields', 'admin/extend/fields/(:num)'), function ($page = 1) { $vars['token'] = Csrf::token(); $vars['extend'] = Extend::paginate($page, Config::get('admin.posts_per_page')); return View::create('extend/fields/index', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer'); }); /* Add Field */ Route::get('admin/extend/fields/add', function () { $vars['token'] = Csrf::token(); $vars['types'] = Extend::$types; $vars['fields'] = Extend::$field_types; $vars['pagetypes'] = Query::table(Base::table('pagetypes'))->sort('key')->get(); return View::create('extend/fields/add', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer'); }); Route::post('admin/extend/fields/add', function () { $input = Input::get(array('type', 'field', 'key', 'label', 'attributes', 'pagetype')); if (empty($input['key'])) { $input['key'] = $input['label']; } $input['key'] = slug($input['key'], '_'); // an array of items that we shouldn't encode - they're no XSS threat $dont_encode = array('attributes'); foreach ($input as $key => &$value) { if (in_array($key, $dont_encode)) {