<?php if (!defined("webStart")) { exit(0); } require_once 'Route.php'; Route::get('/', 'homeController@page'); Route::get('/home', 'homeController@page'); //Route::get('/home/{id}','pagesController@home', ['id'=>'/[0-9]/']); Route::get('/history', 'historyController@page'); Route::get('/importantplace', 'importantplaceController@page'); Route::get('/gallery', 'galleryController@page'); Route::get('/guestbook', 'guestbookController@page'); Route::get('/contact', 'contactController@page'); Route::get('/map', 'mapController@page'); Route::get('/admin', 'adminController@index'); Route::get('/admin/history', 'adminController@history'); Route::get('/admin/importantplace', 'adminController@importantplace'); Route::get('/admin/logout', 'adminController@logout'); Route::post('/admin/login', 'adminController@login'); Route::post('/admin/history', 'adminController@saveHistory'); Route::error();
return View::create('upgrade', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer'); }); /* List extend */ Route::get('admin/extend', array('before' => 'auth', 'main' => function ($page = 1) { $vars['messages'] = Notify::read(); $vars['token'] = Csrf::token(); return View::create('extend/index', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer'); })); Route::get('admin/posts/edit/ckeditor/plugins/imageuploader/', array('before' => 'auth', 'main' => function () { return View::create('imageuploaded'); })); /* Upload a image */ Route::post('admin/upload', function () { $uploader = new Uploader(PATH . 'content', array('png', 'jpg', 'bmp', 'gif')); $file = $_FILES['file']; $filepath = $uploader->upload($file); $newfilename = basename($filepath); $uri = '/content/' . $newfilename; $output = array('uploaded' => 1, 'url' => $uri, 'fileName' => $newfilename); return Response::json($output); }); /* 404 error */ Route::error('404', function () { return Response::error(404); });
<?php if (!defined('BASEPATH')) { exit('No direct script access allowed'); } /** * 路由 * @author 徐亚坤 hdyakun@sina.com */ Route::get('/', 'IndexController@index'); Route::get('/(:num)', 'IndexController@index'); Route::get('/(:any)', 'IndexController@show'); Route::error(function () { throw new Exception("404 Not Found"); }); Route::dispatch();
Event::register('test', function (&$data) { echo "firstHandler\n"; $data['testEvent'] = 'triggered'; }); Event::register('test', function ($data = null) { echo "secondHandler\n"; }); Event::register('another', function ($data = null) { echo "anotherHandler\n"; }); /****************************** -----------Маршруты------------ ******************************/ // error 404 Route::error('PageNotFound', function () { Response::status(404); return Response::text('404 страница не найдена'); }); // index Route::any('/', 'Index@index'); Route::any('/test_model', 'Index@testModel'); Route::any('/user', 'Index@user'); Route::any('/rows', 'Index@rows'); Route::any('/products', 'Index@products'); Route::post('/product', 'Index@product'); Route::any('/list/{id}/{subId}/', function ($id, $subId) { return Response::text("I'm element with id '{$id}' and subId '{$subId}'"); })->where(array('id' => '[A-Za-z0-9_\\-]+', 'subId' => '[0-9]+')); Route::any('/event', function () { $arr = array(); Event::trigger('test', $arr); print_r($arr);