PageRenderTime 58ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 0ms

/kaltura/editor/contributionwizard.php

https://github.com/juho-jaakkola/kaltura_video
PHP | 108 lines | 73 code | 20 blank | 15 comment | 12 complexity | 0bb7a8c156f680c34817b92eb47a6885 MD5 | raw file
  1. <?php
  2. /**
  3. * Kaltura video client
  4. * @package ElggKalturaVideo
  5. * @license http://www.gnu.org/licenses/gpl.html GNU Public License version 3
  6. * @author Ivan Vergés <ivan@microstudi.net>
  7. * @copyright Ivan Vergés 2010
  8. * @link http://microstudi.net/elgg/
  9. */
  10. require_once('../../../../engine/start.php');
  11. elgg_load_library('kaltura_video');
  12. global $KALTURA_GLOBAL_UICONF;
  13. if (!extension_loaded('curl')) {
  14. echo kaltura_get_error_page('',elgg_echo('kalturavideo:error:curl'));
  15. die;
  16. }
  17. $user = elgg_get_logged_in_user_entity();
  18. $container_guid = $user->getGUID();
  19. if ($page_owner = elgg_get_page_owner_entity()) {
  20. if ($page_owner instanceof ElggGroup) {
  21. $container_guid = $page_owner->getGUID();
  22. }
  23. }
  24. try {
  25. //get the current session
  26. $kmodel = KalturaModel::getInstance();
  27. $ks = $kmodel->getClientSideSession();
  28. $kmodel->startSession();
  29. $mediaEntry = new KalturaMediaEntry();
  30. $mediaEntry->name = elgg_echo('kalturavideo:title:video');
  31. //$mediaEntry->editorType = KalturaEditorType_SIMPLE;
  32. //$mediaEntry->adminTags = KALTURA_ADMIN_TAGS;
  33. //$mediaEntry = $kmodel->addMixEntry($mediaEntry);
  34. $mediaEntry->mediaType = KalturaMediaType::VIDEO;
  35. $mediaEntry = $kmodel->client->media->add($mediaEntry);
  36. $entryId = $mediaEntry->id;
  37. } catch(Exception $e) {
  38. $error = $e->getMessage();
  39. }
  40. if (!$entryId && !$error) {
  41. $error = elgg_echo('kalturavideo:error:noid');
  42. }
  43. if ($error) {
  44. echo kaltura_get_error_page('',$error);
  45. die;
  46. } else {
  47. //create the elgg object
  48. $ob = kaltura_update_object($mediaEntry, null, ACCESS_PRIVATE, $user->getGUID(), $container_guid);
  49. //add to the river
  50. add_to_river('river/object/kaltura_video/create', 'create', $user->getGUID(), $ob->getGUID());
  51. $viewData = array();
  52. $kcw = elgg_get_plugin_setting('defaultkcw',"kaltura_video");
  53. if ($kcw == 'custom') {
  54. $kcw_uid = elgg_get_plugin_setting('custom_kcw',"kaltura_video");
  55. } else {
  56. $t = elgg_get_plugin_setting('kaltura_server_type',"kaltura_video");
  57. if (empty($t)) {
  58. $t = 'corp';
  59. }
  60. $editors = $KALTURA_GLOBAL_UICONF['kcw'][$t];
  61. $kswf = $editors[$kcw];
  62. if (empty($kswf)) {
  63. $kswf = current($editors);
  64. }
  65. $kcw_uid = $kswf['uiConfId'];
  66. }
  67. $viewData["flashVars"] = KalturaHelpers::getContributionWizardFlashVars($ks,$entryId);
  68. //$viewData["flashVars"]["showCloseButton"] = "false";
  69. $viewData["swfUrl"] = KalturaHelpers::getContributionWizardUrl($kcw_uid);
  70. $viewData["entryId"] = $entryId;
  71. $viewData["flashVars"]["kshowId"] = "entry-".$entryId;
  72. $flashVarsStr = KalturaHelpers::flashVarsToString($viewData["flashVars"]);
  73. $height = 360;
  74. $width = 680;
  75. $widget = '<object id="kaltura_contribution_wizard" type="application/x-shockwave-flash" allowScriptAccess="always" allowNetworking="all" height="' . $height . '" width="' . $width . '" data="'. $viewData["swfUrl"] . '">'.
  76. '<param name="allowScriptAccess" value="always" />'.
  77. '<param name="allowNetworking" value="all" />'.
  78. '<param name="bgcolor" value=#000000 />'.
  79. '<param name="movie" value="'.$viewData["swfUrl"] . '"/>'.
  80. '<param name="flashVars" value="' . $flashVarsStr . '" />' .
  81. '</object>';
  82. echo $widget;
  83. }
  84. ?>
  85. <script type='text/javascript'>
  86. var entryId = "<?php echo $entryId; ?>";
  87. alert(entryId);
  88. </script>