form.inc.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. function video($field, $value, $fieldinfo) {
  2. $value_data = '';
  3. //获取flash上传属性
  4. pc_base::load_app_class('ku6api', 'video', 0);
  5. $setting = getcache('video', 'video');
  6. if(empty($setting)) return L('please_input_video_setting');
  7. $ku6api = new ku6api($setting['sn'], $setting['skey']);
  8. $flash_info = $ku6api->flashuploadparam();
  9. //获取上传的视频
  10. $key = 0;
  11. $list_str = "<div style='padding:1px'><ul class=\"tbsa\" id=\"video_{$field}_list\">";
  12. if($value) {
  13. $video_content_db = pc_base::load_model('video_content_model');
  14. $video_store_db = pc_base::load_model('video_store_model');
  15. $videos = $video_content_db->select(array('contentid'=>$this->id), 'videoid, listorder', '', '`listorder` ASC', '', 'videoid');
  16. if (!empty($videos)) {
  17. $videoids = '';
  18. foreach ($videos as $v) {
  19. $videoids .= $v['videoid'].',';
  20. }
  21. $videoids = substr($videoids, 0, -1);
  22. $result = $video_store_db->select("`videoid` IN($videoids)", '`videoid`, `title`, `picpath`', '', '', '', 'videoid');
  23. if (is_array($result)) {
  24. //首先对$result按照$videos的videoid排序
  25. foreach ($videos as $_vid => $v) {
  26. $new_result[] = $result[$_vid];
  27. }
  28. unset($result, $_vid, $v);
  29. foreach ($new_result as $_k => $r) {
  30. $key = $_k+1;
  31. $picpath = $r['picpath'] ? $r['picpath'] : IMG_PATH.'nopic.gif';
  32. $list_str .= "<li class=\"ac\" id=\"video_{$field}_{$key}\"><div class=\"r1\"><img src=\"{$r['picpath']}\" onerror=\"".IMG_PATH."nopic.jpg\" width=\"132\" height=\"75\"><input type='text' name='{$field}_video[{$key}][title]' value='".$r['title']."' class=\"input-text ipt_box\"><input type='hidden' name='{$field}_video[{$key}][videoid]' value='{$r[videoid]}'><div class=\"r2\"><span class=\"l\"><label>".L('listorder')."</label><input type='text' name='{$field}_video[$key][listorder]' value='".$videos[$r['videoid']]['listorder']."' class=\"input-text\"></span><span class=\"r\"> <a href=\"javascript:remove_div('video_{$field}_{$key}')\">".L('delete')."</a></span></li>";
  33. }
  34. }
  35. }
  36. }
  37. $list_str .= "</ul></div>";
  38. $data = '';
  39. if (!defined('SWFOBJECT_INIT')) {
  40. $data .= '<script type="text/javascript" src="'.JS_PATH.'video/swfobject2.js"></script>';
  41. $data .= '<script type="text/javascript" src="'.JS_PATH.'video/vod2ckedit.js"></script>';
  42. define('SWFOBJECT_INIT', 1);
  43. $data .= '<SCRIPT LANGUAGE="JavaScript">
  44. <!--
  45. var js4swf = {
  46. onInit: function(list)
  47. {
  48. // 初始化时调用, 若 list.length > 0 代表有可续传文件
  49. // [{file}, {file}]
  50. if(list.length > 0) {
  51. var length = list.length-1;
  52. $("#list_name").html("'.L('file', '', 'video').'"+list[length].name+"'.L('failed_uplaod_choose_again', '', 'video').'");
  53. }
  54. this.showMessage("init", list);
  55. },
  56. onSelect: function(files)
  57. {
  58. // 选中文件后调用, 返回文件列表
  59. // [{file}, {file}]
  60. this.showMessage("select", files);
  61. },
  62. onSid: function(evt)
  63. {
  64. // 获得 sid 后返回, 更新 sid 用 (key, sid, name, type, size)
  65. $("#video_title").val(evt.name);
  66. var ku6vid = evt.vid;
  67. $.get(\'index.php\', {m:\'video\', c:\'vid\', a:\'check\', vid:ku6vid});
  68. this.showMessage("sid", evt);
  69. },
  70. onStart: function()
  71. {
  72. // 开始上传 (选择文件后自动开始)
  73. this.showMessage("start");
  74. },
  75. onCancel: function()
  76. {
  77. // 上传取消事件
  78. this.showMessage("cancel");
  79. },
  80. onProgress: function(evt)
  81. {
  82. // 上传进度事件 (bytesLoaded, bytesTotal, speed) m=1 时没有这事件
  83. this.showMessage("progress", evt);
  84. },
  85. onComplete: function(evt)
  86. {
  87. // 上传完成事件 (包含文件信息和完成后返回数据(data))
  88. $("#vid").val(evt.vid);
  89. var video_num = parseInt($("#key").val()) + 1;
  90. var title = $("#video_title").val();
  91. var vid = $("#vid").val();
  92. var html = "<li id=\"video_'.$field.'_"+video_num+"\"><div class=\"r1\"><img src=\"'.IMG_PATH.'nopic.jpg\" width=\"132\" height=\"75\"><input type=\"text\" name=\"'.$field.'_video["+video_num+"][title]\" value=\""+title+"\" class=\"input-text\"><input type=\"hidden\" name=\"'.$field.'_video["+video_num+"][vid]\" value=\""+vid+"\"><div class=\"r2\"><span class=\"l\"><label>'.L('listorder').'</label><input type=\"text\" class=\"input-text\" name=\"'.$field.'_video["+video_num+"][listorder]\" value=\""+video_num+"\" ></span><span class=\"r\"> <a href=\"javascript:remove_div(\'video_'.$field.'_"+video_num+"\')\">'.L('delete').'</a></span></li>";
  93. $("#video_'.$field.'_list").append(html);
  94. $("#key").val(video_num);
  95. $("#video_title").val("");
  96. swfobject.embedSWF("'.$flash_info['flashurl'].'", "ku6uploader", "450", "45", "10.0.0", null, flashvars, params, attributes);
  97. //document.getElementById("frm").submit();
  98. this.showMessage("complete", evt);
  99. },
  100. onWarn: function(evt)
  101. {
  102. // 报错事件 (key, message)
  103. //this.showMessage("warn", evt);
  104. alert(evt.msg);
  105. },
  106. showMessage: function()
  107. {
  108. console.log(arguments);
  109. }
  110. };
  111. //-->
  112. </SCRIPT>
  113. <script type="text/javascript">
  114. var flashvars = { m: "1", u: "'.$flash_info['userid'].'", ctime: "'.$flash_info['passport_ctime'].'", sig:"'.$flash_info['passport_sig'].'", c: "vms", t: "1", n: "js4swf", k: "190000" ,ms:"39",s: "8000000"};
  115. var params = { allowScriptAccess: "always" , wmode: "transparent"};
  116. var attributes = { };
  117. //swfobject.embedSWF("http://player.ku6cdn.com/default/podcast/upload/201104261840/ku6uploader.swf", "ku6uploader", "450", "45", "10.0.0", null, flashvars, params, attributes);
  118. swfobject.embedSWF("'.$flash_info['flashurl'].'", "ku6uploader", "450", "45", "10.0.0", null, flashvars, params, attributes);
  119. </script>';
  120. }
  121. $authkey = upload_key("$upload_number,$upload_allowext,$isselectimage");
  122. $video_store_sel = defined('IN_ADMIN') ? '<div class="picBut cu video_btn" style="float:right; margin-top:10px;"><a herf="javascript:void(0);" onclick="javascript:video_store_select(\''.$field.'_videoes\', \''.L('choose_videoes').'\',\'video_'.$field.'_list\',change_videoes, \''.$_GET['pc_hash'].'\')"> '.L('videoes_store').' </a></div>' : '';
  123. $vms_str = $flash_info['allow_upload_to_vms'] ? '<label class="ib cu" style="width:125px"><input type="radio" name="channelid" value="2">'. L('upload_to_ku6vms', '', 'video').' </label>' : '';
  124. return $data.'<input name="info['.$field.']" type="hidden" value="1"><input type="hidden" id="key" value="'.$key.'"><fieldset class="blue pad-10">
  125. <legend>'.L('videoes_lists').'</legend><center><div class="onShow" id="nameTip">'.L('videoes_num').'</center><div id="videoes" class="picList">'.$list_str.'</div>
  126. </fieldset>
  127. <table width="100%" border="0" cellspacing="1" class="tbb">
  128. <tbody><tr>
  129. <td width="15%" height="40">'.L('select_upload_channel', '', 'video').'</td>
  130. <td height="40"><label class="ib cu" style="width:125px"><input type="radio" name="channelid" value="1" checked> '.L('upload_to_ku6').' </label>'.$vms_str.'
  131. </td>
  132. </tr>
  133. <tr>
  134. <td width="15%" height="40"><div align="right" ><input class="input_style" type="text" value="'.L('video_title', '', 'video').'" name="video_title" id="video_title" size="10"></div></td>
  135. <td height="40">
  136. '.$video_store_sel.'
  137. <div id="ku6uploader"></div><BR><span id="list_name" style="color:red"></span></td><input type="hidden" id="vid" name="vid" value="">
  138. </tr>
  139. </tbody></table>';
  140. }