v.class.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. *
  4. * ----------------------------
  5. * v class
  6. * ----------------------------
  7. *
  8. * An open source application development framework for PHP 5.0 or newer
  9. *
  10. * 这个类,主要负责视频模型数据处理
  11. * @package PHPCMS V9.1.16
  12. * @author chenxuewang
  13. * @copyright CopyRight (c) 2006-2012 上海盛大网络发展有限公司
  14. *
  15. */
  16. class v {
  17. private $db;
  18. public function __construct(&$db) {
  19. $this->db = & $db;
  20. }
  21. /**
  22. *
  23. * add 添加视频方法,将视频入库到视频库中
  24. * @param array $data 视频信息数据
  25. */
  26. public function add($data = array()) {
  27. if (is_array($data) && !empty($data)) {
  28. $data['status'] = 1;
  29. $data['userid'] = defined('IN_ADMIN') ? 0 : intval(param::get_cookie('_userid'));
  30. $data['vid'] = safe_replace($data['vid']);
  31. $vid = $this->db->insert($data, true);
  32. return $vid ? $vid : false;
  33. } else {
  34. return false;
  35. }
  36. }
  37. /**
  38. * function edit
  39. * 编辑视频方法,用户重新编辑已上传的视频
  40. * @param array $data 视频视频信息数组 包括title description tag vid 等信息
  41. * @param int $vid 视频库中视频的主键
  42. */
  43. public function edit($data = array(), $vid = 0) {
  44. if (is_array($data) && !empty($data)) {
  45. $vid = intval($vid);
  46. if (!$vid) return false;
  47. unset($data['vid']);
  48. $this->db->update($data, "`videoid` = '$vid'");
  49. return true;
  50. } else {
  51. return false;
  52. }
  53. }
  54. /**
  55. * function del_video
  56. * 删除视频库中的视频
  57. * @param int $vid 视频ID
  58. */
  59. public function del_video($vid = 0) {
  60. $vid = intval($vid);
  61. if (!$vid) return false;
  62. //删除视频关联的内容,并更新内容页
  63. $this->db->delete(array('videoid'=>$vid));
  64. return true;
  65. }
  66. }
  67. ?>