Changeset 1651

Show
Ignore:
Timestamp:
12/30/2007 02:36:02 PM (12 months ago)
Author:
Shadowhand
Message:

Much polish on website admin. Hooray for fancy pants.

Location:
branches/website/application
Files:
2 added
1 removed
3 modified

Legend:

Unmodified
Added
Removed
  • branches/website/application/controllers/admin.php

    r1649 r1651  
    2727                        // User must be logged in 
    2828                        is_object($this->user) and $this->user->has_role('developer') or url::redirect('admin/login'); 
    29                 } 
     29 
     30                        Event::add_before('system.post_controller', array($this, '_display'), array($this, '_add_breadcrumb')); 
     31                } 
     32        } 
     33 
     34        public function _add_breadcrumb() 
     35        { 
     36                $crumbs = View::factory('admin/breadcrumb') 
     37                        ->set('crumbs', html::breadcrumb()) 
     38                        ->render(); 
     39 
     40                $this->template->content = $crumbs.$this->template->content; 
    3041        } 
    3142 
     
    3344        { 
    3445                // Send them to the right page 
    35                 url::redirect('admin/login'); 
     46                url::redirect('admin/dashboard'); 
    3647        } 
    3748 
     
    95106                        { 
    96107                                // Create a list of all users 
    97                                 $users[$user->id] = $user->username; 
    98                         } 
    99  
    100                         $this->template->content = View::factory('admin/user_list')->set('users', $users); 
     108                                $users[$user->username] = $user->username; 
     109                        } 
     110 
     111                        $this->template->content = View::factory('admin/edit_list') 
     112                                ->set('new', 'Add a new user') 
     113                                ->set('items', $users) 
     114                                ->set('edit_action', 'admin/manage_users') 
     115                                ->set('delete_action', 'admin/delete_user'); 
    101116                } 
    102117                else 
     
    199214        } 
    200215 
    201         public function add_video_tutorial() 
    202         { 
    203                 $form = new Forge(NULL, $this->template->title = 'Create Tutorial'); 
    204                 $form->input('title')->label(TRUE)->rules('required|length[4,64]'); 
    205                 $form->input('author')->label(TRUE)->rules('required|length[4,64]'); 
    206                 $form->input('copyright')->label(TRUE)->rules('required|length[4]|valid_digit'); 
    207                 $form->input('video')->label('File')->rules('required|length[2,127]'); 
    208                 $form->input('width')->label(TRUE)->rules('required|length[2,3]|valid_digit'); 
    209                 $form->input('height')->label(TRUE)->rules('required|length[2,3]|valid_digit'); 
    210                 $form->submit('Save'); 
    211  
    212                 if ($form->validate()) 
    213                 { 
    214                         // Create new object 
    215                         $tutorial = new Video_Tutorial_Model; 
    216  
    217                         foreach($form->as_array() as $key => $val) 
    218                         { 
    219                                 // Set object data 
    220                                 $tutorial->$key = $val; 
    221                         } 
    222  
    223                         if ($tutorial->save()) 
    224                         { 
    225                                 // Set the message 
    226                                 $this->session->set_flash('message', '<p><strong>Success!</strong> New tutorial has been created.</p>'); 
    227                         } 
    228  
    229                         // Go back to dashboard 
    230                         url::redirect('admin/dashboard'); 
    231                 } 
    232  
    233                 // Set content 
    234                 $this->template->content = $form->html(); 
     216        public function manage_video_tutorials($id = FALSE) 
     217        { 
     218                if ($id === FALSE) 
     219                { 
     220                        $this->template->title = 'Manage Users'; 
     221 
     222                        $list = View::factory('admin/edit_list') 
     223                                ->set('new', 'Add a new video') 
     224                                ->set('edit_action', 'admin/manage_video_tutorials') 
     225                                ->set('delete_action', 'admin/delete_video_tutorial') 
     226                                ->bind('items', $items); 
     227 
     228                        foreach (ORM::factory('video_tutorial')->find(ALL) as $tutorial) 
     229                        { 
     230                                // Create a list of all tutorials 
     231                                $items[$tutorial->video] = $tutorial->title; 
     232                        } 
     233 
     234                        $this->template->content = $list->render(); 
     235                } 
     236                else 
     237                { 
     238                        ($id === 'new') and $id = FALSE; 
     239 
     240                        // Load tutorial 
     241                        $tutorial = new Video_Tutorial_Model($id); 
     242 
     243                        $form = new Forge(NULL, $this->template->title = ($tutorial->id ? 'Update Tutorial' : 'New Tutorial')); 
     244                        $form->input('title')->label(TRUE)->rules('required|length[4,64]')->value($tutorial->title); 
     245                        $form->input('author')->label(TRUE)->rules('required|length[4,64]')->value($tutorial->author); 
     246                        $form->input('copyright')->label(TRUE)->rules('required|length[4]|valid_digit')->value($tutorial->copyright); 
     247                        $form->input('video')->label('File')->rules('required|length[2,127]')->value($tutorial->video); 
     248                        $form->input('width')->label(TRUE)->rules('required|length[2,3]|valid_digit')->value($tutorial->width); 
     249                        $form->input('height')->label(TRUE)->rules('required|length[2,3]|valid_digit')->value($tutorial->height); 
     250                        $form->submit('Save'); 
     251 
     252                        if ($form->validate()) 
     253                        { 
     254                                foreach($form->as_array() as $key => $val) 
     255                                { 
     256                                        // Set object data 
     257                                        $tutorial->$key = $val; 
     258                                } 
     259 
     260                                if ($tutorial->save()) 
     261                                { 
     262                                        // Set the message 
     263                                        $this->session->set_flash('message', '<p><strong>Success!</strong> Tutorial was saved successfully.</p>'); 
     264                                } 
     265 
     266                                // Go back to dashboard 
     267                                url::redirect('admin/dashboard'); 
     268                        } 
     269 
     270                        // Set content 
     271                        $this->template->content = $form->html(); 
     272                } 
    235273        } 
    236274 
  • branches/website/application/models/video_tutorial.php

    r1392 r1651  
    1616        protected function where_key($id) 
    1717        { 
    18                 if (is_string($id) AND ! empty($id)) 
     18                if ( ! empty($id) AND is_string($id) AND ! ctype_digit($id)) 
    1919                { 
    2020                        // Allow searches by video 
  • branches/website/application/views/media/css/layout.css

    r1648 r1651  
    2121/* Container */ 
    2222.container { position: relative; clear: both; } 
     23 
     24/* Breadcrumb */ 
     25.breadcrumb { padding: 0 0.3em 0.3em; margin-bottom: 1.5em; border-bottom: dotted 1px #3f5c0b; font-size: 0.8em; color: #555; } 
     26 
     27/* Edit List */ 
     28ul.edit_list .new { list-style-type: none; line-height: 220%; font-weight: bold; } 
     29ul.edit_list li { vertical-align: middle; } 
     30ul.edit_list span { font-size: 0.8em; padding-left: 0.5em; opacity: 0.8; } 
     31ul.edit_list span:hover { opacity: 1.0; } 
     32 
     33/* Messages */ 
     34p.message { font-weight: bold; text-align: center; font-size: 1.2em; } 
     35p.confirm { text-align: center; } 
     36p.confirm a { font-size: 1.2em; padding: 0 0.3em; } 
    2337 
    2438/* Developer Menu */ 
     
    91105        #flash span { display: block; cursor: pointer; width: 8em; text-align: bottom; margin: 0 auto; padding: 6em 0.5em 1em; background: #2f2f2f; } 
    92106        #flash .alt span { display: none; } 
    93  
    94 /* Common Styles */ 
    95 ul.user_list .new { line-height: 300%; font-weight: bold; } 
    96 ul.user_list li { vertical-align: middle; } 
    97 ul.user_list span { font-size: 0.8em; padding-left: 0.5em; } 
    98  
    99 p.message { font-weight: bold; text-align: center; font-size: 1.2em; } 
    100 p.confirm { text-align: center; } 
    101 p.confirm a { font-size: 1.2em; padding: 0 0.3em; }