Ejemplo n.º 1
0
     if ($password_reset) {
         $input['password'] = Hash::make($input['password']);
     }
     User::update($id, $input);
     Extend::process('user', $id);
     Notify::success(__('users.updated'));
     return Response::redirect('admin/users/edit/' . $id);
 });
 /*
 	Add user
 */
 Route::get('admin/users/add', function () {
     $vars['messages'] = Notify::read();
     $vars['token'] = Csrf::token();
     // extended fields
     $vars['fields'] = Extend::fields('user');
     $vars['statuses'] = array('inactive' => __('global.inactive'), 'active' => __('global.active'));
     $vars['roles'] = array('administrator' => __('global.administrator'), 'editor' => __('global.editor'), 'user' => __('global.user'));
     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');
     }
Ejemplo n.º 2
0
     if (empty($input['slug'])) {
         $input['slug'] = $input['title'];
     }
     $input['slug'] = slug($input['slug']);
     Category::update($id, $input);
     Extend::process('category', $id);
     Notify::success(__('categories.updated'));
     return Response::redirect('admin/categories/edit/' . $id);
 });
 /*
     Add Category
 */
 Route::get('admin/categories/add', function () {
     $vars['token'] = Csrf::token();
     // extended fields
     $vars['fields'] = Extend::fields('category');
     return View::create('categories/add', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer');
 });
 Route::post('admin/categories/add', function () {
     $input = Input::get(array('title', 'slug', 'description'));
     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['show_in_menu'] = is_null($input['show_in_menu']) ? 0 : 1;
     Page::update($id, $input);
     Extend::process('page', $id);
     Notify::success(__('pages.updated'));
     return Response::redirect('admin/pages/edit/' . $id);
 });
 /*
 	Add Page
 */
 Route::get('admin/pages/add', function () {
     $vars['messages'] = Notify::read();
     $vars['token'] = Csrf::token();
     $vars['pages'] = Page::dropdown(array('exclude' => array(), 'show_empty_option' => true));
     $vars['statuses'] = array('published' => __('global.published'), 'draft' => __('global.draft'), 'archived' => __('global.archived'));
     // extended fields
     $vars['fields'] = Extend::fields('page');
     return View::create('pages/add', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer')->partial('editor', 'partials/editor');
 });
 Route::post('admin/pages/add', function () {
     $input = Input::get(array('parent', 'name', 'title', 'slug', 'content', 'status', 'redirect', 'show_in_menu'));
     // if there is no slug try and create one from the title
     if (empty($input['slug'])) {
         $input['slug'] = $input['title'];
     }
     // convert to ascii
     $input['slug'] = slug($input['slug']);
     // encode title
     $input['title'] = e($input['title'], ENT_COMPAT);
     $validator = new Validator($input);
     $validator->add('duplicate', function ($str) {
         return Page::where('slug', '=', $str)->count() == 0;
Ejemplo n.º 4
0
         $input['status'] = 'draft';
     }
     Post::update($id, $input);
     Extend::process('post', $id);
     Notify::success(__('posts.updated'));
     return Response::redirect('admin/posts/edit/' . $id);
 });
 /*
 	Add new post
 */
 Route::get('admin/posts/add', function () {
     $vars['messages'] = Notify::read();
     $vars['token'] = Csrf::token();
     $vars['page'] = Registry::get('posts_page');
     // extended fields
     $vars['fields'] = Extend::fields('post');
     $vars['statuses'] = array('published' => __('global.published'), 'draft' => __('global.draft'), 'archived' => __('global.archived'));
     $vars['categories'] = Category::dropdown();
     $vars['companies'] = Company::dropdown();
     $vars['departments'] = Department::dropdown();
     // echo '<pre>';
     // print_r($vars);exit;
     return View::create('posts/add', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer')->partial('editor', 'partials/editor');
 });
 Route::post('admin/posts/add', function () {
     $input = Input::get(array('title', 'slug', 'description', 'created', 'html', 'css', 'js', 'category', 'status', 'comments', 'company', 'department'));
     // if there is no slug try and create one from the title
     if (empty($input['slug'])) {
         $input['slug'] = $input['title'];
     }
     // convert to ascii
Ejemplo n.º 5
0
         Notify::error($errors);
         return Response::redirect('admin/departments/edit/' . $id);
     }
     if (empty($input['slug'])) {
         $input['slug'] = $input['title'];
     }
     $input['slug'] = slug($input['slug']);
     department::update($id, $input);
     Extend::process('department', $id);
     Notify::successs(__('departments.update'));
     return Response::redirect('admin/departments/edit/' . $id);
 });
 Route::get('admin/departments/add', function () {
     $vars['messages'] = Notify::read();
     $vars['token'] = Csrf::token();
     $vars['fields'] = Extend::fields('department');
     return View::create('departments/add', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer');
 });
 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']);
Ejemplo n.º 6
0
     }
     $post = Post::create($input);
     Extend::process('post', $post->id);
     Notify::success(__('publications.created_book'));
     return Response::redirect('admin/publications');
 });
 /*
     Edit a text-only publication
 */
 Route::get('admin/publications/editPublication/(:num)', function ($id) {
     $vars['messages'] = Notify::read();
     $vars['token'] = Csrf::token();
     $vars['publication'] = Post::find($id);
     $vars['page'] = Registry::get('posts_page');
     // extended fields
     $vars['fields'] = Extend::fields('post', $id);
     $vars['statuses'] = array('published' => __('global.published'), 'draft' => __('global.draft'), 'archived' => __('global.archived'));
     return View::create('publications/editPublication', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer')->partial('editor', 'partials/editor');
 });
 Route::post('admin/publications/editPublication/(:num)', function ($id) {
     $currentPageCategoryId = getCurrentPageCategoryId('publication');
     $input = Input::get(array('title', 'slug', 'description', 'created', 'html', 'css', 'js', 'category', 'status', 'comments'));
     /** Valeurs en dur **/
     $input['comments'] = 0;
     $input['category'] = $currentPageCategoryId;
     // encode title
     $input['title'] = e($input['title'], ENT_COMPAT);
     $validator = new Validator($input);
     $validator->add('duplicate', function ($str) use($id) {
         return Post::where('slug', '=', $str)->where('id', '<>', $id)->count() == 0;
     });
Ejemplo n.º 7
0
    $vars['version'] = $version;
    $vars['url'] = sprintf($url, $version);
    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::post('admin/get_fields', array('before' => 'auth', 'main' => function () {
    $input = Input::get(array('id', 'pagetype'));
    // get the extended fields
    $vars['fields'] = Extend::fields('page', -1, $input['pagetype']);
    $html = View::create('pages/fields', $vars)->render();
    $token = '<input name="token" type="hidden" value="' . Csrf::token() . '">';
    return Response::json(array('token' => $token, 'html' => $html));
}));
/*
	Upload an image
*/
Route::post('admin/upload', array('before' => 'auth', 'main' => function () {
    $uploader = new Uploader(PATH . 'content', array('png', 'jpg', 'bmp', 'gif', 'pdf'));
    $filepath = $uploader->upload($_FILES['file']);
    $uri = Config::app('url', '/') . 'content/' . basename($filepath);
    $output = array('uri' => $uri);
    return Response::json($output);
}));
/*
Ejemplo n.º 8
0
 * Publication Page
 */
Route::get(array('publication', 'publication/(:any)'), function ($pageNumber = 1) {
    $page = Page::slug('publication');
    $category = Category::slug('publication');
    $per_page = Config::meta('posts_per_page');
    list($total, $posts) = Post::listing($category, $pageNumber, $per_page);
    //     get the last page
    $max_page = $total > $per_page ? ceil($total / $per_page) : 1;
    // stop users browsing to non existing ranges
    if ($pageNumber > $max_page or $pageNumber < 1) {
        return Response::create(new Template('404'), 404);
    }
    //Get extend for each post
    for ($i = 0; $i < count($posts); $i++) {
        $e = Extend::fields('post', $posts[$i]->id);
        $newExtendObj = array();
        for ($j = 0; $j < count($e); $j++) {
            $key = $e[$j]->key;
            if (is_null($e[$j]->value) || !property_exists($e[$j]->value, 'text')) {
                $value = $e[$j]->value;
            } else {
                $value = $e[$j]->value->text;
            }
            $newExtendObj[$key] = $value;
        }
        $posts[$i]->extends = $newExtendObj;
    }
    Registry::set('posts', $posts);
    Registry::set('page', $page);
    Registry::set('category', $category);
Ejemplo n.º 9
0
         Notify::error($errors);
         return Response::redirect('admin/companies/edit/' . $id);
     }
     if (empty($input['slug'])) {
         $input['slug'] = $input['title'];
     }
     $input['slug'] = slug($input['slug']);
     Company::update($id, $input);
     Extend::process('company', $id);
     Notify::successs(__('companies.update'));
     return Response::redirect('admin/companies/edit/' . $id);
 });
 Route::get('admin/companies/add', function () {
     $vars['messages'] = Notify::read();
     $vars['token'] = Csrf::token();
     $vars['fields'] = Extend::fields('company');
     return View::create('companies/add', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer');
 });
 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']);