PasteSite.Com

Recent Pastes

Sign Up!

PasteSite is open to the public, but with limited features. Register to be able to modify access rights, track your pastes and more...

Change the theme

If you prefer reading light text on a dark background to dark text on a light background, then you might want to try the dark theme.

This paste is a reply. View the Previous Paste?
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
<?php
class Admin_Videos extends Wrapper_Admin {
 
    public function Categories( Turnware_Request $request ){
        $categories = $this->Model( 'VideoCategories' )->order( array( 'sort_order', 'desc' ) );
        return $this->View( 'Admin/Videos/Categories.html', array(
            'categories' => $categories,
            'category_count' => count( $categories )
        ) );
    }
 
    public function AddEdit( Turnware_Request $request, $category ){
        // Set the rules for this form
        $category->form->setRuleSet( 'AdminVideoCategories' );
 
        // Does this form pass validation?
        if( !$category->form->validates() ){
            return $this->View( 'Admin/Videos/AddEditCategory.html', array(
                'category' => $category,
                'form' => $category->form,
                'mode' => ( $categoryId === false ) ? 'add' : 'edit'
            ) );
        }
 
        // Insert or update, then redirect back
        $category->save();
        $request->redirect( 'admin_videos_categories' );
    }
    
    public function Delete( Turnware_Request $requestm, $category ){
        $category->delete();
        $request->redirect( 'admin_videos_categories' );
    }
 
}

Reply to This Paste

(leave blank to make this paste permanent)
(if set as private)