示例#1
0
     foreach ($input as $key => &$value) {
         $value = eq($value);
     }
     $validator = new Validator($input);
     $validator->check('title')->is_max(3, __('categories.title_missing'));
     if ($errors = $validator->errors()) {
         Input::flash();
         Notify::error($errors);
         return Response::redirect('admin/categories/add');
     }
     if (empty($input['slug'])) {
         $input['slug'] = $input['title'];
     }
     $input['slug'] = slug($input['slug']);
     $category = Category::create($input);
     Extend::process('category', $category->id);
     Notify::success(__('categories.created'));
     return Response::redirect('admin/categories');
 });
 /*
     Delete Category
 */
 Route::get('admin/categories/delete/(:num)', function ($id) {
     $total = Category::count();
     if ($total == 1) {
         Notify::error(__('categories.delete_error'));
         return Response::redirect('admin/categories/edit/' . $id);
     }
     // move posts
     $category = Category::where('id', '<>', $id)->fetch();
     // delete selected
示例#2
0
         Notify::error($errors);
         return Response::redirect('admin/posts/add');
     }
     if (empty($input['created'])) {
         $input['created'] = Date::mysql('now');
     }
     $user = Auth::user();
     $input['author'] = $user->id;
     if (is_null($input['comments'])) {
         $input['comments'] = 0;
     }
     if (empty($input['html'])) {
         $input['status'] = 'draft';
     }
     $post = Post::create($input);
     Extend::process('post', $post->id);
     Notify::success(__('posts.created'));
     return Response::redirect('admin/posts');
 });
 /*
 	Preview post
 */
 Route::post('admin/posts/preview', function () {
     $html = Input::get('html');
     // apply markdown processing
     $md = new Markdown();
     $output = Json::encode(array('html' => $md->transform($html)));
     return Response::create($output, 200, array('content-type' => 'application/json'));
 });
 /*
 	Delete post
示例#3
0
     return View::create('users/add', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer');
 });
 Route::post('admin/users/add', function () {
     $input = Input::get(array('username', 'email', 'real_name', 'password', 'bio', 'status', 'role'));
     $validator = new Validator($input);
     $validator->check('username')->is_max(3, __('users.username_missing', 2));
     $validator->check('email')->is_email(__('users.email_missing'));
     $validator->check('password')->is_max(6, __('users.password_too_short', 6));
     if ($errors = $validator->errors()) {
         Input::flash();
         Notify::error($errors);
         return Response::redirect('admin/users/add');
     }
     $input['password'] = Hash::make($input['password']);
     $user = User::create($input);
     Extend::process('user', $user->id);
     Notify::success(__('users.created'));
     return Response::redirect('admin/users');
 });
 /*
 	Delete user
 */
 Route::get('admin/users/delete/(:num)', function ($id) {
     $self = Auth::user();
     if ($self->id == $id) {
         Notify::error(__('users.delete_error'));
         return Response::redirect('admin/users/edit/' . $id);
     }
     User::where('id', '=', $id)->delete();
     Query::table(Base::table('user_meta'))->where('user', '=', $id)->delete();
     Notify::success(__('users.deleted'));
            return Page::where('slug', '=', $str)->count() == 0;
        });
        $validator->check('title')->is_max(3, __('pages.title_missing'));
        $validator->check('slug')->is_max(3, __('pages.slug_missing'))->is_duplicate(__('pages.slug_duplicate'))->not_regex('#^[0-9_-]+$#', __('pages.slug_invalid'));
        if ($input['redirect']) {
            $validator->check('redirect')->is_url(__('pages.redirect_missing'));
        }
        if ($errors = $validator->errors()) {
            Input::flash();
            Notify::error($errors);
            return Response::redirect('admin/pages/add');
        }
        if (empty($input['name'])) {
            $input['name'] = $input['title'];
        }
        $input['show_in_menu'] = is_null($input['show_in_menu']) ? 0 : 1;
        $page = Page::create($input);
        Extend::process('page', $page->id);
        Notify::success(__('pages.created'));
        return Response::redirect('admin/pages');
    });
    /*
    	Delete Page
    */
    Route::get('admin/pages/delete/(:num)', function ($id) {
        Page::find($id)->delete();
        Query::table(Base::table('page_meta'))->where('page', '=', $id)->delete();
        Notify::success(__('pages.deleted'));
        return Response::redirect('admin/pages');
    });
});
示例#5
0
 });
 Route::post('admin/departments/add', function () {
     $input = Input::get(array('title', 'slug', 'description'));
     $validator = new validator($input);
     $validator->check('title')->is_max(3, __('departments.title_missing'));
     if ($errors = $validator->errors()) {
         Input::flash();
         Notify::error($errors);
         return Response::redirect('admin/departments/add');
     }
     if (empty($input['slug'])) {
         $input['slug'] = $input['title'];
     }
     $input['slug'] = slug($input['slug']);
     $department = department::create($input);
     Extend::process('department', $department->id);
     Notify::success(__('departments.created'));
     return Response::redirect('admin/departments');
 });
 Route::get('admin/departments/delete/(:num)', function ($id) {
     $total = department::count();
     if ($total == 1) {
         Notify::error(__('departments.delete_error'));
         return Response::redirect('admin/departments/edit/' . $id);
     }
     $department = department::where('id', '<>', $id)->fetch();
     department::find($id)->delete();
     Post::where('department', '=', $id)->update(array('department' => $department->id));
     Notify::success(__('departments.deleted'));
     return Response::redirect('admin/departments');
 });
示例#6
0
     }
     if (empty($input['created'])) {
         $input['created'] = Date::mysql('now');
     }
     $user = Auth::user();
     $input['author'] = $user->id;
     if (empty($input['comments'])) {
         $input['comments'] = 0;
     }
     if (empty($input['markdown'])) {
         $input['status'] = 'draft';
     }
     $input['html'] = parse($input['markdown']);
     $post = Post::create($input);
     $id = $post->id;
     Extend::process('post', $id);
     // Notify::success(__('posts.created'));
     if (Input::get('autosave') === 'true') {
         return Response::json(array('id' => $id, 'notification' => __('posts.updated')));
     } else {
         return Response::json(array('id' => $id, 'notification' => __('posts.created'), 'redirect' => Uri::to('admin/posts/edit/' . $id)));
     }
 });
 /*
     Preview post
 */
 Route::post('admin/posts/preview', function () {
     $markdown = Input::get('markdown');
     // apply markdown processing
     $md = new Markdown();
     $output = Json::encode(array('markdown' => $md->transform($markdown)));
示例#7
0
 });
 Route::post('admin/companies/add', function () {
     $input = Input::get(array('title', 'slug', 'description'));
     $validator = new validator($input);
     $validator->check('title')->is_max(3, __('companies.title_missing'));
     if ($errors = $validator->errors()) {
         Input::flash();
         Notify::error($errors);
         return Response::redirect('admin/companies/add');
     }
     if (empty($input['slug'])) {
         $input['slug'] = $input['title'];
     }
     $input['slug'] = slug($input['slug']);
     $company = Company::create($input);
     Extend::process('company', $company->id);
     Notify::success(__('companies.created'));
     return Response::redirect('admin/companies');
 });
 Route::get('admin/companies/delete/(:num)', function ($id) {
     $total = Company::count();
     if ($total == 1) {
         Notify::error(__('companies.delete_error'));
         return Response::redirect('admin/companies/edit/' . $id);
     }
     $company = Company::where('id', '<>', $id)->fetch();
     Company::find($id)->delete();
     Post::where('company', '=', $id)->update(array('company' => $company->id));
     Notify::success(__('companies.deleted'));
     return Response::redirect('admin/companies');
 });
示例#8
0
     if ($input['redirect']) {
         $validator->check('redirect')->is_url(__('pages.redirect_missing'));
     }
     if ($errors = $validator->errors()) {
         Input::flash();
         // Notify::error($errors);
         return Response::json(array('id' => $id, 'errors' => array_flatten($errors, array())));
     }
     if (empty($input['name'])) {
         $input['name'] = $input['title'];
     }
     $input['show_in_menu'] = is_null($input['show_in_menu']) || empty($input['show_in_menu']) ? 0 : 1;
     $input['html'] = parse($input['markdown']);
     $page = Page::create($input);
     $id = $page->id;
     Extend::process('page', $id);
     // Notify::success(__('pages.created'));
     return Response::json(array('id' => $id, 'notification' => __('pages.created'), 'redirect' => Uri::to('admin/pages/edit/' . $id)));
 });
 /*
     Delete Page
 */
 Route::get('admin/pages/delete/(:num)', function ($id) {
     if (Page::count() > 1) {
         Page::find($id)->delete();
         Query::table(Base::table('page_meta'))->where('page', '=', $id)->delete();
         Notify::success(__('pages.deleted'));
     } else {
         Notify::error('Unable to delete page, you must have at least 1 page.');
     }
     return Response::redirect('admin/pages');