示例#1
0
 public function insert(Model_Video $video)
 {
     //we don't deal with tags now
     $data = $video->toArray();
     unset($data['tags']);
     return $this->getDbTable()->insert($data);
 }
示例#2
0
 /**
  * Get additional content data selected
  * 
  * @param $result = Query result
  */
 public static function post_find($result)
 {
     if ($result !== null) {
         if (is_array($result)) {
             foreach ($result as $item) {
                 // It will first check if we already have result in temporary result,
                 // and only execute query if we dont. That way we dont have duplicate queries
                 // Get content images
                 $item->get_images = static::lazy_load(function () use($item) {
                     return Model_Image::find(array('where' => array('content_id' => $item->id), 'order_by' => array('sort' => 'asc')));
                 }, $item->id, 'images');
                 // Get content files
                 $item->get_files = static::lazy_load(function () use($item) {
                     return Model_File::find(array('where' => array('content_id' => $item->id), 'order_by' => array('sort' => 'asc')));
                 }, $item->id, 'files');
                 // Get content videos
                 $item->get_videos = static::lazy_load(function () use($item) {
                     return Model_Video::find(array('where' => array('content_id' => $item->id), 'order_by' => array('sort' => 'asc')));
                 }, $item->id, 'videos');
             }
         }
     }
     // return the result
     return $result;
 }
示例#3
0
文件: video.php 项目: 4otaku/4otaku
 protected function get_items()
 {
     $items = $this->load_batch('video');
     foreach ($items as $id => &$item) {
         $item['id'] = $id;
         $item = new Model_Video($item);
         $item->set_display_object('thumb');
         if ($this->area == 'workshop' || sets::user('rights')) {
             $item['is_editable'] = true;
         }
     }
     $this->load_meta($items);
     $this->data['items'] = $items;
     if ($this->count > $this->per_page) {
         $this->data['navi'] = $this->get_bottom_navi('video');
     }
 }
示例#4
0
文件: video.php 项目: 4otaku/4otaku
 public function __construct($reader, $writer)
 {
     parent::__construct($reader, $writer);
     $data = $this->reader->get_data();
     if (empty($data['id']) || !Check::id($data['id'])) {
         throw new Error_Update('Incorrect Id');
     }
     $model = new Model_Video($data['id']);
     $model->load();
     if ($model->is_phantom()) {
         throw new Error_Update('Incorrect Id');
     }
     if ($model['area'] != 'workshop' && !sets::user('rights')) {
         throw new Error_Update('Not enough rights');
     }
     $this->model = $model;
 }
示例#5
0
 /**
  * Удаление записи
  * 
  * @param int $id
  */
 public function action_delete($id = null)
 {
     is_null($id) and \Response::redirect_back('admin/videos');
     if ($video = \Model_Video::find($id)) {
         $video->delete();
         \Session::set_flash('success', 'Видео удалено.');
     } else {
         \Session::set_flash('error', 'Could not delete video #' . $id);
     }
     \Response::redirect_back('admin/videos');
 }
 /**
  * IS: Parameter page terdeklarasi
  * FS: Mengirimkan ke viewer: video, itemPerPage, current, totalItems
  * Desc: Fungsi untuk menampilkan daftar video
  */
 public function indexAction()
 {
     // Param
     $page = $this->_hasParam('page') ? $this->_getParam('page') : 1;
     // Variable
     $maxResult = 8;
     $startIndex = ($page - 1) * ($maxResult - 1) + 1;
     // Model
     $videoModel = new Model_Video();
     // Data
     $videos = $videoModel->getMostViewedVideos($startIndex, $maxResult);
     $totalFeeds = $videoModel->getTotalFeeds();
     // View
     $this->view->videos = $videos;
     $this->view->itemPerPage = $maxResult;
     $this->view->current = $page;
     $this->view->totalItems = $totalFeeds;
     if ($this->_request->isXmlHttpRequest()) {
         $this->_helper->layout()->disableLayout();
         $this->render('list');
     }
 }
示例#7
0
文件: video.php 项目: 4otaku/4otaku
 public function main()
 {
     $post = $this->correct_main_data($this->reader->get_data());
     if (!$post['title']) {
         $this->writer->set_message('Вы забыли указать заголовок для видео.')->set_error(Error_Create::MISSING_INPUT);
         return;
     }
     if (!$post['link']) {
         $this->writer->set_message('Вы не предоставили ссылки, или же ссылка почему-то битая.')->set_error(Error_Create::MISSING_INPUT);
         return;
     }
     $test = new Transform_Video($post['link']);
     if (!$test->enable_nico()->get_html()) {
         $this->writer->set_message('Ссылка не ведет на видео, либо этот видеохостинг не поддерживается')->set_error(Error_Create::INCORRECT_INPUT);
         return;
     }
     $already_have = Database::get_field('video', 'id', 'link = ?', $post['link']);
     if ($already_have) {
         $error = 'Это видео уже у нас есть, оно находится по адресу <a href="/video/' . $already_have . '/">http://4otaku.org/video/' . $already_have . '/</a>.';
         $this->writer->set_message($error)->set_error(Error_Create::ALREADY_EXISTS);
         return;
     }
     if ($post['author'] != def::user('name') && $post['author']) {
         $cookie = new dynamic__cookie();
         $cookie->inner_set('user.name', $post['author']);
     }
     $worker = new Transform_Meta();
     $parsed_tags = $worker->parse_array($post['tag']);
     $tags = $worker->add_tags($parsed_tags);
     $category = $worker->category($post['category']);
     $parsed_author = $worker->parse($post['author'], def::user('author'));
     $author = $worker->author($parsed_author);
     $text = Transform_Text::format($post['text']);
     $item = new Model_Video();
     $item->set_array(array('title' => $post['title'], 'link' => $post['link'], 'text' => $text, 'pretty_text' => undo_safety($post['text']), 'author' => $author, 'category' => $category, 'tag' => $tags));
     $item->insert();
     // TODO: перемести input__common::transfer в Model_Common
     if (!empty($post['transfer_to'])) {
         input__common::transfer(array('sure' => 1, 'do' => array('video', 'transfer'), 'where' => $post['transfer_to'], 'id' => $item->get_id()));
     }
     $this->writer->set_success()->set_message('Ваша видео успешно добавлено, и доступно по адресу ' . '<a href="/video/' . $item->get_id() . '/">http://4otaku.org/video/' . $item->get_id() . '/</a> или в ' . '<a href="/video/' . def::area(1) . '/">очереди на премодерацию</a>.')->set_param('id', $item->get_id());
 }
示例#8
0
 public function action_index()
 {
     $sort = $this->request->param('sort', 'title');
     $order = $this->request->param('order', 'ASC');
     //Session::instance()->delete('course_id');
     $criteria = array('filters' => array('title' => $this->request->param('filter_title'), 'description' => $this->request->param('filter_description')));
     $total = Model_Video::video_total($criteria);
     $pagination = Pagination::factory(array('total_items' => $total, 'items_per_page' => 5));
     $criteria = array_merge($criteria, array('sort' => $sort, 'order' => $order, 'limit' => $pagination->items_per_page, 'offset' => $pagination->offset));
     $videos = Model_Video::videos($criteria);
     $sorting = new Sort(array('Title' => 'title', 'Description' => 'description'));
     $url = 'video/index';
     if ($this->request->param('filter_title')) {
         $url .= '/filter_title/' . $this->request->param('filter_title');
         $filter = $this->request->param('filter_title');
         $filter_select = 'filter_title';
     }
     if ($this->request->param('filter_description')) {
         $url .= '/filter_description/' . $this->request->param('filter_description');
         $filter = $this->request->param('filter_description');
         $filter_select = 'filter_description';
     }
     $sorting->set_link($url);
     $sorting->set_order($order);
     $sorting->set_sort($sort);
     $heading = $sorting->render();
     // Render the pagination links
     $pagination = $pagination->render();
     $links_old = array('delete' => URL::site('/video/delete/'), 'add' => URL::site('/video/add/'), 'search' => URL::site('/video/search/'));
     $table = array('data' => $videos);
     $filter_title = $this->request->param('filter_title');
     $filter_description = $this->request->param('filter_description');
     $filter_url = URL::site('video/index');
     $success = Session::instance()->get('success');
     Session::instance()->delete('success');
     $view = View::factory('video/list')->bind('table', $table)->bind('count', $total)->bind('links_old', $links_old)->bind('pagination', $pagination)->bind('filter', $filter)->bind('filter_select', $filter_select)->bind('filter_url', $filter_url)->bind('success', $success);
     $this->content = $view;
 }
示例#9
0
 /**
  * Get additional content data selected
  * 
  * @param $result = Query result
  */
 public static function post_find($result)
 {
     if ($result !== null) {
         if (is_array($result)) {
             foreach ($result as $item) {
                 // It will first check if we already have result in temporary result,
                 // and only execute query if we dont. That way we dont have duplicate queries
                 // Get content images
                 $item->get_images = static::lazy_load(function () use($item) {
                     return Model_Image::find(array('where' => array('content_id' => $item->id), 'order_by' => array('sort' => 'asc')));
                 }, $item->id, 'images');
                 // Get content files
                 $item->get_files = static::lazy_load(function () use($item) {
                     return Model_File::find(array('where' => array('content_id' => $item->id), 'order_by' => array('sort' => 'asc')));
                 }, $item->id, 'files');
                 // Get content videos
                 $item->get_videos = static::lazy_load(function () use($item) {
                     return Model_Video::find(array('where' => array('content_id' => $item->id), 'order_by' => array('sort' => 'asc')));
                 }, $item->id, 'videos');
                 // Get content children
                 $item->get_children = static::lazy_load(function () use($item) {
                     return Model_Casestudy::find(array('where' => array('parent_id' => $item->id), 'order_by' => array('sort' => 'asc')));
                 }, $item->id, 'children');
                 // Get content accordions
                 $item->get_accordions = static::lazy_load(function () use($item) {
                     return Model_Accordion::find(array('where' => array('parent_id' => $item->id), 'order_by' => array('sort' => 'asc')));
                 }, $item->id, 'accordions');
                 // Get content children
                 $item->get_seo = static::lazy_load(function () use($item) {
                     return Model_Seo::find_one_by_content_id($item->id);
                 }, $item->id, 'seo', 'object');
                 // Get related products
                 $item->get_related_products = static::lazy_load(function () use($item) {
                     $related = Model_Application_To_Related::find(function ($query) use($item) {
                         return $query->where('application_id', $item->id);
                     }, 'related_id');
                     if (!empty($related)) {
                         $related = '(' . implode(',', array_keys($related)) . ')';
                         return \Product\Model_Product::find(function ($query) use($related, $item) {
                             $query->where('id', 'IN', \DB::expr($related));
                             $query->where('id', '<>', $item->id);
                             $query->order_by('sort', 'asc');
                             return $query;
                         }, 'id');
                     }
                     return array();
                 }, $item->id, 'related_products');
                 // Get hotspot images
                 $item->get_hotspot = static::lazy_load(function () use($item) {
                     $return = new \stdClass();
                     $return->images = Model_Application_Image::find_by_application_id($item->id);
                     return $return;
                 }, $item->id, 'hotspot', 'object');
             }
         }
     }
     // return the result
     return $result;
 }
 public function videolistAction()
 {
     if (Zend_Auth::getInstance()->hasIdentity()) {
         $id = $this->_getParam('iVideoCategoryId');
         $eventsList = new Model_Video();
         $this->view->list = $eventsList->getDocListByCat($id);
     }
 }
示例#11
0
 /**
  * Delete content file
  * 
  * @param $video_id		= Video ID
  * @param $content_id	= Content ID
  */
 public function action_delete_video($video_id = false, $content_id = false)
 {
     if ($video_id && $content_id) {
         $videos = Model_Video::find(array('where' => array('content_id' => $content_id), 'order_by' => array('sort' => 'asc')), 'id');
         if ($videos) {
             if (isset($videos[$video_id])) {
                 $video = $videos[$video_id];
                 // If there is only one video and video is required
                 if (count($videos) == 1) {
                     if (\Config::get('details.video.required', false)) {
                         \Messages::error('You can\'t delete all videos. Please add new video in order to delete this one.');
                     } else {
                         // Reset sort fields
                         \DB::update(Model_Video::get_protected('_table_name'))->value('sort', \DB::expr('sort - 1'))->where('sort', '>', $video->sort)->execute();
                         // Delete video
                         $this->delete_image($video->thumbnail, 'video');
                         $video->delete();
                         \Messages::success('Video was successfully deleted.');
                     }
                 } else {
                     // Reset sort fields
                     \DB::update(Model_Video::get_protected('_table_name'))->value('sort', \DB::expr('sort - 1'))->where('sort', '>', $video->sort)->execute();
                     // Delete video
                     $this->delete_image($video->thumbnail, 'video');
                     $video->delete();
                     \Messages::success('Video was successfully deleted.');
                 }
             } else {
                 \Messages::error('Video you are trying to delete don\'t exists. Check your url and try again.');
             }
         } else {
             \Messages::error('Video you are trying to delete don\'t exists. Check your url and try again.');
         }
     }
     \Response::redirect(\Input::referrer(\Uri::create('admin/application/list')));
 }
示例#12
0
文件: video.php 项目: 4otaku/4otaku
 protected function get_video($url)
 {
     $video = new Model_Video($this->data['id']);
     $video->load();
     return $video;
 }
示例#13
0
 /**
  * Get additional content data selected
  * 
  * @param $result = Query result
  */
 public static function post_find($result)
 {
     if ($result !== null) {
         if (is_array($result)) {
             foreach ($result as $item) {
                 // It will first check if we already have result in temporary result,
                 // and only execute query if we dont. That way we dont have duplicate queries
                 // Get content images
                 $item->get_images = static::lazy_load(function () use($item) {
                     return Model_Image::find(array('where' => array('content_id' => $item->id), 'order_by' => array('sort' => 'asc')));
                 }, $item->id, 'images');
                 // Get first content image
                 $item->get_image = static::lazy_load(function () use($item) {
                     if (!empty($item->images)) {
                         return $item->images[0];
                     }
                 }, $item->id, 'image', 'object');
                 // Get content files
                 $item->get_files = static::lazy_load(function () use($item) {
                     return Model_File::find(array('where' => array('content_id' => $item->id), 'order_by' => array('sort' => 'asc')));
                 }, $item->id, 'files');
                 // Get content videos
                 $item->get_videos = static::lazy_load(function () use($item) {
                     return Model_Video::find(array('where' => array('content_id' => $item->id), 'order_by' => array('sort' => 'asc')));
                 }, $item->id, 'videos');
                 // Get content parent
                 $item->get_parent = static::lazy_load(function () use($item) {
                     return Model_Page::find_one_by_id($item->parent_id);
                 }, $item->id, 'parent', 'object');
                 // Get content children
                 $item->get_children = static::lazy_load(function () use($item) {
                     return Model_Page::find(array('where' => array('parent_id' => $item->id), 'order_by' => array('sort' => 'asc')));
                 }, $item->id, 'children');
                 // Get content accordions
                 $item->get_accordions = static::lazy_load(function () use($item) {
                     return Model_Accordion::find(array('where' => array('parent_id' => $item->id), 'order_by' => array('sort' => 'asc')));
                 }, $item->id, 'accordions');
                 // Get content children
                 $item->get_seo = static::lazy_load(function () use($item) {
                     return Model_Seo::find_one_by_content_id($item->id);
                 }, $item->id, 'seo', 'object');
             }
         }
     }
     // return the result
     return $result;
 }
示例#14
0
 /**
  * Действие для отображения слайдера
  */
 public function action_videos()
 {
     // Выбираем первых 5 слайдеров
     $data['videos'] = \Model_Video::find('all');
     return \View::forge('widgets/videos', $data)->render();
 }
示例#15
0
 public function action_index()
 {
     require $_SERVER['DOCUMENT_ROOT'] . "/application/vendor/vimeo/autoload.php";
     $client_id = '';
     $client_secret = '';
     $token = '';
     $token_secret = '';
     $vimeo = new \Vimeo\Vimeo($client_id, $client_secret, $token);
     $categories = $vimeo->request("/categories");
     foreach ($categories['body']['data'] as $category) {
         // $categoryArray = array('Animation', 'Arts & Design', 'Cameras & Techniques', 'Comedy', 'Documentary', 'Experimental', 'Fashion', 'Food', 'Instructionals', 'Music', 'Narrative', 'Personal', 'Reporting & Journalism', 'Sports', 'Talks'));
         // if (in_array($category['name'], $categoryArray)) {
         // 	continue;
         // }
         $categoryShortName = str_replace('/categories/', '', $category['uri']);
         for ($i = 1; $i <= 20; $i++) {
             sleep(1);
             echo 'page ' . $i . ' of ' . $category['uri'];
             $videos = $vimeo->request($category['uri'] . '/videos', array('sort' => 'plays', 'per_page' => 50, 'page' => $i));
             // echo '<pre>'; print_r($videos); echo '</pre>'; exit;
             foreach ($videos['body']['data'] as $video) {
                 // Prepares video data array
                 $videoSpecs['uri'] = $video['uri'];
                 $videoSpecs['name'] = $video['name'];
                 $videoSpecs['description'] = $video['description'];
                 $videoSpecs['link'] = $video['link'];
                 $videoSpecs['duration'] = $video['duration'];
                 $videoSpecs['width'] = $video['width'];
                 $videoSpecs['height'] = $video['height'];
                 $videoSpecs['create_time'] = $video['created_time'];
                 $videoSpecs['plays'] = $video['stats']['plays'];
                 $videoSpecs['likes'] = $video['metadata']['connections']['likes']['total'];
                 $videoSpecs['comments'] = $video['metadata']['connections']['comments']['total'];
                 if ($video['privacy']['embed'] === 'public') {
                     $videoSpecs['embeddable'] = true;
                 } else {
                     $videoSpecs['embeddable'] = false;
                 }
                 // Look for existing record
                 $videoOrm = ORM::factory('Video')->where('uri', '=', $video['uri'])->find_all()->as_array();
                 if (sizeOf($videoOrm) === 0) {
                     // Add record to DB if it doesn't exist
                     $videoRecord = new Model_Video();
                     $videoRecord->values($videoSpecs);
                     $videoRecord->save();
                     $videoId = $videoRecord->id;
                     $videoOrm = ORM::factory('Video')->where('uri', '=', $video['uri'])->find();
                     // Populate tags table with video data
                     foreach ($video['tags'] as $tag) {
                         $tagRecord = new Model_Tag();
                         $tagRecord->values(array('video_id' => $videoId, 'name' => $tag['name']));
                         $tagRecord->save();
                     }
                 } else {
                     // Update record if it exists
                     $videoOrm[0]->values($videoSpecs);
                     $videoOrm[0]->save();
                     $videoId = $videoOrm[0]->id;
                 }
                 // Populate categories table category data if that video and category association is not already stored
                 $categoryOrm = ORM::factory('Category')->where('video_id', '=', $videoId)->and_where('short_name', '=', $categoryShortName)->find_all();
                 if ($categoryOrm->count() === 0) {
                     $categoryRecord = new Model_Category();
                     $categoryRecord->values(array('video_id' => $videoId, 'name' => $category['name'], 'short_name' => $categoryShortName));
                     $categoryRecord->save();
                 }
             }
         }
     }
 }