Exemplo n.º 1
0
 /**
  * Создание новой записи
  */
 public function action_create()
 {
     if (\Input::method() == 'POST') {
         $val = \Model_Video::validate('create');
         if ($val->run()) {
             $video = \Model_Video::forge(array('videoid' => \Input::post('videoid')));
             if ($video and $video->save()) {
                 \Session::set_flash('success', 'Видео добавлено.');
                 \Response::redirect_back('admin/videos');
             } else {
                 \Session::set_flash('error', 'Could not save video.');
             }
         } else {
             \Session::set_flash('error', $val->error());
         }
     }
     $this->template->content = \View::forge('videos/create');
 }
Exemplo n.º 2
0
 /**
  * Insert or update application videos
  * Certain array structure need to be passed
  * 
  * array(
  * 	0 => array(
  * 		'id' 	=> If numeric and larger than 0, file will be updated. Otherwise file is considered new
  * 		'data'	=> Array of file data to insert
  * 	),
  * 	1 => array(
  * 		'id' 	=> If numeric and larger than 0, file will be updated. Otherwise file is considered new
  * 		'data'	=> Array of file data to insert
  * 	),
  * 	etc.
  * )
  * 
  * @param $files
  */
 public static function bind_videos($videos = array())
 {
     if (empty($videos) || !is_array($videos)) {
         return false;
     }
     foreach ($videos as $key => $video) {
         $data = $video['data'];
         if (is_numeric($video['id']) && $video['id'] > 0) {
             // Update existing video
             $item = Model_Video::find_one_by_id($video['id']);
             $item->set($data);
         } else {
             $item = Model_Video::forge($data);
         }
         $item->save();
     }
 }
Exemplo n.º 3
0
 /**
  * Insert or update page videos
  * Certain array structure need to be passed
  * 
  * array(
  * 	0 => array(
  * 		'id' 	=> If numeric and larger than 0, file will be updated. Otherwise file is considered new
  * 		'data'	=> Array of file data to insert
  * 	),
  * 	1 => array(
  * 		'id' 	=> If numeric and larger than 0, file will be updated. Otherwise file is considered new
  * 		'data'	=> Array of file data to insert
  * 	),
  * 	etc.
  * )
  * 
  * @param $files
  */
 public static function bind_videos($videos = array())
 {
     if (empty($videos) || !is_array($videos)) {
         return false;
     }
     foreach ($videos as $key => $video) {
         $item = Model_Video::forge($video['data']);
         if (is_numeric($video['id']) && $video['id'] > 0) {
             // Update existing videos
             $item->set(array('id' => $video['id']));
             $item->is_new(false);
         }
         $item->save();
     }
 }