From 1ba53509473098a614f2c1e6cfd8304416c30671 Mon Sep 17 00:00:00 2001 From: MosheMaorKaltura Date: Sun, 21 Jul 2024 12:05:20 +0300 Subject: [PATCH 01/96] PLAT-24912: v2 to v7 --- .../actions/embedIframeJsAction.class.php | 26 ++++++++++++++++++- alpha/lib/model/uiConf.php | 3 ++- api_v3/lib/types/KalturaUiConf.php | 7 +++++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php index 454531a8d5b..abad98d85cb 100644 --- a/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php @@ -47,7 +47,6 @@ public function execute() $ui_conf_html5_url = $uiConf->getHtml5Url(); - if (array_key_exists($partner_id, $optimizedPlayback)) { // force a specific kdp for the partner @@ -61,6 +60,14 @@ public function execute() $autoEmbed = $this->getRequestParameter('autoembed'); $iframeEmbed = $this->getRequestParameter('iframeembed'); + + //redirect the call to V7 + if($this->getRequestParameter('v2tov7')) + { + $this->redirectToV7($uiConf->getV7Id(), $partner_id); + } + + $scriptName = ($iframeEmbed) ? 'mwEmbedFrame.php' : 'mwEmbedLoader.php'; if($ui_conf_html5_url && $iframeEmbed) { $ui_conf_html5_url = str_replace('mwEmbedLoader.php', 'mwEmbedFrame.php', $ui_conf_html5_url); @@ -143,4 +150,21 @@ public function execute() header("Location:$url"); KExternalErrors::dieGracefully(); } + + /* + * v2 - https://cdnapisec.kaltura.com/p/1915851/sp/191585100/embedIframeJs/uiconf_id/32880931/partner_id/1915851?iframeembed=true&playerId=kaltura_player_1719900446&entry_id=1_aeg07vpv + * v7 - https://cdnapisec.kaltura.com/p/1915851/embedPlaykitJs/uiconf_id/54813242?iframeembed=true&entry_id=1_aeg07vpv + * Test - http://www.kaltura.local/p/102/sp/10200/embedIframeJs/uiconf_id/23448128/partner_id/102?iframeembed=true&playerId=kaltura_player_1719900446&entry_id=0_3eil6eqs + */ + private function redirectToV7($v7Id, $partnerId) : void + { + if(!$v7Id) + { + return; + } + $host = myPartnerUtils::getCdnHost($partnerId, null , 'api'); + $url = $host . "/p/" . $partnerId . '/embedPlaykitJs/uiconf_id/' . $v7Id . "?" . $_SERVER['QUERY_STRING'];; + header("Location:$url"); + KExternalErrors::dieGracefully(); + } } diff --git a/alpha/lib/model/uiConf.php b/alpha/lib/model/uiConf.php index 7c3b67c1388..e2ac5ec3be8 100644 --- a/alpha/lib/model/uiConf.php +++ b/alpha/lib/model/uiConf.php @@ -701,7 +701,8 @@ public function getSwfNames() return self::$swf_names; } - + public function getV7Id(){ return $this->getFromCustomData( "v7_id", null , null ); } + public function setV7Id($v){ return $this->putInCustomData( "v7_id", $v ); } public function getAutoplay () { return $this->getFromCustomData( "autoplay" , null , false ); } public function setAutoplay( $v ) { return $this->putInCustomData( "autoplay", $v ); } diff --git a/api_v3/lib/types/KalturaUiConf.php b/api_v3/lib/types/KalturaUiConf.php index 5f5e47e9f89..19b712f2ab6 100644 --- a/api_v3/lib/types/KalturaUiConf.php +++ b/api_v3/lib/types/KalturaUiConf.php @@ -155,6 +155,12 @@ class KalturaUiConf extends KalturaObject implements IFilterable * @filter mlikeor, mlikeand */ public $partnerTags; + + + /** + * @var string + */ + public $v7id; private static $map_between_objects = array @@ -183,6 +189,7 @@ class KalturaUiConf extends KalturaObject implements IFilterable "config", "version", "partnerTags", + "v7id" ); public function getMapBetweenObjects ( ) From 6141087392c0f3d4f0e5ccdaefe3a6fc6301f00a Mon Sep 17 00:00:00 2001 From: MosheMaorKaltura Date: Thu, 8 Aug 2024 09:29:21 +0300 Subject: [PATCH 02/96] PLAT-24912: add support in redirection player v2 to v7 --- alpha/apps/kaltura/lib/v2Tov7Utils.class.php | 128 ++++++++++++++++++ .../actions/embedIframeJsAction.class.php | 39 ++++-- .../actions/embedPlaykitJsAction.class.php | 108 ++++++++++++++- alpha/lib/model/uiConf.php | 19 ++- api_v3/lib/types/KalturaUiConf.php | 22 ++- 5 files changed, 298 insertions(+), 18 deletions(-) create mode 100644 alpha/apps/kaltura/lib/v2Tov7Utils.class.php diff --git a/alpha/apps/kaltura/lib/v2Tov7Utils.class.php b/alpha/apps/kaltura/lib/v2Tov7Utils.class.php new file mode 100644 index 00000000000..29b847a39d0 --- /dev/null +++ b/alpha/apps/kaltura/lib/v2Tov7Utils.class.php @@ -0,0 +1,128 @@ + $value) + { + if(self::isVarPlugin($key)) + { + //get plugin name + KalturaLog::log("V2 to V7 adding plugin: " . $key. " value:" . $value); + if ($value) { + if (!$bundleConfig) { + $bundleConfig = []; + } + $key = trim(trim($key, '"'), "'"); + $v2PluginName = explode(".", $key); + try + { + $v7PluginName = self::getV7PluginInfo($v2PluginName[0]); + $bundleConfig = array_merge($bundleConfig, [$v7PluginName[0] => "{latest}"]); + $v7PluginConfig = $v7PluginName[1]; + if (!isset($playerConfig->plugins)) { + $playerConfig->plugins = new stdClass(); + } + if (!isset($playerConfig->plugins->$v7PluginConfig)) { + $playerConfig->plugins->$v7PluginConfig = new stdClass(); + } + } + catch (Exception $e){ + $unHandledPlugins[] = $e->getMessage(); + } + } + } + } + if(sizeof($unHandledPlugins)) + { + throw new Exception ("Unhandled plugins: " . implode(", ", $unHandledPlugins)); + } + } + + static function addV2toV7config($config, $flashvars, $uiconfId) + { + //Merge v7 config + if (!isset($config["provider"])) { + $config["provider"] = new stdClass(); + } + $unHandledVars = array(); + $config["uiconf_id"] = $uiconfId; + if($flashvars) + { + foreach ($flashvars as $key => $value) { + if(self::isVarPlugin($key)) + { + continue; + } + $key = trim(trim($key, '"'), "'"); + $providerParams = ["partnerId", "uiconf_id", "entry_id", "cache_st", "wid", "ks", "autoPlay", "playlistAPI.autoContinue"]; + if (in_array($key, $providerParams)) { + if ($value) { + KalturaLog::log("V2toV7 adding {$key}: " . $value); + $config["provider"]->$key = $value; + } + } + else{ + $unHandledVars[] = $key; + } + } + if(sizeof($unHandledVars)) + { + throw new Exception("UnHandled params:" . implode(",",$unHandledVars)); + } + } + + return $config; + } + + private static function isVarPlugin($varKeyName) + { + return str_contains($varKeyName, ".plugin"); + } + + private static function v2toV7PluginMap() + { + return + ["info" => ["playkitscreen", "playkit-js-info"], + "quiz" => ["playkit-ivq", "ivq"], + "moderation" => ["playkit-moderation", "playkit-js-moderation"], + "playlistAPI" => ["playkit-playlist", "playlist"], + "liveStatus" => ["playkit-kaltura-live","kaltura-live"], + "related" => ["playkit-related", "related"], + "dualScreen" => ["playkit-dual-screen", "dualscreen"], + "video360" => ["playkit-vr" ,"vr"], + "raptMedia" => ["rapt", "rapt"], + "transcript" => ["playkit-transcript", "playkit-js-transcript"], + "qna" => ["playkit-qna", "qna"], + "bumper" => [ "playkit-bumper" , "bumper" ], + "infoScreen" => ["playkit-info", "playkit-js-info"]]; + } +} \ No newline at end of file diff --git a/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php index abad98d85cb..a62ba6fe41a 100644 --- a/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php @@ -1,4 +1,7 @@ getRequestParameter('iframeembed'); //redirect the call to V7 - if($this->getRequestParameter('v2tov7')) + if($uiConf->getV2tov7id() && ($this->getRequestParameter(v2Tov7Utils::V2TOV7_PARAM_NAME) || $uiConf->getV2tov7Approved()) ) { - $this->redirectToV7($uiConf->getV7Id(), $partner_id); + $this->redirectToV7($uiConf->getV2tov7id(), $uiconf_id, $partner_id, $uiConf->getShouldTranslatePluginsToV7() ); } @@ -156,14 +159,34 @@ public function execute() * v7 - https://cdnapisec.kaltura.com/p/1915851/embedPlaykitJs/uiconf_id/54813242?iframeembed=true&entry_id=1_aeg07vpv * Test - http://www.kaltura.local/p/102/sp/10200/embedIframeJs/uiconf_id/23448128/partner_id/102?iframeembed=true&playerId=kaltura_player_1719900446&entry_id=0_3eil6eqs */ - private function redirectToV7($v7Id, $partnerId) : void + private function redirectToV7($v7Id, $v2UiConfId, $partnerId, $shouldTranslatePlugins) : void { - if(!$v7Id) - { - return; - } + //validate all the params are handled + try + { + $config = array(); + $config["bundleConfig"] = null; + $config["playerConfig"] = new stdClass(); + $config = v2Tov7Utils::addV2toV7config($config,$this->getRequestParameter(v2Tov7Utils::FLASHVARS_PARAM_NAME),$v7Id); + if($shouldTranslatePlugins) + { + v2Tov7Utils::addV2toV7plugins( + $this->getRequestParameter(v2Tov7Utils::FLASHVARS_PARAM_NAME), + $config["bundleConfig"], + $config["playerConfig"]); + } + } + catch(Exception $e) + { + //if we failed, then should not redirect! + KalturaLog::log("V2toV7 was rejected because: " . $e->getMessage() . " v2 id:" . $v2UiConfId. " v7 dd:" . $v2UiConfId); + return; + } + $host = myPartnerUtils::getCdnHost($partnerId, null , 'api'); - $url = $host . "/p/" . $partnerId . '/embedPlaykitJs/uiconf_id/' . $v7Id . "?" . $_SERVER['QUERY_STRING'];; + $url = $host . "/p/" . $partnerId . '/embedPlaykitJs/uiconf_id/' . $v7Id . "?" . $_SERVER['QUERY_STRING'] . "&" + . v2Tov7Utils::FLASHVARS_PARAM_NAME . "=true&v2tov7translatePlugins=" + . v2Tov7Utils::SHOULD_TRANSLATE_PLUGINS . "=true" ;; header("Location:$url"); KExternalErrors::dieGracefully(); } diff --git a/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php index e7a2880c809..34d9df89e92 100644 --- a/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php @@ -1,5 +1,5 @@ bundle_name, array("embedPlaykitJsAction", "buildBundleLocked"), array($this)); } + + $lastModified = $this->getLastModified($bundleContent); //Format bundle content $bundleContent = $this->formatBundleContent($bundleContent, $i18nContent, $extraModulesNames); + if($this->getRequestParameter(v2Tov7Utils::V2TOV7_PARAM_NAME)) + { + KalturaLog::log("Adding v2 to v7"); + // $v2ToV7Code = PHP_EOL . '!function(){"use strict";var e={453:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.thumbnailEmbedV2=t.embed=void 0;const i=n(593),o=window.KalturaPlayer;t.embed=e=>{console.log("## config -----\x3e",e);const t=e.hasOwnProperty("entry_id"),n=e.hasOwnProperty("playlistAPI.kpl0Id");try{const i=o.setup({log:{level:"DEBUG"},targetId:e.targetId,provider:{partnerId:e.wid.match(/\d+/g).join(""),uiConfId:e.uiconf_id}});t?i.loadMedia({entryId:e.entry_id}):n&&i.loadPlaylist({playlistId:e["playlistAPI.kpl0Id"]})}catch(e){}},t.thumbnailEmbedV2=e=>{try{const t={config:{targetId:e.targetId,provider:{partnerId:e.wid.match(/\d+/g).join(""),uiConfId:e.uiconf_id}},mediaInfo:{entryId:e.entry_id}};(0,i.thumbnailEmbed)(t)}catch(e){}}},593:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.ThumbnailEmbedComponent=t.thumbnailEmbed=void 0;const i=n(14);Object.defineProperty(t,"ThumbnailEmbedComponent",{enumerable:!0,get:function(){return i.ThumbnailEmbedComponent}});const o=n(512);Object.defineProperty(t,"thumbnailEmbed",{enumerable:!0,get:function(){return o.thumbnailEmbed}}),window.__thumbnailEmbed=o.thumbnailEmbed},14:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ThumbnailEmbedComponent=void 0;const n="#000";t.ThumbnailEmbedComponent=({onClick:e,src:t,bgColor:i=n})=>{const o=window.KalturaPlayer,{Button:r,Icon:d,IconType:a}=o.ui.components,{h:l}=o.ui.preact,{useRef:u,useState:c,useCallback:m}=o.ui.preactHooks,s=m((()=>{e(),v(!1)})),b=m((()=>{g(!0)})),p=m((()=>{g(!0),E(!0)})),h=u(),[y,v]=c(!0),[f,g]=c(!1),[I,E]=c(!1);return y?l("div",{style:{width:"100%",height:"100%",position:"relative",backgroundColor:I?i:n}},I?void 0:l("img",{src:t,ref:h,onLoad:b,onError:p,style:{width:"100%",height:"100%","object-fit":"contain"}}),f?l("div",{className:o.ui.style.prePlaybackPlayOverlay,style:{width:"100%",height:"100%"}},l(r,{className:o.ui.style.prePlaybackPlayButton,tabIndex:0,onClick:s},l(d,{type:a.Play}))):void 0):void 0}},512:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.thumbnailEmbed=void 0;const i=n(14);t.thumbnailEmbed=({config:e,mediaInfo:t,mediaOptions:n={},version:o=1e4,bgColor:r})=>{if(!e||!t)return;const d=(e=>{var t,n,i,o;if(null===(t=e.provider.env)||void 0===t?void 0:t.cdnUrl)return null===(n=e.provider.env)||void 0===n?void 0:n.cdnUrl;const r=window.__kalturaplayerdata;return r?null===(o=null===(i=r.provider)||void 0===i?void 0:i.env)||void 0===o?void 0:o.cdnUrl:"https://cdnapisec.kaltura.com"})(e),{targetId:a,provider:{partnerId:l,ks:u}}=e,c=window.KalturaPlayer;var m=document.getElementById(a);if(!m||!c||c.getPlayer&&c.getPlayer(a))return;let s=1920,b=1080;m.clientWidth&&m.clientHeight&&(s=m.clientWidth,b=m.clientHeight);const p=`${d.endsWith("/")?d:d+"/"}p/${l}/sp/${l}00/thumbnail/entry_id/${t.entryId}/version/${o}/width/${s}/height/${b}`+(u?`/ks/${u}`:""),{h:h,render:y}=c.ui.preact;y(h(i.ThumbnailEmbedComponent,{src:p,bgColor:r,onClick:()=>{try{const i=c.setup(e);i.loadMedia(t,n),i.play()}catch(e){}}}),m)}}},t={};function n(i){var o=t[i];if(void 0!==o)return o.exports;var r=t[i]={exports:{}};return e[i](r,r.exports,n),r.exports}!function(){const e=n(453);window.kWidget={embed:e.embed,thumbEmbed:e.thumbnailEmbedV2}}()}();//# sourceMappingURL=kWidget-embed.js.map";' . PHP_EOL; + $v2ToV7Code = PHP_EOL . PHP_EOL . '!function(){"use strict";var e={593:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.ThumbnailEmbedComponent=t.thumbnailEmbed=void 0;const o=n(14);Object.defineProperty(t,"ThumbnailEmbedComponent",{enumerable:!0,get:function(){return o.ThumbnailEmbedComponent}});const i=n(512);Object.defineProperty(t,"thumbnailEmbed",{enumerable:!0,get:function(){return i.thumbnailEmbed}}),window.__thumbnailEmbed=i.thumbnailEmbed},14:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ThumbnailEmbedComponent=void 0;const n="#000";t.ThumbnailEmbedComponent=({onClick:e,src:t,bgColor:o=n})=>{const i=window.KalturaPlayer,{Button:r,Icon:d,IconType:a}=i.ui.components,{h:l}=i.ui.preact,{useRef:s,useState:u,useCallback:c}=i.ui.preactHooks,m=c((()=>{e(),h(!1)})),b=c((()=>{g(!0)})),p=c((()=>{g(!0),P(!0)})),y=s(),[f,h]=u(!0),[v,g]=u(!1),[I,P]=u(!1);return f?l("div",{style:{width:"100%",height:"100%",position:"relative",backgroundColor:I?o:n}},I?void 0:l("img",{src:t,ref:y,onLoad:b,onError:p,style:{width:"100%",height:"100%","object-fit":"contain"}}),v?l("div",{className:i.ui.style.prePlaybackPlayOverlay,style:{width:"100%",height:"100%"}},l(r,{className:i.ui.style.prePlaybackPlayButton,tabIndex:0,onClick:m},l(d,{type:a.Play}))):void 0):void 0}},512:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.thumbnailEmbed=void 0;const o=n(14);t.thumbnailEmbed=({config:e,mediaInfo:t,mediaOptions:n={},version:i=1e4,bgColor:r})=>{if(!e||!t)return;const d=(e=>{var t,n,o,i;if(null===(t=e.provider.env)||void 0===t?void 0:t.cdnUrl)return null===(n=e.provider.env)||void 0===n?void 0:n.cdnUrl;const r=window.__kalturaplayerdata;return r?null===(i=null===(o=r.provider)||void 0===o?void 0:o.env)||void 0===i?void 0:i.cdnUrl:"https://cdnapisec.kaltura.com"})(e),{targetId:a,provider:{partnerId:l,ks:s}}=e,u=window.KalturaPlayer;var c=document.getElementById(a);if(!c||!u||u.getPlayer&&u.getPlayer(a))return;let m=1920,b=1080;c.clientWidth&&c.clientHeight&&(m=c.clientWidth,b=c.clientHeight);const p=`${d.endsWith("/")?d:d+"/"}p/${l}/sp/${l}00/thumbnail/entry_id/${t.entryId}/version/${i}/width/${m}/height/${b}`+(s?`/ks/${s}`:""),{h:y,render:f}=u.ui.preact;f(y(o.ThumbnailEmbedComponent,{src:p,bgColor:r,onClick:()=>{try{const o=u.setup(e);o.loadMedia(t,n),o.play()}catch(e){}}}),c)}},371:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.thumbEmbed=t.embed=void 0;const o=n(593),i=n(890),r=window.KalturaPlayer;t.embed=e=>{console.log("## v2Config -----\x3e",e);const{targetId:t,partnerId:n,uiConfId:o,mediaInfo:d}=(0,i.getInfoFromV2Config)(e);let a={log:{level:"DEBUG"},targetId:t,provider:{partnerId:n}};const l=(0,i.buildConfigFromFlashvars)(e),s=Object.assign({},a,l);try{const e=r.setup(s),n=document.getElementById(t);n&&(n.addJsListener=(t,n)=>{"mediaLoaded"===t&&e.addEventListener("medialoaded",(()=>{n()}))});const o=d.id;d.isPlaylist?e.loadPlaylist({playlistId:o}):e.loadMedia({entryId:o})}catch(e){}},t.thumbEmbed=e=>{const{targetId:t,partnerId:n,uiConfId:r,mediaInfo:d}=(0,i.getInfoFromV2Config)(e);try{const e={config:{targetId:t,provider:{partnerId:n}},mediaInfo:{entryId:d.id}};(0,o.thumbnailEmbed)(e)}catch(e){}}},890:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.buildConfigFromFlashvars=t.getMediaInfo=t.getInfoFromV2Config=void 0,t.getInfoFromV2Config=e=>({targetId:e.targetId,partnerId:e.wid.match(/\d+/g).join(""),uiConfId:e.uiconf_id,mediaInfo:(0,t.getMediaInfo)(e)}),t.getMediaInfo=e=>{if(e.entry_id)return{id:e.entry_id,isPlaylist:!1};let t="";const n=e.flashvars;return n.hasOwnProperty("playlistAPI.kpl0Id")?t=n["playlistAPI.kpl0Id"]:n.hasOwnProperty("playlistAPI")&&n.playlistAPI.hasOwnProperty("kpl0Id")&&(t=n.playlistAPI.kpl0Id),{id:t,isPlaylist:!0}},t.buildConfigFromFlashvars=e=>{let t={text:{},playback:{},streaming:{},abr:{},drm:{},network:{},plugins:{}};if(e.hasOwnProperty("flashvars")){const n=e.flashvars;n.hasOwnProperty("autoPlay")&&(t.playback.autoplay=n.autoPlay)}return t}}},t={};function n(o){var i=t[o];if(void 0!==i)return i.exports;var r=t[o]={exports:{}};return e[o](r,r.exports,n),r.exports}!function(){const e=n(371);window.kWidget={embed:e.embed,thumbEmbed:e.thumbEmbed}}()}();'; + $bundleContent = $bundleContent . $v2ToV7Code; + } // send cache headers $this->sendHeaders($bundleContent, $lastModified); @@ -484,9 +495,11 @@ private function getAutoEmbedCode($targetId = null) } $config = $this->getRequestParameter(self::CONFIG_PARAM_NAME, array()); //enable passing nested config options + //KalturaLog::log("Autoembed:" .$config); foreach ($config as $key=>$val) { $config[$key] = json_decode($val); + KalturaLog::log("Key:" .$key ." value:" . $val); } if (!isset($config["provider"])) @@ -498,7 +511,6 @@ private function getAutoEmbedCode($targetId = null) $config["provider"]->uiConfId = $this->uiconfId; $ks = $this->getRequestParameter(self::KS_PARAM_NAME); - if ($ks) { $config["provider"]->ks = $ks; @@ -506,6 +518,12 @@ private function getAutoEmbedCode($targetId = null) $config["targetId"] = $targetId; + //Add v2 to v7 config + if($this->uiConf->getV2tov7id() && ($this->getRequestParameter(v2Tov7Utils::V2TOV7_PARAM_NAME) || $this->uiConf->getV2tov7Approved()) ) + { + $config = v2Tov7Utils::addV2toV7config($config,$this->getRequestParameter(v2Tov7Utils::FLASHVARS_PARAM_NAME),$this->uiconfId); + } + $config = json_encode($config); if ($config === false) { @@ -543,7 +561,7 @@ private function getIfarmEmbedCode($bundleContent)
- + '; @@ -576,6 +594,7 @@ private function mergeVersionsParamIntoConfig() if (!$this->bundleConfig) { $this->bundleConfig = array(); } + KalturaLog::log("versionsArr" . print_r($versionsArr,true)); $this->bundleConfig = array_merge($this->bundleConfig, $versionsArr); } } @@ -813,6 +832,15 @@ private function initMembers() } $this->mergeVersionsParamIntoConfig(); + + if($this->getRequestParameter(v2Tov7Utils::V2TOV7_PARAM_NAME) && $this->getRequestParameter(v2Tov7Utils::SHOULD_TRANSLATE_PLUGINS)) + { + v2Tov7Utils::addV2toV7plugins( + $this->getRequestParameter(v2Tov7Utils::FLASHVARS_PARAM_NAME), + $this->bundleConfig, + $this->playerConfig); + } + if (!$this->bundleConfig) { KExternalErrors::dieError(KExternalErrors::MISSING_PARAMETER, "unable to resolve bundle config"); } @@ -822,6 +850,8 @@ private function initMembers() $this->setBundleName(); } + + private function setBundleName() { //sort bundle config by key @@ -844,4 +874,76 @@ public function getRequestParameter($name, $default = null) return $returnValue ? $returnValue : $default; } +// private function getTranslatedPluginName($v2PluginName) +// { +// KalturaLog::log("Searching for " . $v2PluginName. " " . strlen($v2PluginName)); +// $translation = ["info" => ["playkit-info","playkit-js-info"], +// "quiz" => ["playkit-ivq","ivq"], +// "moderation" => ["playkit-moderation","playkit-js-moderation" ], +// "playlist" => ["playkit-playlist","playlist"]]; +// $v7PluginName = $translation[$v2PluginName]; +// KalturaLog::log("Found " . print_r($v7PluginName,true)); +// return $v7PluginName; +// } +// +// +// private function addV2toV7plugins(){ +// //Merge v7 config +// if($this->getRequestParameter(self::V2TOV7_PARAM_NAME, false)) { +// $flashvars = $this->getRequestParameter(self::FLASHVARS_PARAM_NAME); +// foreach ($flashvars as $key => $value) { +// if (strpos($key, ".plugin") !== false) { +// //get plugin name +// KalturaLog::log("V2 to V7 adding plugin: " . $key); +// if ($value) { +// if (!$this->bundleConfig) { +// $this->bundleConfig = array(); +// } +// $key = trim(trim($key, '"'), "'"); +// $v2PluginName = explode(".", $key); +// $v7PluginName = $this->getTranslatedPluginName($v2PluginName[0]); +// KalturaLog::log("v7PluginName: " . $v7PluginName[0] . " configName: " . $v7PluginName[1]); +// $this->bundleConfig = array_merge($this->bundleConfig, [$v7PluginName[0] => "{latest}"]); +// KalturaLog::log("bundleConfig" . print_r($this->bundleConfig, true)); +// $v7PluginConfig = $v7PluginName[1]; +// if(!isset($this->playerConfig->plugins->$v7PluginConfig)) +// { +// if(!isset($this->playerConfig->plugins)) +// { +// $this->playerConfig->plugins = new stdClass(); +// } +// +// $this->playerConfig->plugins->$v7PluginConfig = new stdClass(); +// KalturaLog::log("adding plugin config :" . print_r( $this->playerConfig->plugins,true)); +// } +// +// } +// } +// } +// } +// } +// +// private function addV2toV7config($config){ +// //Merge v7 config +// if($this->getRequestParameter(self::V2TOV7_PARAM_NAME, false)) { +// if (!isset($config["provider"])) { +// $config["provider"] = new stdClass(); +// } +// $config["uiconf_id"] = $this->uiconfId; +// $flashvars = $this->getRequestParameter("flashvars"); +// foreach ($flashvars as $key => $value) { +// +// $key = trim(trim($key, '"'), "'"); +// $providerParams = ["partnerId","uiconf_id","entry_id","cache_st","wid","ks","autoPlay","playlistAPI.autoContinue"]; +// if (in_array($key,$providerParams)) { +// if ($value) { +// KalturaLog::log("V2 to V7 adding ks: " . $value); +// $config["provider"]->$key = $value; +// } +// } +// } +// } +// return $config; +// } + } diff --git a/alpha/lib/model/uiConf.php b/alpha/lib/model/uiConf.php index e2ac5ec3be8..0e8aa21091d 100644 --- a/alpha/lib/model/uiConf.php +++ b/alpha/lib/model/uiConf.php @@ -113,6 +113,11 @@ class uiConf extends BaseuiConf implements ISyncableFile, IRelatedObject const CUSTOM_DATA_CON_FILE_VERSION = 'conf_file_version'; const CUSTOM_DATA_CONF_FILE_FEATURES_VERSION = 'conf_file_features_version'; + + //v2 to b7 + const CUSTOM_DATA_V2V7_ID = "v2v7_id"; + const CUSTOM_DATA_V2V7_APPROVED = "v2v7_approved"; + const CUSTOM_DATA_V2V7_TRANSLATE_PLUGINS = "v2v7_trnanslate_plugins"; public function save(PropelPDO $con = null) { @@ -701,8 +706,10 @@ public function getSwfNames() return self::$swf_names; } - public function getV7Id(){ return $this->getFromCustomData( "v7_id", null , null ); } - public function setV7Id($v){ return $this->putInCustomData( "v7_id", $v ); } + + + + public function getAutoplay () { return $this->getFromCustomData( "autoplay" , null , false ); } public function setAutoplay( $v ) { return $this->putInCustomData( "autoplay", $v ); } @@ -810,4 +817,12 @@ public function setVersion($v, $subType = self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG return parent::setVersion($v); } + + //v2 to v7 + public function getV2tov7id(){ return $this->getFromCustomData( self::CUSTOM_DATA_V2V7_ID, null , null ); } + public function setV2tov7id($v){ return $this->putInCustomData( self::CUSTOM_DATA_V2V7_ID, $v ); } + public function getV2tov7Approved(){ return $this->getFromCustomData( self::CUSTOM_DATA_V2V7_APPROVED, null, false , null ); } + public function setV2tov7Approved($v){ return $this->putInCustomData( self::CUSTOM_DATA_V2V7_APPROVED, $v ); } + public function getShouldTranslatePluginsToV7(){ return $this->getFromCustomData( self::CUSTOM_DATA_V2V7_TRANSLATE_PLUGINS, null,false , null ); } + public function setShouldTranslatePluginsToV7($v){ return $this->putInCustomData( self::CUSTOM_DATA_V2V7_TRANSLATE_PLUGINS, $v ); } } diff --git a/api_v3/lib/types/KalturaUiConf.php b/api_v3/lib/types/KalturaUiConf.php index 19b712f2ab6..a5887652b4a 100644 --- a/api_v3/lib/types/KalturaUiConf.php +++ b/api_v3/lib/types/KalturaUiConf.php @@ -160,10 +160,20 @@ class KalturaUiConf extends KalturaObject implements IFilterable /** * @var string */ - public $v7id; - - - private static $map_between_objects = array + public $v2tov7id; + + /** + * @var string + */ + public $v2tov7Approved; + + /** + * @var string + */ + public $v2tov7ShouldTranslatePlugins; + + + private static $map_between_objects = array ( "id" , "creationMode" , @@ -189,7 +199,9 @@ class KalturaUiConf extends KalturaObject implements IFilterable "config", "version", "partnerTags", - "v7id" + "v2tov7id", + "v2tov7Approved", + "v2tov7ShouldTranslatePlugins" => "shouldTranslatePluginsToV7" ); public function getMapBetweenObjects ( ) From 106a9f35c4b200003e403c1911ec56a94196d497 Mon Sep 17 00:00:00 2001 From: MosheMaorKaltura Date: Thu, 8 Aug 2024 12:31:31 +0300 Subject: [PATCH 03/96] PLAT-24912: add support in v2 to v7 --- .../actions/embedPlaykitJsAction.class.php | 73 ------------------- 1 file changed, 73 deletions(-) diff --git a/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php index 34d9df89e92..8048624d5cb 100644 --- a/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php @@ -873,77 +873,4 @@ public function getRequestParameter($name, $default = null) $returnValue = parent::getRequestParameter($name, $default); return $returnValue ? $returnValue : $default; } - -// private function getTranslatedPluginName($v2PluginName) -// { -// KalturaLog::log("Searching for " . $v2PluginName. " " . strlen($v2PluginName)); -// $translation = ["info" => ["playkit-info","playkit-js-info"], -// "quiz" => ["playkit-ivq","ivq"], -// "moderation" => ["playkit-moderation","playkit-js-moderation" ], -// "playlist" => ["playkit-playlist","playlist"]]; -// $v7PluginName = $translation[$v2PluginName]; -// KalturaLog::log("Found " . print_r($v7PluginName,true)); -// return $v7PluginName; -// } -// -// -// private function addV2toV7plugins(){ -// //Merge v7 config -// if($this->getRequestParameter(self::V2TOV7_PARAM_NAME, false)) { -// $flashvars = $this->getRequestParameter(self::FLASHVARS_PARAM_NAME); -// foreach ($flashvars as $key => $value) { -// if (strpos($key, ".plugin") !== false) { -// //get plugin name -// KalturaLog::log("V2 to V7 adding plugin: " . $key); -// if ($value) { -// if (!$this->bundleConfig) { -// $this->bundleConfig = array(); -// } -// $key = trim(trim($key, '"'), "'"); -// $v2PluginName = explode(".", $key); -// $v7PluginName = $this->getTranslatedPluginName($v2PluginName[0]); -// KalturaLog::log("v7PluginName: " . $v7PluginName[0] . " configName: " . $v7PluginName[1]); -// $this->bundleConfig = array_merge($this->bundleConfig, [$v7PluginName[0] => "{latest}"]); -// KalturaLog::log("bundleConfig" . print_r($this->bundleConfig, true)); -// $v7PluginConfig = $v7PluginName[1]; -// if(!isset($this->playerConfig->plugins->$v7PluginConfig)) -// { -// if(!isset($this->playerConfig->plugins)) -// { -// $this->playerConfig->plugins = new stdClass(); -// } -// -// $this->playerConfig->plugins->$v7PluginConfig = new stdClass(); -// KalturaLog::log("adding plugin config :" . print_r( $this->playerConfig->plugins,true)); -// } -// -// } -// } -// } -// } -// } -// -// private function addV2toV7config($config){ -// //Merge v7 config -// if($this->getRequestParameter(self::V2TOV7_PARAM_NAME, false)) { -// if (!isset($config["provider"])) { -// $config["provider"] = new stdClass(); -// } -// $config["uiconf_id"] = $this->uiconfId; -// $flashvars = $this->getRequestParameter("flashvars"); -// foreach ($flashvars as $key => $value) { -// -// $key = trim(trim($key, '"'), "'"); -// $providerParams = ["partnerId","uiconf_id","entry_id","cache_st","wid","ks","autoPlay","playlistAPI.autoContinue"]; -// if (in_array($key,$providerParams)) { -// if ($value) { -// KalturaLog::log("V2 to V7 adding ks: " . $value); -// $config["provider"]->$key = $value; -// } -// } -// } -// } -// return $config; -// } - } From 231426abd390d67c8417931867f05373675f10ec Mon Sep 17 00:00:00 2001 From: MosheMaorKaltura Date: Thu, 8 Aug 2024 13:20:55 +0300 Subject: [PATCH 04/96] PLAT-24912: code review remarks --- alpha/apps/kaltura/lib/v2Tov7Utils.class.php | 232 +++++++++--------- .../actions/embedIframeJsAction.class.php | 47 ++-- .../actions/embedPlaykitJsAction.class.php | 39 ++- alpha/lib/model/uiConf.php | 22 +- 4 files changed, 168 insertions(+), 172 deletions(-) diff --git a/alpha/apps/kaltura/lib/v2Tov7Utils.class.php b/alpha/apps/kaltura/lib/v2Tov7Utils.class.php index 29b847a39d0..ccd11b26d9a 100644 --- a/alpha/apps/kaltura/lib/v2Tov7Utils.class.php +++ b/alpha/apps/kaltura/lib/v2Tov7Utils.class.php @@ -2,127 +2,127 @@ class v2Tov7Utils { - const V2TOV7_PARAM_NAME = 'v2tov7'; - const FLASHVARS_PARAM_NAME = 'flashvars'; - const SHOULD_TRANSLATE_PLUGINS = self::V2TOV7_PARAM_NAME ."translate"; + const V2TOV7_PARAM_NAME = 'v2tov7'; + const FLASHVARS_PARAM_NAME = 'flashvars'; + const SHOULD_TRANSLATE_PLUGINS = self::V2TOV7_PARAM_NAME ."translate"; - static private function getV7PluginInfo($v2PluginName): array - { - KalturaLog::log("Searching for " . $v2PluginName . " " . strlen($v2PluginName)); - $translation = self::v2toV7PluginMap(); - if(isset($translation[$v2PluginName])) - { - $v7PluginInfo = $translation[$v2PluginName]; - KalturaLog::log("Found " . print_r($v7PluginInfo, true)); - return $v7PluginInfo; - } - else - { - throw new Exception ($v2PluginName); - } - } + static private function getV7PluginInfo($v2PluginName): array + { + KalturaLog::log("Searching for " . $v2PluginName . " " . strlen($v2PluginName)); + $translation = self::v2toV7PluginMap(); + if(isset($translation[$v2PluginName])) + { + $v7PluginInfo = $translation[$v2PluginName]; + KalturaLog::log("Found " . print_r($v7PluginInfo, true)); + return $v7PluginInfo; + } + else + { + throw new Exception ($v2PluginName); + } + } - static function addV2toV7plugins($flashvars, &$bundleConfig, &$playerConfig) - { - if(!$flashvars) - { - return; - } - $unHandledPlugins = array(); + static function addV2toV7plugins($flashvars, &$bundleConfig, &$playerConfig) + { + if(!$flashvars) + { + return; + } + $unHandledPlugins = array(); - //Merge v7 config - foreach ($flashvars as $key => $value) - { - if(self::isVarPlugin($key)) - { - //get plugin name - KalturaLog::log("V2 to V7 adding plugin: " . $key. " value:" . $value); - if ($value) { - if (!$bundleConfig) { - $bundleConfig = []; - } - $key = trim(trim($key, '"'), "'"); - $v2PluginName = explode(".", $key); - try - { - $v7PluginName = self::getV7PluginInfo($v2PluginName[0]); - $bundleConfig = array_merge($bundleConfig, [$v7PluginName[0] => "{latest}"]); - $v7PluginConfig = $v7PluginName[1]; - if (!isset($playerConfig->plugins)) { - $playerConfig->plugins = new stdClass(); - } - if (!isset($playerConfig->plugins->$v7PluginConfig)) { - $playerConfig->plugins->$v7PluginConfig = new stdClass(); - } - } - catch (Exception $e){ - $unHandledPlugins[] = $e->getMessage(); - } - } - } - } - if(sizeof($unHandledPlugins)) - { - throw new Exception ("Unhandled plugins: " . implode(", ", $unHandledPlugins)); - } - } + //Merge v7 config + foreach ($flashvars as $key => $value) + { + if(self::isVarPlugin($key)) + { + //get plugin name + KalturaLog::log("V2 to V7 adding plugin: " . $key. " value:" . $value); + if ($value) { + if (!$bundleConfig) { + $bundleConfig = []; + } + $key = trim(trim($key, '"'), "'"); + $v2PluginName = explode(".", $key); + try + { + $v7PluginName = self::getV7PluginInfo($v2PluginName[0]); + $bundleConfig = array_merge($bundleConfig, [$v7PluginName[0] => "{latest}"]); + $v7PluginConfig = $v7PluginName[1]; + if (!isset($playerConfig->plugins)) { + $playerConfig->plugins = new stdClass(); + } + if (!isset($playerConfig->plugins->$v7PluginConfig)) { + $playerConfig->plugins->$v7PluginConfig = new stdClass(); + } + } + catch (Exception $e){ + $unHandledPlugins[] = $e->getMessage(); + } + } + } + } + if(sizeof($unHandledPlugins)) + { + throw new Exception ("Unhandled plugins: " . implode(", ", $unHandledPlugins)); + } + } - static function addV2toV7config($config, $flashvars, $uiconfId) - { - //Merge v7 config - if (!isset($config["provider"])) { - $config["provider"] = new stdClass(); - } - $unHandledVars = array(); - $config["uiconf_id"] = $uiconfId; - if($flashvars) - { - foreach ($flashvars as $key => $value) { - if(self::isVarPlugin($key)) - { - continue; - } - $key = trim(trim($key, '"'), "'"); - $providerParams = ["partnerId", "uiconf_id", "entry_id", "cache_st", "wid", "ks", "autoPlay", "playlistAPI.autoContinue"]; - if (in_array($key, $providerParams)) { - if ($value) { - KalturaLog::log("V2toV7 adding {$key}: " . $value); - $config["provider"]->$key = $value; - } - } - else{ - $unHandledVars[] = $key; - } - } - if(sizeof($unHandledVars)) - { - throw new Exception("UnHandled params:" . implode(",",$unHandledVars)); - } - } + static function addV2toV7config($config, $flashvars, $uiconfId) + { + //Merge v7 config + if (!isset($config["provider"])) { + $config["provider"] = new stdClass(); + } + $unHandledVars = array(); + $config["uiconf_id"] = $uiconfId; + if($flashvars) + { + foreach ($flashvars as $key => $value) { + if(self::isVarPlugin($key)) + { + continue; + } + $key = trim(trim($key, '"'), "'"); + $providerParams = ["partnerId", "uiconf_id", "entry_id", "cache_st", "wid", "ks", "autoPlay", "playlistAPI.autoContinue"]; + if (in_array($key, $providerParams)) { + if ($value) { + KalturaLog::log("V2toV7 adding {$key}: " . $value); + $config["provider"]->$key = $value; + } + } + else{ + $unHandledVars[] = $key; + } + } + if(sizeof($unHandledVars)) + { + throw new Exception("UnHandled params:" . implode(",",$unHandledVars)); + } + } - return $config; - } + return $config; + } - private static function isVarPlugin($varKeyName) - { - return str_contains($varKeyName, ".plugin"); - } + private static function isVarPlugin($varKeyName) + { + return str_contains($varKeyName, ".plugin"); + } - private static function v2toV7PluginMap() - { - return - ["info" => ["playkitscreen", "playkit-js-info"], - "quiz" => ["playkit-ivq", "ivq"], - "moderation" => ["playkit-moderation", "playkit-js-moderation"], - "playlistAPI" => ["playkit-playlist", "playlist"], - "liveStatus" => ["playkit-kaltura-live","kaltura-live"], - "related" => ["playkit-related", "related"], - "dualScreen" => ["playkit-dual-screen", "dualscreen"], - "video360" => ["playkit-vr" ,"vr"], - "raptMedia" => ["rapt", "rapt"], - "transcript" => ["playkit-transcript", "playkit-js-transcript"], - "qna" => ["playkit-qna", "qna"], - "bumper" => [ "playkit-bumper" , "bumper" ], - "infoScreen" => ["playkit-info", "playkit-js-info"]]; - } + private static function v2toV7PluginMap() + { + return + ["info" => ["playkitscreen", "playkit-js-info"], + "quiz" => ["playkit-ivq", "ivq"], + "moderation" => ["playkit-moderation", "playkit-js-moderation"], + "playlistAPI" => ["playkit-playlist", "playlist"], + "liveStatus" => ["playkit-kaltura-live","kaltura-live"], + "related" => ["playkit-related", "related"], + "dualScreen" => ["playkit-dual-screen", "dualscreen"], + "video360" => ["playkit-vr" ,"vr"], + "raptMedia" => ["rapt", "rapt"], + "transcript" => ["playkit-transcript", "playkit-js-transcript"], + "qna" => ["playkit-qna", "qna"], + "bumper" => [ "playkit-bumper" , "bumper" ], + "infoScreen" => ["playkit-info", "playkit-js-info"]]; + } } \ No newline at end of file diff --git a/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php index a62ba6fe41a..31b6e4346e8 100644 --- a/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php @@ -157,36 +157,35 @@ public function execute() /* * v2 - https://cdnapisec.kaltura.com/p/1915851/sp/191585100/embedIframeJs/uiconf_id/32880931/partner_id/1915851?iframeembed=true&playerId=kaltura_player_1719900446&entry_id=1_aeg07vpv * v7 - https://cdnapisec.kaltura.com/p/1915851/embedPlaykitJs/uiconf_id/54813242?iframeembed=true&entry_id=1_aeg07vpv - * Test - http://www.kaltura.local/p/102/sp/10200/embedIframeJs/uiconf_id/23448128/partner_id/102?iframeembed=true&playerId=kaltura_player_1719900446&entry_id=0_3eil6eqs */ private function redirectToV7($v7Id, $v2UiConfId, $partnerId, $shouldTranslatePlugins) : void { - //validate all the params are handled - try - { - $config = array(); - $config["bundleConfig"] = null; - $config["playerConfig"] = new stdClass(); - $config = v2Tov7Utils::addV2toV7config($config,$this->getRequestParameter(v2Tov7Utils::FLASHVARS_PARAM_NAME),$v7Id); - if($shouldTranslatePlugins) - { - v2Tov7Utils::addV2toV7plugins( - $this->getRequestParameter(v2Tov7Utils::FLASHVARS_PARAM_NAME), - $config["bundleConfig"], - $config["playerConfig"]); - } - } - catch(Exception $e) - { - //if we failed, then should not redirect! - KalturaLog::log("V2toV7 was rejected because: " . $e->getMessage() . " v2 id:" . $v2UiConfId. " v7 dd:" . $v2UiConfId); - return; - } + //validate all the params are handled + try + { + $config = array(); + $config["bundleConfig"] = null; + $config["playerConfig"] = new stdClass(); + $config = v2Tov7Utils::addV2toV7config($config,$this->getRequestParameter(v2Tov7Utils::FLASHVARS_PARAM_NAME),$v7Id); + if($shouldTranslatePlugins) + { + v2Tov7Utils::addV2toV7plugins( + $this->getRequestParameter(v2Tov7Utils::FLASHVARS_PARAM_NAME), + $config["bundleConfig"], + $config["playerConfig"]); + } + } + catch(Exception $e) + { + //if we failed, then should not redirect! + KalturaLog::log("V2toV7 was rejected because: " . $e->getMessage() . " v2 id:" . $v2UiConfId. " v7 dd:" . $v2UiConfId); + return; + } $host = myPartnerUtils::getCdnHost($partnerId, null , 'api'); $url = $host . "/p/" . $partnerId . '/embedPlaykitJs/uiconf_id/' . $v7Id . "?" . $_SERVER['QUERY_STRING'] . "&" - . v2Tov7Utils::FLASHVARS_PARAM_NAME . "=true&v2tov7translatePlugins=" - . v2Tov7Utils::SHOULD_TRANSLATE_PLUGINS . "=true" ;; + . v2Tov7Utils::FLASHVARS_PARAM_NAME + . v2Tov7Utils::SHOULD_TRANSLATE_PLUGINS . "=true" ;; header("Location:$url"); KExternalErrors::dieGracefully(); } diff --git a/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php index 8048624d5cb..94c75ebc949 100644 --- a/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php @@ -28,8 +28,6 @@ class embedPlaykitJsAction extends sfAction const KALTURA_TV_PLAYER = 'kaltura-tv-player'; const NO_ANALYTICS_PLAYER_VERSION = '0.56.0'; const NO_UICONF_FOR_KALTURA_DATA = '1.9.0'; - const V2TOV7_PARAM_NAME = "v2tov7"; - const FLASHVARS_PARAM_NAME = 'flashvars'; private $bundleCache = null; private $sourceMapsCache = null; @@ -74,13 +72,12 @@ public function execute() //Format bundle content $bundleContent = $this->formatBundleContent($bundleContent, $i18nContent, $extraModulesNames); - if($this->getRequestParameter(v2Tov7Utils::V2TOV7_PARAM_NAME)) - { - KalturaLog::log("Adding v2 to v7"); - // $v2ToV7Code = PHP_EOL . '!function(){"use strict";var e={453:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.thumbnailEmbedV2=t.embed=void 0;const i=n(593),o=window.KalturaPlayer;t.embed=e=>{console.log("## config -----\x3e",e);const t=e.hasOwnProperty("entry_id"),n=e.hasOwnProperty("playlistAPI.kpl0Id");try{const i=o.setup({log:{level:"DEBUG"},targetId:e.targetId,provider:{partnerId:e.wid.match(/\d+/g).join(""),uiConfId:e.uiconf_id}});t?i.loadMedia({entryId:e.entry_id}):n&&i.loadPlaylist({playlistId:e["playlistAPI.kpl0Id"]})}catch(e){}},t.thumbnailEmbedV2=e=>{try{const t={config:{targetId:e.targetId,provider:{partnerId:e.wid.match(/\d+/g).join(""),uiConfId:e.uiconf_id}},mediaInfo:{entryId:e.entry_id}};(0,i.thumbnailEmbed)(t)}catch(e){}}},593:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.ThumbnailEmbedComponent=t.thumbnailEmbed=void 0;const i=n(14);Object.defineProperty(t,"ThumbnailEmbedComponent",{enumerable:!0,get:function(){return i.ThumbnailEmbedComponent}});const o=n(512);Object.defineProperty(t,"thumbnailEmbed",{enumerable:!0,get:function(){return o.thumbnailEmbed}}),window.__thumbnailEmbed=o.thumbnailEmbed},14:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ThumbnailEmbedComponent=void 0;const n="#000";t.ThumbnailEmbedComponent=({onClick:e,src:t,bgColor:i=n})=>{const o=window.KalturaPlayer,{Button:r,Icon:d,IconType:a}=o.ui.components,{h:l}=o.ui.preact,{useRef:u,useState:c,useCallback:m}=o.ui.preactHooks,s=m((()=>{e(),v(!1)})),b=m((()=>{g(!0)})),p=m((()=>{g(!0),E(!0)})),h=u(),[y,v]=c(!0),[f,g]=c(!1),[I,E]=c(!1);return y?l("div",{style:{width:"100%",height:"100%",position:"relative",backgroundColor:I?i:n}},I?void 0:l("img",{src:t,ref:h,onLoad:b,onError:p,style:{width:"100%",height:"100%","object-fit":"contain"}}),f?l("div",{className:o.ui.style.prePlaybackPlayOverlay,style:{width:"100%",height:"100%"}},l(r,{className:o.ui.style.prePlaybackPlayButton,tabIndex:0,onClick:s},l(d,{type:a.Play}))):void 0):void 0}},512:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.thumbnailEmbed=void 0;const i=n(14);t.thumbnailEmbed=({config:e,mediaInfo:t,mediaOptions:n={},version:o=1e4,bgColor:r})=>{if(!e||!t)return;const d=(e=>{var t,n,i,o;if(null===(t=e.provider.env)||void 0===t?void 0:t.cdnUrl)return null===(n=e.provider.env)||void 0===n?void 0:n.cdnUrl;const r=window.__kalturaplayerdata;return r?null===(o=null===(i=r.provider)||void 0===i?void 0:i.env)||void 0===o?void 0:o.cdnUrl:"https://cdnapisec.kaltura.com"})(e),{targetId:a,provider:{partnerId:l,ks:u}}=e,c=window.KalturaPlayer;var m=document.getElementById(a);if(!m||!c||c.getPlayer&&c.getPlayer(a))return;let s=1920,b=1080;m.clientWidth&&m.clientHeight&&(s=m.clientWidth,b=m.clientHeight);const p=`${d.endsWith("/")?d:d+"/"}p/${l}/sp/${l}00/thumbnail/entry_id/${t.entryId}/version/${o}/width/${s}/height/${b}`+(u?`/ks/${u}`:""),{h:h,render:y}=c.ui.preact;y(h(i.ThumbnailEmbedComponent,{src:p,bgColor:r,onClick:()=>{try{const i=c.setup(e);i.loadMedia(t,n),i.play()}catch(e){}}}),m)}}},t={};function n(i){var o=t[i];if(void 0!==o)return o.exports;var r=t[i]={exports:{}};return e[i](r,r.exports,n),r.exports}!function(){const e=n(453);window.kWidget={embed:e.embed,thumbEmbed:e.thumbnailEmbedV2}}()}();//# sourceMappingURL=kWidget-embed.js.map";' . PHP_EOL; - $v2ToV7Code = PHP_EOL . PHP_EOL . '!function(){"use strict";var e={593:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.ThumbnailEmbedComponent=t.thumbnailEmbed=void 0;const o=n(14);Object.defineProperty(t,"ThumbnailEmbedComponent",{enumerable:!0,get:function(){return o.ThumbnailEmbedComponent}});const i=n(512);Object.defineProperty(t,"thumbnailEmbed",{enumerable:!0,get:function(){return i.thumbnailEmbed}}),window.__thumbnailEmbed=i.thumbnailEmbed},14:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ThumbnailEmbedComponent=void 0;const n="#000";t.ThumbnailEmbedComponent=({onClick:e,src:t,bgColor:o=n})=>{const i=window.KalturaPlayer,{Button:r,Icon:d,IconType:a}=i.ui.components,{h:l}=i.ui.preact,{useRef:s,useState:u,useCallback:c}=i.ui.preactHooks,m=c((()=>{e(),h(!1)})),b=c((()=>{g(!0)})),p=c((()=>{g(!0),P(!0)})),y=s(),[f,h]=u(!0),[v,g]=u(!1),[I,P]=u(!1);return f?l("div",{style:{width:"100%",height:"100%",position:"relative",backgroundColor:I?o:n}},I?void 0:l("img",{src:t,ref:y,onLoad:b,onError:p,style:{width:"100%",height:"100%","object-fit":"contain"}}),v?l("div",{className:i.ui.style.prePlaybackPlayOverlay,style:{width:"100%",height:"100%"}},l(r,{className:i.ui.style.prePlaybackPlayButton,tabIndex:0,onClick:m},l(d,{type:a.Play}))):void 0):void 0}},512:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.thumbnailEmbed=void 0;const o=n(14);t.thumbnailEmbed=({config:e,mediaInfo:t,mediaOptions:n={},version:i=1e4,bgColor:r})=>{if(!e||!t)return;const d=(e=>{var t,n,o,i;if(null===(t=e.provider.env)||void 0===t?void 0:t.cdnUrl)return null===(n=e.provider.env)||void 0===n?void 0:n.cdnUrl;const r=window.__kalturaplayerdata;return r?null===(i=null===(o=r.provider)||void 0===o?void 0:o.env)||void 0===i?void 0:i.cdnUrl:"https://cdnapisec.kaltura.com"})(e),{targetId:a,provider:{partnerId:l,ks:s}}=e,u=window.KalturaPlayer;var c=document.getElementById(a);if(!c||!u||u.getPlayer&&u.getPlayer(a))return;let m=1920,b=1080;c.clientWidth&&c.clientHeight&&(m=c.clientWidth,b=c.clientHeight);const p=`${d.endsWith("/")?d:d+"/"}p/${l}/sp/${l}00/thumbnail/entry_id/${t.entryId}/version/${i}/width/${m}/height/${b}`+(s?`/ks/${s}`:""),{h:y,render:f}=u.ui.preact;f(y(o.ThumbnailEmbedComponent,{src:p,bgColor:r,onClick:()=>{try{const o=u.setup(e);o.loadMedia(t,n),o.play()}catch(e){}}}),c)}},371:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.thumbEmbed=t.embed=void 0;const o=n(593),i=n(890),r=window.KalturaPlayer;t.embed=e=>{console.log("## v2Config -----\x3e",e);const{targetId:t,partnerId:n,uiConfId:o,mediaInfo:d}=(0,i.getInfoFromV2Config)(e);let a={log:{level:"DEBUG"},targetId:t,provider:{partnerId:n}};const l=(0,i.buildConfigFromFlashvars)(e),s=Object.assign({},a,l);try{const e=r.setup(s),n=document.getElementById(t);n&&(n.addJsListener=(t,n)=>{"mediaLoaded"===t&&e.addEventListener("medialoaded",(()=>{n()}))});const o=d.id;d.isPlaylist?e.loadPlaylist({playlistId:o}):e.loadMedia({entryId:o})}catch(e){}},t.thumbEmbed=e=>{const{targetId:t,partnerId:n,uiConfId:r,mediaInfo:d}=(0,i.getInfoFromV2Config)(e);try{const e={config:{targetId:t,provider:{partnerId:n}},mediaInfo:{entryId:d.id}};(0,o.thumbnailEmbed)(e)}catch(e){}}},890:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.buildConfigFromFlashvars=t.getMediaInfo=t.getInfoFromV2Config=void 0,t.getInfoFromV2Config=e=>({targetId:e.targetId,partnerId:e.wid.match(/\d+/g).join(""),uiConfId:e.uiconf_id,mediaInfo:(0,t.getMediaInfo)(e)}),t.getMediaInfo=e=>{if(e.entry_id)return{id:e.entry_id,isPlaylist:!1};let t="";const n=e.flashvars;return n.hasOwnProperty("playlistAPI.kpl0Id")?t=n["playlistAPI.kpl0Id"]:n.hasOwnProperty("playlistAPI")&&n.playlistAPI.hasOwnProperty("kpl0Id")&&(t=n.playlistAPI.kpl0Id),{id:t,isPlaylist:!0}},t.buildConfigFromFlashvars=e=>{let t={text:{},playback:{},streaming:{},abr:{},drm:{},network:{},plugins:{}};if(e.hasOwnProperty("flashvars")){const n=e.flashvars;n.hasOwnProperty("autoPlay")&&(t.playback.autoplay=n.autoPlay)}return t}}},t={};function n(o){var i=t[o];if(void 0!==i)return i.exports;var r=t[o]={exports:{}};return e[o](r,r.exports,n),r.exports}!function(){const e=n(371);window.kWidget={embed:e.embed,thumbEmbed:e.thumbEmbed}}()}();'; - $bundleContent = $bundleContent . $v2ToV7Code; - } + if($this->getRequestParameter(v2Tov7Utils::V2TOV7_PARAM_NAME)) + { + KalturaLog::log("Adding v2 to v7 facade"); + $v2ToV7Code = PHP_EOL . PHP_EOL . '!function(){"use strict";var e={593:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.ThumbnailEmbedComponent=t.thumbnailEmbed=void 0;const o=n(14);Object.defineProperty(t,"ThumbnailEmbedComponent",{enumerable:!0,get:function(){return o.ThumbnailEmbedComponent}});const i=n(512);Object.defineProperty(t,"thumbnailEmbed",{enumerable:!0,get:function(){return i.thumbnailEmbed}}),window.__thumbnailEmbed=i.thumbnailEmbed},14:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ThumbnailEmbedComponent=void 0;const n="#000";t.ThumbnailEmbedComponent=({onClick:e,src:t,bgColor:o=n})=>{const i=window.KalturaPlayer,{Button:r,Icon:d,IconType:a}=i.ui.components,{h:l}=i.ui.preact,{useRef:s,useState:u,useCallback:c}=i.ui.preactHooks,m=c((()=>{e(),h(!1)})),b=c((()=>{g(!0)})),p=c((()=>{g(!0),P(!0)})),y=s(),[f,h]=u(!0),[v,g]=u(!1),[I,P]=u(!1);return f?l("div",{style:{width:"100%",height:"100%",position:"relative",backgroundColor:I?o:n}},I?void 0:l("img",{src:t,ref:y,onLoad:b,onError:p,style:{width:"100%",height:"100%","object-fit":"contain"}}),v?l("div",{className:i.ui.style.prePlaybackPlayOverlay,style:{width:"100%",height:"100%"}},l(r,{className:i.ui.style.prePlaybackPlayButton,tabIndex:0,onClick:m},l(d,{type:a.Play}))):void 0):void 0}},512:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.thumbnailEmbed=void 0;const o=n(14);t.thumbnailEmbed=({config:e,mediaInfo:t,mediaOptions:n={},version:i=1e4,bgColor:r})=>{if(!e||!t)return;const d=(e=>{var t,n,o,i;if(null===(t=e.provider.env)||void 0===t?void 0:t.cdnUrl)return null===(n=e.provider.env)||void 0===n?void 0:n.cdnUrl;const r=window.__kalturaplayerdata;return r?null===(i=null===(o=r.provider)||void 0===o?void 0:o.env)||void 0===i?void 0:i.cdnUrl:"https://cdnapisec.kaltura.com"})(e),{targetId:a,provider:{partnerId:l,ks:s}}=e,u=window.KalturaPlayer;var c=document.getElementById(a);if(!c||!u||u.getPlayer&&u.getPlayer(a))return;let m=1920,b=1080;c.clientWidth&&c.clientHeight&&(m=c.clientWidth,b=c.clientHeight);const p=`${d.endsWith("/")?d:d+"/"}p/${l}/sp/${l}00/thumbnail/entry_id/${t.entryId}/version/${i}/width/${m}/height/${b}`+(s?`/ks/${s}`:""),{h:y,render:f}=u.ui.preact;f(y(o.ThumbnailEmbedComponent,{src:p,bgColor:r,onClick:()=>{try{const o=u.setup(e);o.loadMedia(t,n),o.play()}catch(e){}}}),c)}},371:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.thumbEmbed=t.embed=void 0;const o=n(593),i=n(890),r=window.KalturaPlayer;t.embed=e=>{console.log("## v2Config -----\x3e",e);const{targetId:t,partnerId:n,uiConfId:o,mediaInfo:d}=(0,i.getInfoFromV2Config)(e);let a={log:{level:"DEBUG"},targetId:t,provider:{partnerId:n}};const l=(0,i.buildConfigFromFlashvars)(e),s=Object.assign({},a,l);try{const e=r.setup(s),n=document.getElementById(t);n&&(n.addJsListener=(t,n)=>{"mediaLoaded"===t&&e.addEventListener("medialoaded",(()=>{n()}))});const o=d.id;d.isPlaylist?e.loadPlaylist({playlistId:o}):e.loadMedia({entryId:o})}catch(e){}},t.thumbEmbed=e=>{const{targetId:t,partnerId:n,uiConfId:r,mediaInfo:d}=(0,i.getInfoFromV2Config)(e);try{const e={config:{targetId:t,provider:{partnerId:n}},mediaInfo:{entryId:d.id}};(0,o.thumbnailEmbed)(e)}catch(e){}}},890:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.buildConfigFromFlashvars=t.getMediaInfo=t.getInfoFromV2Config=void 0,t.getInfoFromV2Config=e=>({targetId:e.targetId,partnerId:e.wid.match(/\d+/g).join(""),uiConfId:e.uiconf_id,mediaInfo:(0,t.getMediaInfo)(e)}),t.getMediaInfo=e=>{if(e.entry_id)return{id:e.entry_id,isPlaylist:!1};let t="";const n=e.flashvars;return n.hasOwnProperty("playlistAPI.kpl0Id")?t=n["playlistAPI.kpl0Id"]:n.hasOwnProperty("playlistAPI")&&n.playlistAPI.hasOwnProperty("kpl0Id")&&(t=n.playlistAPI.kpl0Id),{id:t,isPlaylist:!0}},t.buildConfigFromFlashvars=e=>{let t={text:{},playback:{},streaming:{},abr:{},drm:{},network:{},plugins:{}};if(e.hasOwnProperty("flashvars")){const n=e.flashvars;n.hasOwnProperty("autoPlay")&&(t.playback.autoplay=n.autoPlay)}return t}}},t={};function n(o){var i=t[o];if(void 0!==i)return i.exports;var r=t[o]={exports:{}};return e[o](r,r.exports,n),r.exports}!function(){const e=n(371);window.kWidget={embed:e.embed,thumbEmbed:e.thumbEmbed}}()}();'; + $bundleContent = $bundleContent . $v2ToV7Code; + } // send cache headers $this->sendHeaders($bundleContent, $lastModified); @@ -518,11 +515,11 @@ private function getAutoEmbedCode($targetId = null) $config["targetId"] = $targetId; - //Add v2 to v7 config - if($this->uiConf->getV2tov7id() && ($this->getRequestParameter(v2Tov7Utils::V2TOV7_PARAM_NAME) || $this->uiConf->getV2tov7Approved()) ) - { - $config = v2Tov7Utils::addV2toV7config($config,$this->getRequestParameter(v2Tov7Utils::FLASHVARS_PARAM_NAME),$this->uiconfId); - } + //Add v2 to v7 config + if($this->uiConf->getV2tov7id() && ($this->getRequestParameter(v2Tov7Utils::V2TOV7_PARAM_NAME) || $this->uiConf->getV2tov7Approved()) ) + { + $config = v2Tov7Utils::addV2toV7config($config,$this->getRequestParameter(v2Tov7Utils::FLASHVARS_PARAM_NAME),$this->uiconfId); + } $config = json_encode($config); if ($config === false) @@ -833,13 +830,13 @@ private function initMembers() $this->mergeVersionsParamIntoConfig(); - if($this->getRequestParameter(v2Tov7Utils::V2TOV7_PARAM_NAME) && $this->getRequestParameter(v2Tov7Utils::SHOULD_TRANSLATE_PLUGINS)) - { - v2Tov7Utils::addV2toV7plugins( - $this->getRequestParameter(v2Tov7Utils::FLASHVARS_PARAM_NAME), - $this->bundleConfig, - $this->playerConfig); - } + if($this->getRequestParameter(v2Tov7Utils::V2TOV7_PARAM_NAME) && $this->getRequestParameter(v2Tov7Utils::SHOULD_TRANSLATE_PLUGINS)) + { + v2Tov7Utils::addV2toV7plugins( + $this->getRequestParameter(v2Tov7Utils::FLASHVARS_PARAM_NAME), + $this->bundleConfig, + $this->playerConfig); + } if (!$this->bundleConfig) { KExternalErrors::dieError(KExternalErrors::MISSING_PARAMETER, "unable to resolve bundle config"); diff --git a/alpha/lib/model/uiConf.php b/alpha/lib/model/uiConf.php index 0e8aa21091d..f1676eb66fd 100644 --- a/alpha/lib/model/uiConf.php +++ b/alpha/lib/model/uiConf.php @@ -114,10 +114,10 @@ class uiConf extends BaseuiConf implements ISyncableFile, IRelatedObject const CUSTOM_DATA_CON_FILE_VERSION = 'conf_file_version'; const CUSTOM_DATA_CONF_FILE_FEATURES_VERSION = 'conf_file_features_version'; - //v2 to b7 - const CUSTOM_DATA_V2V7_ID = "v2v7_id"; - const CUSTOM_DATA_V2V7_APPROVED = "v2v7_approved"; - const CUSTOM_DATA_V2V7_TRANSLATE_PLUGINS = "v2v7_trnanslate_plugins"; + //v2 to b7 + const CUSTOM_DATA_V2V7_ID = "v2v7_id"; + const CUSTOM_DATA_V2V7_APPROVED = "v2v7_approved"; + const CUSTOM_DATA_V2V7_TRANSLATE_PLUGINS = "v2v7_translate_plugins"; public function save(PropelPDO $con = null) { @@ -818,11 +818,11 @@ public function setVersion($v, $subType = self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG return parent::setVersion($v); } - //v2 to v7 - public function getV2tov7id(){ return $this->getFromCustomData( self::CUSTOM_DATA_V2V7_ID, null , null ); } - public function setV2tov7id($v){ return $this->putInCustomData( self::CUSTOM_DATA_V2V7_ID, $v ); } - public function getV2tov7Approved(){ return $this->getFromCustomData( self::CUSTOM_DATA_V2V7_APPROVED, null, false , null ); } - public function setV2tov7Approved($v){ return $this->putInCustomData( self::CUSTOM_DATA_V2V7_APPROVED, $v ); } - public function getShouldTranslatePluginsToV7(){ return $this->getFromCustomData( self::CUSTOM_DATA_V2V7_TRANSLATE_PLUGINS, null,false , null ); } - public function setShouldTranslatePluginsToV7($v){ return $this->putInCustomData( self::CUSTOM_DATA_V2V7_TRANSLATE_PLUGINS, $v ); } + //v2 to v7 + public function getV2tov7id(){ return $this->getFromCustomData( self::CUSTOM_DATA_V2V7_ID, null , null ); } + public function setV2tov7id($v){ return $this->putInCustomData( self::CUSTOM_DATA_V2V7_ID, $v ); } + public function getV2tov7Approved(){ return $this->getFromCustomData( self::CUSTOM_DATA_V2V7_APPROVED, null, false , null ); } + public function setV2tov7Approved($v){ return $this->putInCustomData( self::CUSTOM_DATA_V2V7_APPROVED, $v ); } + public function getShouldTranslatePluginsToV7(){ return $this->getFromCustomData( self::CUSTOM_DATA_V2V7_TRANSLATE_PLUGINS, null,false , null ); } + public function setShouldTranslatePluginsToV7($v){ return $this->putInCustomData( self::CUSTOM_DATA_V2V7_TRANSLATE_PLUGINS, $v ); } } From 93f13ad20971ab78155b96911f0a080cd2c881fb Mon Sep 17 00:00:00 2001 From: MosheMaorKaltura Date: Thu, 8 Aug 2024 14:03:50 +0300 Subject: [PATCH 05/96] PLAT-24912: support redirect v2 to v7 --- .../actions/embedIframeJsAction.class.php | 18 +- alpha/lib/model/uiConf.php | 1595 ++++++++--------- 2 files changed, 807 insertions(+), 806 deletions(-) diff --git a/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php index 31b6e4346e8..38cfda6c13f 100644 --- a/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php @@ -164,28 +164,30 @@ private function redirectToV7($v7Id, $v2UiConfId, $partnerId, $shouldTranslatePl try { $config = array(); - $config["bundleConfig"] = null; - $config["playerConfig"] = new stdClass(); + $config['bundleConfig'] = null; + $config['playerConfig'] = new stdClass(); $config = v2Tov7Utils::addV2toV7config($config,$this->getRequestParameter(v2Tov7Utils::FLASHVARS_PARAM_NAME),$v7Id); if($shouldTranslatePlugins) { v2Tov7Utils::addV2toV7plugins( $this->getRequestParameter(v2Tov7Utils::FLASHVARS_PARAM_NAME), - $config["bundleConfig"], - $config["playerConfig"]); + $config['bundleConfig'], + $config['playerConfig']); } } catch(Exception $e) { //if we failed, then should not redirect! - KalturaLog::log("V2toV7 was rejected because: " . $e->getMessage() . " v2 id:" . $v2UiConfId. " v7 dd:" . $v2UiConfId); + KalturaLog::log('V2toV7 was rejected because: ' . $e->getMessage() . ' v2 id:' . $v2UiConfId. ' v7 id:' . $v2UiConfId); return; } + $shouldTranslatePluginsQueryParam = $shouldTranslatePlugins ? '&' . v2Tov7Utils::SHOULD_TRANSLATE_PLUGINS . '=true' : '' ; $host = myPartnerUtils::getCdnHost($partnerId, null , 'api'); - $url = $host . "/p/" . $partnerId . '/embedPlaykitJs/uiconf_id/' . $v7Id . "?" . $_SERVER['QUERY_STRING'] . "&" - . v2Tov7Utils::FLASHVARS_PARAM_NAME - . v2Tov7Utils::SHOULD_TRANSLATE_PLUGINS . "=true" ;; + $url = $host . '/p/' . $partnerId . '/embedPlaykitJs/uiconf_id/' . $v7Id . '?' + . $_SERVER['QUERY_STRING'] . "&" + . v2Tov7Utils::V2TOV7_PARAM_NAME .'=true' + . $shouldTranslatePluginsQueryParam; header("Location:$url"); KExternalErrors::dieGracefully(); } diff --git a/alpha/lib/model/uiConf.php b/alpha/lib/model/uiConf.php index f1676eb66fd..830e323a7a1 100644 --- a/alpha/lib/model/uiConf.php +++ b/alpha/lib/model/uiConf.php @@ -10,819 +10,818 @@ */ class uiConf extends BaseuiConf implements ISyncableFile, IRelatedObject { - const MYSQL_CODE_DUPLICATE_KEY = 23000; - - const UI_CONF_TYPE_GENERIC = 0; - const UI_CONF_TYPE_WIDGET = 1; - const UI_CONF_TYPE_CW = 2; - const UI_CONF_TYPE_EDITOR = 3; - const UI_CONF_TYPE_ADVANCED_EDITOR = 4; - const UI_CONF_TYPE_PLAYLIST = 5; // maybe this is in fact type WIDGET with some flags switched on ?!? - const UI_CONF_TYPE_KMC_APP_STUDIO = 6; - const UI_CONF_TYPE_KRECORD = 7; - const UI_CONF_TYPE_KDP3 = 8; - const UI_CONF_TYPE_KMC_ACCOUNT = 9; - const UI_CONF_TYPE_KMC_ANALYTICS = 10; - const UI_CONF_TYPE_KMC_CONTENT = 11; - const UI_CONF_TYPE_KMC_DASHBOARD = 12; - const UI_CONF_TYPE_KMC_LOGIN = 13; - const UI_CONF_TYPE_SLP = 14; - const UI_CONF_CLIENTSIDE_ENCODER = 15; - const UI_CONF_KMC_GENERAL = 16; - const UI_CONF_KMC_ROLES_AND_PERMISSIONS = 17; - const UI_CONF_CLIPPER = 18; - const UI_CONF_TYPE_KSR = 19; - const UI_CONF_TYPE_KUPLOAD = 20; - const UI_CONF_TYPE_WEBCASTING = 21; - const UI_CONF_TYPE_SAP = 22; - - - const UI_CONF_CREATION_MODE_MANUAL = 1; - const UI_CONF_CREATION_MODE_WIZARD = 2; - const UI_CONF_CREATION_MODE_ADVANCED = 3; - - // status - const UI_CONF_STATUS_PENDING = 1; - const UI_CONF_STATUS_READY = 2; - const UI_CONF_STATUS_DELETED = 3; - - const FILE_NAME_FEATURES = "features"; - const FILE_NAME_CONFIG = "config"; - - const FILE_SYNC_UICONF_SUB_TYPE_DATA = 1; - const FILE_SYNC_UICONF_SUB_TYPE_FEATURES = 2; - const FILE_SYNC_UICONF_SUB_TYPE_CONFIG = 3; - - private static $UI_CONF_OBJ_TYPE_MAP = null; - private static $REQUIRE_UI_CONF_FILE_FOR_TYPE = null; - - private static $validSubTypes = array(self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG, self::FILE_SYNC_UICONF_SUB_TYPE_DATA, self::FILE_SYNC_UICONF_SUB_TYPE_FEATURES); - private $content = array(); - - private $swf_url_version = null; - - //UI_CONF_TYPE_KSR:: This is a general path value the actual jar file should be symlinked under each KSR version dir - private static $swf_names = array ( self::UI_CONF_TYPE_WIDGET => "kdp.swf" , - self::UI_CONF_TYPE_CW => "ContributionWizard.swf" , - self::UI_CONF_TYPE_EDITOR => "simpleeditor.swf" , - self::UI_CONF_TYPE_ADVANCED_EDITOR => "KalturaAdvancedVideoEditor.swf" , - self::UI_CONF_TYPE_PLAYLIST => "kdp.swf" , - self::UI_CONF_TYPE_KMC_APP_STUDIO => "applicationstudio.swf", - self::UI_CONF_TYPE_KDP3 => "kdp3.swf", - self::UI_CONF_TYPE_KMC_ACCOUNT => "account.swf", - self::UI_CONF_TYPE_KMC_ANALYTICS => "ReportsAndAnalytics.swf", - self::UI_CONF_TYPE_KMC_CONTENT => "content.swf", - self::UI_CONF_TYPE_KMC_DASHBOARD => "dashboard.swf", - self::UI_CONF_TYPE_KMC_LOGIN => "login.swf", - self::UI_CONF_TYPE_SLP => "KalturaPlayer.xap", - self::UI_CONF_CLIENTSIDE_ENCODER => "KEU_0.8_win.msi", - self::UI_CONF_KMC_GENERAL => "kmc.swf", - self::UI_CONF_KMC_ROLES_AND_PERMISSIONS => "", - self::UI_CONF_CLIPPER => "", - self::UI_CONF_TYPE_KSR => "ScreencastOMaticRun.jar", - self::UI_CONF_TYPE_KRECORD => "KRecord.swf", - self::UI_CONF_TYPE_KUPLOAD => "KUpload.swf", - self::UI_CONF_TYPE_WEBCASTING => "", - self::UI_CONF_TYPE_SAP => "", - ); - - private static $swf_directory_map = array ( - self::UI_CONF_TYPE_WIDGET => "kdp", - self::UI_CONF_TYPE_CW => "kcw", - self::UI_CONF_TYPE_EDITOR => "kse", - self::UI_CONF_TYPE_ADVANCED_EDITOR => "kae", - self::UI_CONF_TYPE_PLAYLIST => "kdp", - self::UI_CONF_TYPE_KMC_APP_STUDIO => "kmc/appstudio", - self::UI_CONF_TYPE_KDP3 => "kdp3", - self::UI_CONF_TYPE_KMC_ACCOUNT => "kmc/account", - self::UI_CONF_TYPE_KMC_ANALYTICS => "kmc/analytics", - self::UI_CONF_TYPE_KMC_CONTENT => "kmc/content", - self::UI_CONF_TYPE_KMC_DASHBOARD => "kmc/dashboard", - self::UI_CONF_TYPE_KMC_LOGIN => "kmc/login", - self::UI_CONF_TYPE_SLP => "slp", - self::UI_CONF_CLIENTSIDE_ENCODER => "expressUploader", - self::UI_CONF_KMC_GENERAL => "kmc", - self::UI_CONF_KMC_ROLES_AND_PERMISSIONS => "", - self::UI_CONF_CLIPPER => "kclip", - self::UI_CONF_TYPE_KSR => "ksr", - self::UI_CONF_TYPE_KRECORD => 'krecord', - self::UI_CONF_TYPE_KUPLOAD => "kupload", - self::UI_CONF_TYPE_WEBCASTING => "", - self::UI_CONF_TYPE_SAP => "", - ); - - const CUSTOM_DATA_CON_FILE_VERSION = 'conf_file_version'; - const CUSTOM_DATA_CONF_FILE_FEATURES_VERSION = 'conf_file_features_version'; - - //v2 to b7 - const CUSTOM_DATA_V2V7_ID = "v2v7_id"; - const CUSTOM_DATA_V2V7_APPROVED = "v2v7_approved"; - const CUSTOM_DATA_V2V7_TRANSLATE_PLUGINS = "v2v7_translate_plugins"; - - public function save(PropelPDO $con = null) - { - try - { - $res = parent::save( $con ); - } - catch (PropelException $e) - { - /** - * Because many ui-conf objects have hard-coded id, the auto-incremented id of new ui-conf could exist in the db. - * Just retry to save the ui-conf with a different auto-inceremented id. - */ - - if($e->getCause() && $e->getCause()->getCode() == self::MYSQL_CODE_DUPLICATE_KEY) //unique constraint - { - $res = parent::save( $con ); - } - else - { - throw $e; // Rethrow the unfamiliar exception - } - } - - if($this->shouldSetContent()) - { - foreach ($this->content as $contentItem) - { - $confFile = $this->getConfFileBySuffix($contentItem['suffix']); - if ($confFile) - $this->saveConfFileToDisk($confFile, $contentItem['suffix']); - $contentItem['shouldSet'] = false; - - } - $res = parent::save( $con ); - } - $this->getConfFilePath(); - - return $res; - } - - private function isUiConfContentSet($subType) - { - if(!array_key_exists($subType, $this->content)) - return false; - $contentItem = $this->content[$subType]; - if(!$contentItem || !$contentItem['data']) - return false; - - return true; - } - - /* (non-PHPdoc) - * @see lib/model/om/BaseuiConf#postUpdate() - */ - public function postUpdate(PropelPDO $con = null) - { - if ($this->alreadyInSave) - return parent::postUpdate($con); - - $objectDeleted = false; - if($this->isColumnModified(uiConfPeer::STATUS) && $this->getStatus() == self::UI_CONF_STATUS_DELETED) - $objectDeleted = true; - - $ret = parent::postUpdate($con); - - if($objectDeleted) - kEventsManager::raiseEvent(new kObjectDeletedEvent($this)); - - return $ret; - } - - private static function initUiConfTypeMap() - { - if ( self::$UI_CONF_OBJ_TYPE_MAP == null ) - { - self::$UI_CONF_OBJ_TYPE_MAP = array ( - self::UI_CONF_TYPE_GENERIC => "Generic", - self::UI_CONF_TYPE_WIDGET => "Widget", - self::UI_CONF_TYPE_CW => "Contribution Wizard", - self::UI_CONF_TYPE_EDITOR => "Simple Editor", - self::UI_CONF_TYPE_ADVANCED_EDITOR => "Advanced Editor", - self::UI_CONF_TYPE_PLAYLIST => "Playlist", - self::UI_CONF_TYPE_KDP3 => "KDP3", - self::UI_CONF_TYPE_KMC_APP_STUDIO => "KMC AppStudio", - self::UI_CONF_TYPE_KMC_ACCOUNT => "KMC Account", - self::UI_CONF_TYPE_KMC_ANALYTICS => "KMC Analytics", - self::UI_CONF_TYPE_KMC_CONTENT => "KMC Content", - self::UI_CONF_TYPE_KMC_DASHBOARD => "KMC Dashboard", - self::UI_CONF_TYPE_KMC_LOGIN => "KMC Login", - self::UI_CONF_TYPE_SLP => "SLP", - self::UI_CONF_CLIENTSIDE_ENCODER => "Express Uploader", - self::UI_CONF_KMC_GENERAL => "KMC", - self::UI_CONF_KMC_ROLES_AND_PERMISSIONS => "KMC Roles and Permissions", - self::UI_CONF_CLIPPER => "Kaltura Clipper", - self::UI_CONF_TYPE_KSR => "Kaltura Screen Recorder", - self::UI_CONF_TYPE_KUPLOAD => "Kaltura Simple Uploader", - self::UI_CONF_TYPE_WEBCASTING => "Kaltura Webcasting Studio", - self::UI_CONF_TYPE_SAP => "Slim Audio Player", - ); - } - } - - public function isValid() - { - return true; - } - - public function getUiConfTypeMap() - { - self::initUiConfTypeMap(); - return self::$UI_CONF_OBJ_TYPE_MAP; - } - - public function getObjTypeAsString ( ) - { - self::initUiConfTypeMap(); - return self::$UI_CONF_OBJ_TYPE_MAP[$this->getType()]; - } - - public function getType() - { - $t = parent::getObjType(); - if ( empty ( $t ) ) $t = self::UI_CONF_TYPE_WIDGET; - return $t; - } - - /** - * (non-PHPdoc) - * @see lib/model/ISyncableFile#getSyncKey() - */ - public function getSyncKey ( $sub_type , $version = null ) - { - self::validateFileSyncSubType ( $sub_type ); - $key = new FileSyncKey(); - $key->object_type = FileSyncObjectType::UICONF; - $key->object_sub_type = $sub_type; - $key->object_id = $this->getId(); + const MYSQL_CODE_DUPLICATE_KEY = 23000; + + const UI_CONF_TYPE_GENERIC = 0; + const UI_CONF_TYPE_WIDGET = 1; + const UI_CONF_TYPE_CW = 2; + const UI_CONF_TYPE_EDITOR = 3; + const UI_CONF_TYPE_ADVANCED_EDITOR = 4; + const UI_CONF_TYPE_PLAYLIST = 5; // maybe this is in fact type WIDGET with some flags switched on ?!? + const UI_CONF_TYPE_KMC_APP_STUDIO = 6; + const UI_CONF_TYPE_KRECORD = 7; + const UI_CONF_TYPE_KDP3 = 8; + const UI_CONF_TYPE_KMC_ACCOUNT = 9; + const UI_CONF_TYPE_KMC_ANALYTICS = 10; + const UI_CONF_TYPE_KMC_CONTENT = 11; + const UI_CONF_TYPE_KMC_DASHBOARD = 12; + const UI_CONF_TYPE_KMC_LOGIN = 13; + const UI_CONF_TYPE_SLP = 14; + const UI_CONF_CLIENTSIDE_ENCODER = 15; + const UI_CONF_KMC_GENERAL = 16; + const UI_CONF_KMC_ROLES_AND_PERMISSIONS = 17; + const UI_CONF_CLIPPER = 18; + const UI_CONF_TYPE_KSR = 19; + const UI_CONF_TYPE_KUPLOAD = 20; + const UI_CONF_TYPE_WEBCASTING = 21; + const UI_CONF_TYPE_SAP = 22; + + + const UI_CONF_CREATION_MODE_MANUAL = 1; + const UI_CONF_CREATION_MODE_WIZARD = 2; + const UI_CONF_CREATION_MODE_ADVANCED = 3; + + // status + const UI_CONF_STATUS_PENDING = 1; + const UI_CONF_STATUS_READY = 2; + const UI_CONF_STATUS_DELETED = 3; + + const FILE_NAME_FEATURES = "features"; + const FILE_NAME_CONFIG = "config"; + + const FILE_SYNC_UICONF_SUB_TYPE_DATA = 1; + const FILE_SYNC_UICONF_SUB_TYPE_FEATURES = 2; + const FILE_SYNC_UICONF_SUB_TYPE_CONFIG = 3; + + private static $UI_CONF_OBJ_TYPE_MAP = null; + private static $REQUIRE_UI_CONF_FILE_FOR_TYPE = null; + + private static $validSubTypes = array(self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG, self::FILE_SYNC_UICONF_SUB_TYPE_DATA, self::FILE_SYNC_UICONF_SUB_TYPE_FEATURES); + private $content = array(); + + private $swf_url_version = null; + + //UI_CONF_TYPE_KSR:: This is a general path value the actual jar file should be symlinked under each KSR version dir + private static $swf_names = array(self::UI_CONF_TYPE_WIDGET => "kdp.swf", + self::UI_CONF_TYPE_CW => "ContributionWizard.swf", + self::UI_CONF_TYPE_EDITOR => "simpleeditor.swf", + self::UI_CONF_TYPE_ADVANCED_EDITOR => "KalturaAdvancedVideoEditor.swf", + self::UI_CONF_TYPE_PLAYLIST => "kdp.swf", + self::UI_CONF_TYPE_KMC_APP_STUDIO => "applicationstudio.swf", + self::UI_CONF_TYPE_KDP3 => "kdp3.swf", + self::UI_CONF_TYPE_KMC_ACCOUNT => "account.swf", + self::UI_CONF_TYPE_KMC_ANALYTICS => "ReportsAndAnalytics.swf", + self::UI_CONF_TYPE_KMC_CONTENT => "content.swf", + self::UI_CONF_TYPE_KMC_DASHBOARD => "dashboard.swf", + self::UI_CONF_TYPE_KMC_LOGIN => "login.swf", + self::UI_CONF_TYPE_SLP => "KalturaPlayer.xap", + self::UI_CONF_CLIENTSIDE_ENCODER => "KEU_0.8_win.msi", + self::UI_CONF_KMC_GENERAL => "kmc.swf", + self::UI_CONF_KMC_ROLES_AND_PERMISSIONS => "", + self::UI_CONF_CLIPPER => "", + self::UI_CONF_TYPE_KSR => "ScreencastOMaticRun.jar", + self::UI_CONF_TYPE_KRECORD => "KRecord.swf", + self::UI_CONF_TYPE_KUPLOAD => "KUpload.swf", + self::UI_CONF_TYPE_WEBCASTING => "", + self::UI_CONF_TYPE_SAP => "", + ); + + private static $swf_directory_map = array( + self::UI_CONF_TYPE_WIDGET => "kdp", + self::UI_CONF_TYPE_CW => "kcw", + self::UI_CONF_TYPE_EDITOR => "kse", + self::UI_CONF_TYPE_ADVANCED_EDITOR => "kae", + self::UI_CONF_TYPE_PLAYLIST => "kdp", + self::UI_CONF_TYPE_KMC_APP_STUDIO => "kmc/appstudio", + self::UI_CONF_TYPE_KDP3 => "kdp3", + self::UI_CONF_TYPE_KMC_ACCOUNT => "kmc/account", + self::UI_CONF_TYPE_KMC_ANALYTICS => "kmc/analytics", + self::UI_CONF_TYPE_KMC_CONTENT => "kmc/content", + self::UI_CONF_TYPE_KMC_DASHBOARD => "kmc/dashboard", + self::UI_CONF_TYPE_KMC_LOGIN => "kmc/login", + self::UI_CONF_TYPE_SLP => "slp", + self::UI_CONF_CLIENTSIDE_ENCODER => "expressUploader", + self::UI_CONF_KMC_GENERAL => "kmc", + self::UI_CONF_KMC_ROLES_AND_PERMISSIONS => "", + self::UI_CONF_CLIPPER => "kclip", + self::UI_CONF_TYPE_KSR => "ksr", + self::UI_CONF_TYPE_KRECORD => 'krecord', + self::UI_CONF_TYPE_KUPLOAD => "kupload", + self::UI_CONF_TYPE_WEBCASTING => "", + self::UI_CONF_TYPE_SAP => "", + ); + + const CUSTOM_DATA_CON_FILE_VERSION = 'conf_file_version'; + const CUSTOM_DATA_CONF_FILE_FEATURES_VERSION = 'conf_file_features_version'; + + //v2 to b7 + const CUSTOM_DATA_V2V7_ID = "v2v7_id"; + const CUSTOM_DATA_V2V7_APPROVED = "v2v7_approved"; + const CUSTOM_DATA_V2V7_TRANSLATE_PLUGINS = "v2v7_translate_plugins"; + + public function save(PropelPDO $con = null) + { + try { + $res = parent::save($con); + } catch (PropelException $e) { + /** + * Because many ui-conf objects have hard-coded id, the auto-incremented id of new ui-conf could exist in the db. + * Just retry to save the ui-conf with a different auto-inceremented id. + */ + + if ($e->getCause() && $e->getCause()->getCode() == self::MYSQL_CODE_DUPLICATE_KEY) //unique constraint + { + $res = parent::save($con); + } else { + throw $e; // Rethrow the unfamiliar exception + } + } + + if ($this->shouldSetContent()) { + foreach ($this->content as $contentItem) { + $confFile = $this->getConfFileBySuffix($contentItem['suffix']); + if ($confFile) + $this->saveConfFileToDisk($confFile, $contentItem['suffix']); + $contentItem['shouldSet'] = false; + + } + $res = parent::save($con); + } + $this->getConfFilePath(); + + return $res; + } + + private function isUiConfContentSet($subType) + { + if (!array_key_exists($subType, $this->content)) + return false; + $contentItem = $this->content[$subType]; + if (!$contentItem || !$contentItem['data']) + return false; + + return true; + } + + /* (non-PHPdoc) + * @see lib/model/om/BaseuiConf#postUpdate() + */ + public function postUpdate(PropelPDO $con = null) + { + if ($this->alreadyInSave) + return parent::postUpdate($con); + + $objectDeleted = false; + if ($this->isColumnModified(uiConfPeer::STATUS) && $this->getStatus() == self::UI_CONF_STATUS_DELETED) + $objectDeleted = true; + + $ret = parent::postUpdate($con); + + if ($objectDeleted) + kEventsManager::raiseEvent(new kObjectDeletedEvent($this)); + + return $ret; + } + + private static function initUiConfTypeMap() + { + if (self::$UI_CONF_OBJ_TYPE_MAP == null) { + self::$UI_CONF_OBJ_TYPE_MAP = array( + self::UI_CONF_TYPE_GENERIC => "Generic", + self::UI_CONF_TYPE_WIDGET => "Widget", + self::UI_CONF_TYPE_CW => "Contribution Wizard", + self::UI_CONF_TYPE_EDITOR => "Simple Editor", + self::UI_CONF_TYPE_ADVANCED_EDITOR => "Advanced Editor", + self::UI_CONF_TYPE_PLAYLIST => "Playlist", + self::UI_CONF_TYPE_KDP3 => "KDP3", + self::UI_CONF_TYPE_KMC_APP_STUDIO => "KMC AppStudio", + self::UI_CONF_TYPE_KMC_ACCOUNT => "KMC Account", + self::UI_CONF_TYPE_KMC_ANALYTICS => "KMC Analytics", + self::UI_CONF_TYPE_KMC_CONTENT => "KMC Content", + self::UI_CONF_TYPE_KMC_DASHBOARD => "KMC Dashboard", + self::UI_CONF_TYPE_KMC_LOGIN => "KMC Login", + self::UI_CONF_TYPE_SLP => "SLP", + self::UI_CONF_CLIENTSIDE_ENCODER => "Express Uploader", + self::UI_CONF_KMC_GENERAL => "KMC", + self::UI_CONF_KMC_ROLES_AND_PERMISSIONS => "KMC Roles and Permissions", + self::UI_CONF_CLIPPER => "Kaltura Clipper", + self::UI_CONF_TYPE_KSR => "Kaltura Screen Recorder", + self::UI_CONF_TYPE_KUPLOAD => "Kaltura Simple Uploader", + self::UI_CONF_TYPE_WEBCASTING => "Kaltura Webcasting Studio", + self::UI_CONF_TYPE_SAP => "Slim Audio Player", + ); + } + } + + public function isValid() + { + return true; + } + + public function getUiConfTypeMap() + { + self::initUiConfTypeMap(); + return self::$UI_CONF_OBJ_TYPE_MAP; + } + + public function getObjTypeAsString() + { + self::initUiConfTypeMap(); + return self::$UI_CONF_OBJ_TYPE_MAP[$this->getType()]; + } + + public function getType() + { + $t = parent::getObjType(); + if (empty ($t)) $t = self::UI_CONF_TYPE_WIDGET; + return $t; + } + + /** + * (non-PHPdoc) + * @see lib/model/ISyncableFile#getSyncKey() + */ + public function getSyncKey($sub_type, $version = null) + { + self::validateFileSyncSubType($sub_type); + $key = new FileSyncKey(); + $key->object_type = FileSyncObjectType::UICONF; + $key->object_sub_type = $sub_type; + $key->object_id = $this->getId(); // if ( $sub_type == self::FILE_SYNC_UICONF_SUB_TYPE_DATA ) - // TODO - add version to the DB - $key->version = $this->getVersion($sub_type); - - $key->partner_id=$this->getPartnerId(); - return $key; - } - - - - /* (non-PHPdoc) - * @see lib/model/ISyncableFile#generateFileName() - */ - public function generateFileName( $sub_type, $version = null) - { - self::validateFileSyncSubType ( $sub_type ); - - $suffix = $this->getSuffixBySubType($sub_type); - if($suffix == null) - return "ui_conf{$version}.xml"; - else - return "ui_conf.".$suffix.$version.".xml"; - - return null; - } - - /** - * (non-PHPdoc) - * @see lib/model/ISyncableFile#generateFilePathArr() - */ - public function generateFilePathArr($sub_type, $version = null, $externalPath = false ) - { - // TODO - implement field version - self::validateFileSyncSubType ( $sub_type ); - $suffix = $this->getSuffixBySubType($sub_type); - $incVersion = false; - if($sub_type == self::FILE_SYNC_UICONF_SUB_TYPE_DATA) - { - $incVersion = true; - } - - $res = $this->getConfFilePathImpl($suffix, $incVersion, $version); - - if ($externalPath) - { - $file_root = myCloudUtils::getPartnerSharedStorageBaseDir($this->getPartnerId()); - $dir = myContentStorage::getScatteredPathFromIntId($this->getId() * 10); - $file_path = "/generatedUiConf/$dir/ui_conf_{$this->getId()}_$version.xml"; - if ($suffix) - { - $file_path = str_replace("xml", "$suffix.xml", $file_path); - } - } - else - { - $file_root = myContentStorage::getFSContentRootPath(); - $file_path = str_replace(myContentStorage::getFSContentRootPath(), "", $res); - } - - return array ( $file_root , $file_path ) ; - } - - - /** - * Enter description here... - * - * @var FileSync - */ - private $m_file_sync; - - /** - * @return FileSync - */ - public function getFileSync ( ) - { - return $this->m_file_sync; - } - - public function setFileSync ( FileSync $file_sync ) - { - $this->m_file_sync = $file_sync; - } - - private static function validateFileSyncSubType ( $sub_type ) - { - if ( !in_array($sub_type, self::$validSubTypes)) - throw new FileSyncException ( FileSyncObjectType::UICONF ,$sub_type , $validSubTypes ); - } - - private function saveConfFileToDisk($v , $file_suffix = null , $isClone = false) - { - if ( $this->getCreationMode() == self::UI_CONF_CREATION_MODE_MANUAL ) - { - throw new Exception ( "Should not edit MANUAL ui_confs via the API!! Only via the SVN" ); - } - - $subType = $this->getSubTypeBySuffix($file_suffix); - $this->incrementVersion($subType); - $sync_key = $this->getSyncKey( $subType ); - - $this->setUpdatedAt( time() ); // make sure will be updated in the DB - if (version_compare($this->getSwfUrlVersion(), "2.5", ">=")) - { - $v = str_replace('.entryName}', '.name}', $v); - } - - // This is only called on Save, after parent::save(), so ID is present. - kFileSyncUtils::file_put_contents( $sync_key , $v ); //replaced__setFileContent - } - - private function setConfFileBySuffix($suffix = null, $v) - { - $subType = $this->getSubTypeBySuffix($suffix); - $contentItem = array(); - $contentItem['suffix'] = $suffix; - $contentItem['shouldSet'] = true; - $contentItem['subType'] = $subType; - - if ( $v !== null ) - { - $contentItem['data'] = $v; - $this->content[$subType] = $contentItem; - } - } - - private function getConfFileBySuffix($suffix = null, $force_fetch = false) - { - $subType = $this->getSubTypeBySuffix($suffix); - $contents = ""; - if($this->isUiConfContentSet($subType) && ! $force_fetch ) - return $this->content[$subType]['data']; - - $sync_key = $this->getSyncKey( $subType ); - - $contents = kFileSyncUtils::file_get_contents( $sync_key , true , false ); - - if(!$contents) - KalturaLog::debug("Conf file of sub type [$subType] not found for key [$sync_key]"); - return $contents; - } - - public function setConfFile ( $v /*, $increment_version = true */ ) - { - $this->setConfFileBySuffix(null, $v); - } - - public function getConfFile( $force_fetch = false ) - { - return $this->getConfFileBySuffix( null, $force_fetch); - } - - public function setConfFileFeatures ( $v ) - { - $this->setConfFileBySuffix(self::FILE_NAME_FEATURES, $v); - } - - // check this ! - public function getConfFileFeatures ( $force_fetch = false ) - { - return $this->getConfFileBySuffix( self::FILE_NAME_FEATURES, $force_fetch ); - } - - public function setConfig ( $v /*, $increment_version = true */ ) - { - $this->setConfFileBySuffix(self::FILE_NAME_CONFIG, $v); - } - - // will fetch - public function getConfig ( $force_fetch = false ) - { - return $this->getConfFileBySuffix( self::FILE_NAME_CONFIG, $force_fetch ); - } - - private $m_file_time; - private function getFileTime() - { - if ( ! $this->m_file_time ) - $this->m_file_time = strftime( "%Y-%m-%d_%H-%M-%S" , time() ); - return $this->m_file_time; - } - - public function getSwfUrl ( $raw_only = false ) - { - $raw = parent::getSwfUrl(); - if ( $raw_only ) return $raw; - $root_url = kConf::get ( "flash_root_url"); - if ( ! $root_url ) - return $raw; - if ( strpos ( $raw , $root_url) === 0 ) - { - // if the raw url already has the exact prefix of root_url - return the raw - no need to re-append it - return $raw; - } - - if ( strpos ( $raw , "http://" ) === 0 ) - { - // if the raw url starts with http - don't append to it - return $raw; - } - - return $root_url . $raw; - } - - // use this field only if the version is not empty - public function setSwfUrlVersion($version) - { - $flashUrl = myContentStorage::getFSFlashRootPath(); - $swfName = $this->getSwfNameFromType(); - $dir = $this->getDirectoryFromType(); - - if($version) - { - if (strpos($this->swf_url, "kdp3") !== false) - $this->setSwfUrl("$flashUrl/kdp3/v{$version}/kdp3.swf"); - else - $this->setSwfUrl("$flashUrl/$dir/v{$version}/$swfName"); - } - } - - public function getSwfUrlVersion () - { - $swf_url = $this->getSwfUrl(); - $flash_url = myContentStorage::getFSFlashRootPath (); - $match = preg_match ( '/\/v([\w\d\.]+)/' , $swf_url , $version ); - if ( $match ) - { - return $version[1]; - } - return null; - } - - private function getCachedContent ( $kaltura_config , $confFilePath ) - { - if ( ! file_exists ( $confFilePath ) ) return null; - if ( strpos ( $confFilePath , "://" ) != FALSE ) - { - // remote file (http:// or ftp://) - store the cache in a directory near the base file - //$cache_path = dirname( $kaltura_config ) . "cache/" . $confFilePath . "_cache.xml" ; - // for now - don't cache for remote files - $cache_path = null; - } - else - { - // this is a local file - store the cache file in the same directory - $cache_path = str_replace ( "/uiconf/" , "/cacheuiconf/" ,$confFilePath ) . "_cache.xml"; - kFile::fullMkdir( $cache_path ); - } - try - { - $s_time = microtime( true ); - $config = new kXmlConfig( $kaltura_config , $confFilePath ); - $content = $config->getConfig( $cache_path ); - $e_time = microtime( true ); - - if ( $config->createdCache() ) - KalturaLog::log( __METHOD__ . " created config cache file [$kaltura_config]+[$confFilePath]->[$cache_path].\ntook [" . ($e_time - $s_time) . "] seconds" ); - - return $content; - } - catch ( Exception $ex ) - { - KalturaLog::log( __METHOD__ . " Error creating config [$kaltura_config]+[$confFilePath]:" . $ex->getMessage() ); - return null; - } - } - - // TODO fix when add creation_mode to the DB - public function getCreationModeAsStr() - { - return self::UI_CONF_CREATION_MODE_WIZARD; - } - - // TODO - remove this function after Andromeda deployment is stable - public function internalGetParentConfFilePath() - { - return parent::getConfFilePath(); - } - - public function getConfFilePath( $file_suffix = null , $inc_version = false ) - { - return $this->getConfFilePathImpl( $file_suffix ,$inc_version ); - } - - private function getConfFilePathImpl( $file_suffix = null , $inc_version = false, $version = null ) - { - $conf_file_path = parent::getConfFilePath(); - - if ( $this->getCreationMode() != self::UI_CONF_CREATION_MODE_MANUAL ) - { - if( ! $conf_file_path || $inc_version || $version) - { - if ( ! $this->getId() ) - return null; - - $conf_file_path = $this->createConfFilePath($version); - $this->setConfFilePath( $conf_file_path ); - } - } - - // will fix the current problem in the DB- we hold the root in the conf_file_path - $conf_file_path = myContentStorage::getFSContentRootPath( ).str_replace ( "/web/" , "" , $conf_file_path ) ; - - if ( $file_suffix ) - { - // use the file_suffix before the extension - $extension = pathinfo ( $conf_file_path , PATHINFO_EXTENSION ); - $conf_file_path = str_replace ( $extension , "$file_suffix.$extension" , $conf_file_path ); - } - - return $conf_file_path; - } - - /* - * Should not be used as updateable field until the paths on disk are safe to set - */ - public function setConfFilePath( $v ) - { - if ( kString::beginsWith( $v , ".." ) ) - { - $err = "Error in " . __METHOD__ . ": attmpting to set ConfFilePath to [$v]"; - KalturaLog::log( $err ); - throw new APIException ( APIErrors::ERROR_SETTING_FILE_PATH_FOR_UI_CONF , $v ); - } - - if ( $this->getCreationMode() == self::UI_CONF_CREATION_MODE_MANUAL ) - { - if ( ! kString::beginsWith( $v , $this->getUiConfRootDirectory() . "uiconf/" ) ) - { - $v = $this->getUiConfRootDirectory() . "uiconf/" . $v ; - } - - $real_v = realpath( dirname( $v ) ) . "/" . pathinfo( $v , PATHINFO_BASENAME ); - - if ( $v ) - { - if ( $real_v ) - { -/* - * TODO - add this id the service IS externally use via the API - // the file exists - make sure we're not overiding someone elses file - $ui_confs_with_same_path = uiConfPeer::retrieveByConfFilePath ( $real_v , $this->getId() ); - foreach ( $ui_confs_with_same_path as $ui_conf ) - { - if ( $ui_conf->getPartnerId ( ) != $this->getPartnerId() ) - { - $err = "Error in " . __METHOD__ . ": attmpting to set ConfFilePath to [$v]"; - KalturaLog::log( $err ); - throw new APIException ( APIErrors::ERROR_SETTING_FILE_PATH_FOR_UI_CONF , $v ); - } - } -*/ - $v = $real_v; - } - } - parent::setConfFilePath( $v ); - } - else - { - parent::setConfFilePath( $v ); + // TODO - add version to the DB + $key->version = $this->getVersion($sub_type); + + $key->partner_id = $this->getPartnerId(); + return $key; + } + + + /* (non-PHPdoc) + * @see lib/model/ISyncableFile#generateFileName() + */ + public function generateFileName($sub_type, $version = null) + { + self::validateFileSyncSubType($sub_type); + + $suffix = $this->getSuffixBySubType($sub_type); + if ($suffix == null) + return "ui_conf{$version}.xml"; + else + return "ui_conf." . $suffix . $version . ".xml"; + + return null; + } + + /** + * (non-PHPdoc) + * @see lib/model/ISyncableFile#generateFilePathArr() + */ + public function generateFilePathArr($sub_type, $version = null, $externalPath = false) + { + // TODO - implement field version + self::validateFileSyncSubType($sub_type); + $suffix = $this->getSuffixBySubType($sub_type); + $incVersion = false; + if ($sub_type == self::FILE_SYNC_UICONF_SUB_TYPE_DATA) { + $incVersion = true; + } + + $res = $this->getConfFilePathImpl($suffix, $incVersion, $version); + + if ($externalPath) { + $file_root = myCloudUtils::getPartnerSharedStorageBaseDir($this->getPartnerId()); + $dir = myContentStorage::getScatteredPathFromIntId($this->getId() * 10); + $file_path = "/generatedUiConf/$dir/ui_conf_{$this->getId()}_$version.xml"; + if ($suffix) { + $file_path = str_replace("xml", "$suffix.xml", $file_path); + } + } else { + $file_root = myContentStorage::getFSContentRootPath(); + $file_path = str_replace(myContentStorage::getFSContentRootPath(), "", $res); + } + + return array($file_root, $file_path); + } + + + /** + * Enter description here... + * + * @var FileSync + */ + private $m_file_sync; + + /** + * @return FileSync + */ + public function getFileSync() + { + return $this->m_file_sync; + } + + public function setFileSync(FileSync $file_sync) + { + $this->m_file_sync = $file_sync; + } + + private static function validateFileSyncSubType($sub_type) + { + if (!in_array($sub_type, self::$validSubTypes)) + throw new FileSyncException (FileSyncObjectType::UICONF, $sub_type, $validSubTypes); + } + + private function saveConfFileToDisk($v, $file_suffix = null, $isClone = false) + { + if ($this->getCreationMode() == self::UI_CONF_CREATION_MODE_MANUAL) { + throw new Exception ("Should not edit MANUAL ui_confs via the API!! Only via the SVN"); + } + + $subType = $this->getSubTypeBySuffix($file_suffix); + $this->incrementVersion($subType); + $sync_key = $this->getSyncKey($subType); + + $this->setUpdatedAt(time()); // make sure will be updated in the DB + if (version_compare($this->getSwfUrlVersion(), "2.5", ">=")) { + $v = str_replace('.entryName}', '.name}', $v); + } + + // This is only called on Save, after parent::save(), so ID is present. + kFileSyncUtils::file_put_contents($sync_key, $v); //replaced__setFileContent + } + + private function setConfFileBySuffix($suffix = null, $v) + { + $subType = $this->getSubTypeBySuffix($suffix); + $contentItem = array(); + $contentItem['suffix'] = $suffix; + $contentItem['shouldSet'] = true; + $contentItem['subType'] = $subType; + + if ($v !== null) { + $contentItem['data'] = $v; + $this->content[$subType] = $contentItem; + } + } + + private function getConfFileBySuffix($suffix = null, $force_fetch = false) + { + $subType = $this->getSubTypeBySuffix($suffix); + $contents = ""; + if ($this->isUiConfContentSet($subType) && !$force_fetch) + return $this->content[$subType]['data']; + + $sync_key = $this->getSyncKey($subType); + + $contents = kFileSyncUtils::file_get_contents($sync_key, true, false); + + if (!$contents) + KalturaLog::debug("Conf file of sub type [$subType] not found for key [$sync_key]"); + return $contents; + } + + public function setConfFile($v /*, $increment_version = true */) + { + $this->setConfFileBySuffix(null, $v); + } + + public function getConfFile($force_fetch = false) + { + return $this->getConfFileBySuffix(null, $force_fetch); + } + + public function setConfFileFeatures($v) + { + $this->setConfFileBySuffix(self::FILE_NAME_FEATURES, $v); + } + + // check this ! + public function getConfFileFeatures($force_fetch = false) + { + return $this->getConfFileBySuffix(self::FILE_NAME_FEATURES, $force_fetch); + } + + public function setConfig($v /*, $increment_version = true */) + { + $this->setConfFileBySuffix(self::FILE_NAME_CONFIG, $v); + } + + // will fetch + public function getConfig($force_fetch = false) + { + return $this->getConfFileBySuffix(self::FILE_NAME_CONFIG, $force_fetch); + } + + private $m_file_time; + + private function getFileTime() + { + if (!$this->m_file_time) + $this->m_file_time = strftime("%Y-%m-%d_%H-%M-%S", time()); + return $this->m_file_time; + } + + public function getSwfUrl($raw_only = false) + { + $raw = parent::getSwfUrl(); + if ($raw_only) return $raw; + $root_url = kConf::get("flash_root_url"); + if (!$root_url) + return $raw; + if (strpos($raw, $root_url) === 0) { + // if the raw url already has the exact prefix of root_url - return the raw - no need to re-append it + return $raw; + } + + if (strpos($raw, "http://") === 0) { + // if the raw url starts with http - don't append to it + return $raw; + } + + return $root_url . $raw; + } + + // use this field only if the version is not empty + public function setSwfUrlVersion($version) + { + $flashUrl = myContentStorage::getFSFlashRootPath(); + $swfName = $this->getSwfNameFromType(); + $dir = $this->getDirectoryFromType(); + + if ($version) { + if (strpos($this->swf_url, "kdp3") !== false) + $this->setSwfUrl("$flashUrl/kdp3/v{$version}/kdp3.swf"); + else + $this->setSwfUrl("$flashUrl/$dir/v{$version}/$swfName"); + } + } + + public function getSwfUrlVersion() + { + $swf_url = $this->getSwfUrl(); + $flash_url = myContentStorage::getFSFlashRootPath(); + $match = preg_match('/\/v([\w\d\.]+)/', $swf_url, $version); + if ($match) { + return $version[1]; + } + return null; + } + + private function getCachedContent($kaltura_config, $confFilePath) + { + if (!file_exists($confFilePath)) return null; + if (strpos($confFilePath, "://") != FALSE) { + // remote file (http:// or ftp://) - store the cache in a directory near the base file + //$cache_path = dirname( $kaltura_config ) . "cache/" . $confFilePath . "_cache.xml" ; + // for now - don't cache for remote files + $cache_path = null; + } else { + // this is a local file - store the cache file in the same directory + $cache_path = str_replace("/uiconf/", "/cacheuiconf/", $confFilePath) . "_cache.xml"; + kFile::fullMkdir($cache_path); + } + try { + $s_time = microtime(true); + $config = new kXmlConfig($kaltura_config, $confFilePath); + $content = $config->getConfig($cache_path); + $e_time = microtime(true); + + if ($config->createdCache()) + KalturaLog::log(__METHOD__ . " created config cache file [$kaltura_config]+[$confFilePath]->[$cache_path].\ntook [" . ($e_time - $s_time) . "] seconds"); + + return $content; + } catch (Exception $ex) { + KalturaLog::log(__METHOD__ . " Error creating config [$kaltura_config]+[$confFilePath]:" . $ex->getMessage()); + return null; + } + } + + // TODO fix when add creation_mode to the DB + public function getCreationModeAsStr() + { + return self::UI_CONF_CREATION_MODE_WIZARD; + } + + // TODO - remove this function after Andromeda deployment is stable + public function internalGetParentConfFilePath() + { + return parent::getConfFilePath(); + } + + public function getConfFilePath($file_suffix = null, $inc_version = false) + { + return $this->getConfFilePathImpl($file_suffix, $inc_version); + } + + private function getConfFilePathImpl($file_suffix = null, $inc_version = false, $version = null) + { + $conf_file_path = parent::getConfFilePath(); + + if ($this->getCreationMode() != self::UI_CONF_CREATION_MODE_MANUAL) { + if (!$conf_file_path || $inc_version || $version) { + if (!$this->getId()) + return null; + + $conf_file_path = $this->createConfFilePath($version); + $this->setConfFilePath($conf_file_path); + } + } + + // will fix the current problem in the DB- we hold the root in the conf_file_path + $conf_file_path = myContentStorage::getFSContentRootPath() . str_replace("/web/", "", $conf_file_path); + + if ($file_suffix) { + // use the file_suffix before the extension + $extension = pathinfo($conf_file_path, PATHINFO_EXTENSION); + $conf_file_path = str_replace($extension, "$file_suffix.$extension", $conf_file_path); + } + + return $conf_file_path; + } + + /* + * Should not be used as updateable field until the paths on disk are safe to set + */ + public function setConfFilePath($v) + { + if (kString::beginsWith($v, "..")) { + $err = "Error in " . __METHOD__ . ": attmpting to set ConfFilePath to [$v]"; + KalturaLog::log($err); + throw new APIException (APIErrors::ERROR_SETTING_FILE_PATH_FOR_UI_CONF, $v); + } + + if ($this->getCreationMode() == self::UI_CONF_CREATION_MODE_MANUAL) { + if (!kString::beginsWith($v, $this->getUiConfRootDirectory() . "uiconf/")) { + $v = $this->getUiConfRootDirectory() . "uiconf/" . $v; + } + + $real_v = realpath(dirname($v)) . "/" . pathinfo($v, PATHINFO_BASENAME); + + if ($v) { + if ($real_v) { + /* + * TODO - add this id the service IS externally use via the API + // the file exists - make sure we're not overiding someone elses file + $ui_confs_with_same_path = uiConfPeer::retrieveByConfFilePath ( $real_v , $this->getId() ); + foreach ( $ui_confs_with_same_path as $ui_conf ) + { + if ( $ui_conf->getPartnerId ( ) != $this->getPartnerId() ) + { + $err = "Error in " . __METHOD__ . ": attmpting to set ConfFilePath to [$v]"; + KalturaLog::log( $err ); + throw new APIException ( APIErrors::ERROR_SETTING_FILE_PATH_FOR_UI_CONF , $v ); + } + } + */ + $v = $real_v; + } + } + parent::setConfFilePath($v); + } else { + parent::setConfFilePath($v); // throw new APIException ( APIErrors::ERROR_SETTING_FILE_PATH_FOR_UI_CONF , $v ); - } - } - - private function createConfFilePath ($version = null) - { - if ( $this->getVersion() || $version) - $version = "_" . ($version ? $version : $this->getVersion()); - else - $version = ""; - - $dir = (intval($this->getId() / 1000000)).'/'. (intval($this->getId() / 1000) % 1000); - $file_name = "/content/generatedUiConf/$dir/ui_conf_{$this->getId()}_{$version}.xml"; - return $file_name; - } - - // IMPORTANT : WILL NOT include the uiconf or generatedUiconf part of the path - private function getUiConfRootDirectory () - { - $content_path = myContentStorage::getFSContentRootPath(); - return $content_path . "content/"; - } - - /* - * will create a new uiConf object in the DB from this object while using fields from - */ - public function cloneToNew ( $new_ui_conf_obj , $new_name = null ) - { - $cloned = new uiConf(); - $cloned->setCopiedFrom($this); - - $all_fields = uiConfPeer::getFieldNames (); - $ignore_list = array ( "Id" , "ConfFilePath" ); - // clone from current - baseObjectUtils::fillObjectFromObject( $all_fields , - $this , - $cloned , - baseObjectUtils::CLONE_POLICY_PREFER_NEW , $ignore_list , BasePeer::TYPE_PHPNAME ); + } + } + + private function createConfFilePath($version = null) + { + if ($this->getVersion() || $version) + $version = "_" . ($version ? $version : $this->getVersion()); + else + $version = ""; + + $dir = (intval($this->getId() / 1000000)) . '/' . (intval($this->getId() / 1000) % 1000); + $file_name = "/content/generatedUiConf/$dir/ui_conf_{$this->getId()}_{$version}.xml"; + return $file_name; + } + + // IMPORTANT : WILL NOT include the uiconf or generatedUiconf part of the path + private function getUiConfRootDirectory() + { + $content_path = myContentStorage::getFSContentRootPath(); + return $content_path . "content/"; + } + + /* + * will create a new uiConf object in the DB from this object while using fields from + */ + public function cloneToNew($new_ui_conf_obj, $new_name = null) + { + $cloned = new uiConf(); + $cloned->setCopiedFrom($this); + + $all_fields = uiConfPeer::getFieldNames(); + $ignore_list = array("Id", "ConfFilePath"); + // clone from current + baseObjectUtils::fillObjectFromObject($all_fields, + $this, + $cloned, + baseObjectUtils::CLONE_POLICY_PREFER_NEW, $ignore_list, BasePeer::TYPE_PHPNAME); // $cloned->setNew(true); - // override with data from the $new_ui_conf_obj - the name can be chosen to override - if ( $new_ui_conf_obj ) - { - baseObjectUtils::fillObjectFromObject( $all_fields , // assume the new_ui_conf_obj can be fully copied to the cloned - $new_ui_conf_obj , - $cloned , - baseObjectUtils::CLONE_POLICY_PREFER_NEW , null , BasePeer::TYPE_PHPNAME ); - } - - if ($new_name) - { - $cloned->setName( $new_name ); - } - - foreach (self::$validSubTypes as $subType) - { - $suffix = $this->getSuffixBySubType($subType); - $content = $this->getConfFileBySuffix($suffix); - $cloned->setConfFileBySuffix($suffix, $content); - } - - $cloned->save(null); - return $cloned; - } - - public function getSwfNameFromType () - { - $name = @self::$swf_names [ $this->getObjType()]; - if($name) - return $name; - return ""; - } - - public function getDirectoryFromType() - { - if(isset(self::$swf_directory_map[$this->getObjType()])) - return self::$swf_directory_map[$this->getObjType()]; - - return ""; - } - - public function getDirectoryMap () - { - return self::$swf_directory_map; - } - - public function getSwfNames() - { - return self::$swf_names; - } - - - - - + // override with data from the $new_ui_conf_obj - the name can be chosen to override + if ($new_ui_conf_obj) { + baseObjectUtils::fillObjectFromObject($all_fields, // assume the new_ui_conf_obj can be fully copied to the cloned + $new_ui_conf_obj, + $cloned, + baseObjectUtils::CLONE_POLICY_PREFER_NEW, null, BasePeer::TYPE_PHPNAME); + } + + if ($new_name) { + $cloned->setName($new_name); + } + + foreach (self::$validSubTypes as $subType) { + $suffix = $this->getSuffixBySubType($subType); + $content = $this->getConfFileBySuffix($suffix); + $cloned->setConfFileBySuffix($suffix, $content); + } + + $cloned->save(null); + return $cloned; + } + + public function getSwfNameFromType() + { + $name = @self::$swf_names [$this->getObjType()]; + if ($name) + return $name; + return ""; + } + + public function getDirectoryFromType() + { + if (isset(self::$swf_directory_map[$this->getObjType()])) + return self::$swf_directory_map[$this->getObjType()]; + + return ""; + } + + public function getDirectoryMap() + { + return self::$swf_directory_map; + } + + public function getSwfNames() + { + return self::$swf_names; + } + + + public function getAutoplay() + { + return $this->getFromCustomData("autoplay", null, false); + } + + public function setAutoplay($v) + { + return $this->putInCustomData("autoplay", $v); + } + + public function getAutomuted() + { + return $this->getFromCustomData("automuted", null, false); + } + + public function setAutomuted($v) + { + return $this->putInCustomData("automuted", $v); + } + + public function getConfFileVersion() + { + return $this->getFromCustomData(self::CUSTOM_DATA_CON_FILE_VERSION, null, 0); + } + + public function setConfFileVersion($v) + { + return $this->putInCustomData(self::CUSTOM_DATA_CON_FILE_VERSION, $v); + } + + public function getConfFileFeaturesVersion() + { + return $this->getFromCustomData(self::CUSTOM_DATA_CONF_FILE_FEATURES_VERSION, null, 0); + } + + public function setConfFileFeaturesVersion($v) + { + return $this->putInCustomData(self::CUSTOM_DATA_CONF_FILE_FEATURES_VERSION, $v); + } + + + public function getCacheInvalidationKeys() + { + return array("uiConf:id=" . strtolower($this->getId()), "uiConf:partnerId=" . strtolower($this->getPartnerId())); + } + + private function shouldSetContent() + { + foreach ($this->content as $contentItem) { + if ($contentItem['shouldSet']) + return true; + } + return false; + } + + private function getSubTypeBySuffix($suffix = null) + { + if ($suffix == null) + return self::FILE_SYNC_UICONF_SUB_TYPE_DATA; + if ($suffix == self::FILE_NAME_FEATURES) + return self::FILE_SYNC_UICONF_SUB_TYPE_FEATURES; + if ($suffix == self::FILE_NAME_CONFIG) + return self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG; + } + + private function getSuffixBySubType($subType) + { + if ($subType == self::FILE_SYNC_UICONF_SUB_TYPE_DATA) + return null; + if ($subType == self::FILE_SYNC_UICONF_SUB_TYPE_FEATURES) + return self::FILE_NAME_FEATURES; + if ($subType == self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG) + return self::FILE_NAME_CONFIG; + } + + public function incrementVersion($subType = self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG) + { + $version = $this->getVersion($subType); + $newVersion = kFileSyncUtils::calcObjectNewVersion($this->getId(), $version, FileSyncObjectType::UICONF, $subType); + if ($subType == self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG) { + if (!$this->getConfFileVersion() && $this->getConfFileBySuffix()) { + $this->setConfFileVersion($version); + } + if (!$this->getConfFileFeaturesVersion() && $this->getConfFileBySuffix(self::FILE_NAME_FEATURES)) { + $this->setConfFileFeaturesVersion($version); + } + } + + $this->setVersion($newVersion, $subType); + } + + //by default version of the config file is returned + public function getVersion($subType = self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG) + { + switch ($subType) { + case self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG: + return parent::getVersion(); + case self::FILE_SYNC_UICONF_SUB_TYPE_DATA: + $version = $this->getConfFileVersion(); + if ($version) + return $version; + else + return parent::getVersion(); + case self::FILE_SYNC_UICONF_SUB_TYPE_FEATURES: + $version = $this->getConfFileFeaturesVersion(); + if ($version) + return $version; + else + return parent::getVersion(); + + } + + return parent::getVersion(); + } + + public function setVersion($v, $subType = self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG) + { + switch ($subType) { + case self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG: + return parent::setVersion($v); + case self::FILE_SYNC_UICONF_SUB_TYPE_DATA: + return $this->setConfFileVersion($v); + case self::FILE_SYNC_UICONF_SUB_TYPE_FEATURES: + return $this->setConfFileFeaturesVersion($v); + } + + return parent::setVersion($v); + } - public function getAutoplay () { return $this->getFromCustomData( "autoplay" , null , false ); } - public function setAutoplay( $v ) { return $this->putInCustomData( "autoplay", $v ); } - - public function getAutomuted () { return $this->getFromCustomData( "automuted" , null , false ); } - public function setAutomuted( $v ) { return $this->putInCustomData( "automuted", $v ); } - - public function getConfFileVersion () { return $this->getFromCustomData( self::CUSTOM_DATA_CON_FILE_VERSION, null, 0); } - public function setConfFileVersion( $v ) { return $this->putInCustomData( self::CUSTOM_DATA_CON_FILE_VERSION, $v ); } - - public function getConfFileFeaturesVersion () { return $this->getFromCustomData( self::CUSTOM_DATA_CONF_FILE_FEATURES_VERSION, null, 0); } - public function setConfFileFeaturesVersion( $v ) { return $this->putInCustomData( self::CUSTOM_DATA_CONF_FILE_FEATURES_VERSION, $v ); } - - - public function getCacheInvalidationKeys() - { - return array("uiConf:id=".strtolower($this->getId()), "uiConf:partnerId=".strtolower($this->getPartnerId())); - } - - private function shouldSetContent() + //v2 to v7 + public function getV2tov7id() { - foreach ($this->content as $contentItem) - { - if($contentItem['shouldSet']) - return true; - } - return false; + return $this->getFromCustomData(self::CUSTOM_DATA_V2V7_ID, null, null); } - - private function getSubTypeBySuffix($suffix = null) + public function setV2tov7id($v) { - if($suffix == null) - return self::FILE_SYNC_UICONF_SUB_TYPE_DATA; - if($suffix == self::FILE_NAME_FEATURES) - return self::FILE_SYNC_UICONF_SUB_TYPE_FEATURES; - if($suffix == self::FILE_NAME_CONFIG) - return self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG; + return $this->putInCustomData(self::CUSTOM_DATA_V2V7_ID, $v); } - - private function getSuffixBySubType($subType) + public function getV2tov7Approved() { - if($subType == self::FILE_SYNC_UICONF_SUB_TYPE_DATA) - return null; - if($subType == self::FILE_SYNC_UICONF_SUB_TYPE_FEATURES) - return self::FILE_NAME_FEATURES; - if($subType == self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG) - return self::FILE_NAME_CONFIG; + $val = $this->getFromCustomData(self::CUSTOM_DATA_V2V7_APPROVED, null, false, null); + return ($val === 1 || $val === true || $val === "true"); } - - public function incrementVersion($subType = self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG) + public function setV2tov7Approved($v) { - $version = $this->getVersion($subType); - $newVersion = kFileSyncUtils::calcObjectNewVersion($this->getId(), $version, FileSyncObjectType::UICONF, $subType); - if($subType == self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG) - { - if(!$this->getConfFileVersion() && $this->getConfFileBySuffix()) - { - $this->setConfFileVersion($version); - } - if(!$this->getConfFileFeaturesVersion() && $this->getConfFileBySuffix(self::FILE_NAME_FEATURES)) - { - $this->setConfFileFeaturesVersion($version); - } - } - - $this->setVersion($newVersion, $subType); + return $this->putInCustomData(self::CUSTOM_DATA_V2V7_APPROVED, $v); } - - //by default version of the config file is returned - public function getVersion($subType = self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG) + public function getShouldTranslatePluginsToV7() { - switch ($subType) - { - case self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG: - return parent::getVersion(); - case self::FILE_SYNC_UICONF_SUB_TYPE_DATA: - $version = $this->getConfFileVersion(); - if($version) - return $version; - else - return parent::getVersion(); - case self::FILE_SYNC_UICONF_SUB_TYPE_FEATURES: - $version = $this->getConfFileFeaturesVersion(); - if($version) - return $version; - else - return parent::getVersion(); - - } - - return parent::getVersion(); + $val = $this->getFromCustomData(self::CUSTOM_DATA_V2V7_TRANSLATE_PLUGINS, null, false, null); + return ($val === 1 || $val === true || $val === "true"); } - - public function setVersion($v, $subType = self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG) + public function setShouldTranslatePluginsToV7($v) { - switch ($subType) - { - case self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG: - return parent::setVersion($v); - case self::FILE_SYNC_UICONF_SUB_TYPE_DATA: - return $this->setConfFileVersion($v); - case self::FILE_SYNC_UICONF_SUB_TYPE_FEATURES: - return $this->setConfFileFeaturesVersion($v); - } - - return parent::setVersion($v); + return $this->putInCustomData( self::CUSTOM_DATA_V2V7_TRANSLATE_PLUGINS, $v ); } - - //v2 to v7 - public function getV2tov7id(){ return $this->getFromCustomData( self::CUSTOM_DATA_V2V7_ID, null , null ); } - public function setV2tov7id($v){ return $this->putInCustomData( self::CUSTOM_DATA_V2V7_ID, $v ); } - public function getV2tov7Approved(){ return $this->getFromCustomData( self::CUSTOM_DATA_V2V7_APPROVED, null, false , null ); } - public function setV2tov7Approved($v){ return $this->putInCustomData( self::CUSTOM_DATA_V2V7_APPROVED, $v ); } - public function getShouldTranslatePluginsToV7(){ return $this->getFromCustomData( self::CUSTOM_DATA_V2V7_TRANSLATE_PLUGINS, null,false , null ); } - public function setShouldTranslatePluginsToV7($v){ return $this->putInCustomData( self::CUSTOM_DATA_V2V7_TRANSLATE_PLUGINS, $v ); } } From fa1f089f67fec39d0157428a7b9725b30ba66798 Mon Sep 17 00:00:00 2001 From: MosheMaorKaltura Date: Thu, 8 Aug 2024 14:08:24 +0300 Subject: [PATCH 06/96] PLAT-24912: v2 to v7 --- .../actions/embedIframeJsAction.class.php | 2 +- alpha/lib/model/uiConf.php | 4 ++-- api_v3/lib/types/KalturaUiConf.php | 18 +++++++++--------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php index 38cfda6c13f..7309339aebc 100644 --- a/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php @@ -67,7 +67,7 @@ public function execute() //redirect the call to V7 if($uiConf->getV2tov7id() && ($this->getRequestParameter(v2Tov7Utils::V2TOV7_PARAM_NAME) || $uiConf->getV2tov7Approved()) ) { - $this->redirectToV7($uiConf->getV2tov7id(), $uiconf_id, $partner_id, $uiConf->getShouldTranslatePluginsToV7() ); + $this->redirectToV7($uiConf->getV2tov7id(), $uiconf_id, $partner_id, $uiConf->getV2tov7ShouldTranslatePlugins() ); } diff --git a/alpha/lib/model/uiConf.php b/alpha/lib/model/uiConf.php index 830e323a7a1..d5a9ae153eb 100644 --- a/alpha/lib/model/uiConf.php +++ b/alpha/lib/model/uiConf.php @@ -815,12 +815,12 @@ public function setV2tov7Approved($v) { return $this->putInCustomData(self::CUSTOM_DATA_V2V7_APPROVED, $v); } - public function getShouldTranslatePluginsToV7() + public function getV2tov7ShouldTranslatePlugins() { $val = $this->getFromCustomData(self::CUSTOM_DATA_V2V7_TRANSLATE_PLUGINS, null, false, null); return ($val === 1 || $val === true || $val === "true"); } - public function setShouldTranslatePluginsToV7($v) + public function setV2tov7ShouldTranslatePlugins($v) { return $this->putInCustomData( self::CUSTOM_DATA_V2V7_TRANSLATE_PLUGINS, $v ); } diff --git a/api_v3/lib/types/KalturaUiConf.php b/api_v3/lib/types/KalturaUiConf.php index a5887652b4a..d1ae13e6f98 100644 --- a/api_v3/lib/types/KalturaUiConf.php +++ b/api_v3/lib/types/KalturaUiConf.php @@ -162,15 +162,15 @@ class KalturaUiConf extends KalturaObject implements IFilterable */ public $v2tov7id; - /** - * @var string - */ - public $v2tov7Approved; + /** + * @var string + */ + public $v2tov7Approved; - /** - * @var string - */ - public $v2tov7ShouldTranslatePlugins; + /** + * @var string + */ + public $v2tov7ShouldTranslatePlugins; private static $map_between_objects = array @@ -201,7 +201,7 @@ class KalturaUiConf extends KalturaObject implements IFilterable "partnerTags", "v2tov7id", "v2tov7Approved", - "v2tov7ShouldTranslatePlugins" => "shouldTranslatePluginsToV7" + "v2tov7ShouldTranslatePlugins" ); public function getMapBetweenObjects ( ) From 7564a5b33eb71a490f448bad728a870386923b82 Mon Sep 17 00:00:00 2001 From: MosheMaorKaltura Date: Thu, 8 Aug 2024 14:09:46 +0300 Subject: [PATCH 07/96] PLAT-24912: v2 to v7 --- api_v3/lib/types/KalturaUiConf.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api_v3/lib/types/KalturaUiConf.php b/api_v3/lib/types/KalturaUiConf.php index d1ae13e6f98..c9bd5d4e825 100644 --- a/api_v3/lib/types/KalturaUiConf.php +++ b/api_v3/lib/types/KalturaUiConf.php @@ -173,7 +173,7 @@ class KalturaUiConf extends KalturaObject implements IFilterable public $v2tov7ShouldTranslatePlugins; - private static $map_between_objects = array + private static $map_between_objects = array ( "id" , "creationMode" , @@ -197,11 +197,11 @@ class KalturaUiConf extends KalturaObject implements IFilterable "updatedAt", "html5Url", "config", - "version", + "version", "partnerTags", "v2tov7id", - "v2tov7Approved", - "v2tov7ShouldTranslatePlugins" + "v2tov7Approved", + "v2tov7ShouldTranslatePlugins" ); public function getMapBetweenObjects ( ) From ccc7228a41433df568d5393475e8d6cdb7ed3b4e Mon Sep 17 00:00:00 2001 From: MosheMaorKaltura Date: Thu, 8 Aug 2024 15:32:36 +0300 Subject: [PATCH 08/96] PLAT-24912: v2 to v7 --- .../modules/extwidget/actions/embedPlaykitJsAction.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php index 94c75ebc949..342cb27caa7 100644 --- a/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php @@ -75,6 +75,7 @@ public function execute() if($this->getRequestParameter(v2Tov7Utils::V2TOV7_PARAM_NAME)) { KalturaLog::log("Adding v2 to v7 facade"); + //Will be replaced with URL to remote player code $v2ToV7Code = PHP_EOL . PHP_EOL . '!function(){"use strict";var e={593:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.ThumbnailEmbedComponent=t.thumbnailEmbed=void 0;const o=n(14);Object.defineProperty(t,"ThumbnailEmbedComponent",{enumerable:!0,get:function(){return o.ThumbnailEmbedComponent}});const i=n(512);Object.defineProperty(t,"thumbnailEmbed",{enumerable:!0,get:function(){return i.thumbnailEmbed}}),window.__thumbnailEmbed=i.thumbnailEmbed},14:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ThumbnailEmbedComponent=void 0;const n="#000";t.ThumbnailEmbedComponent=({onClick:e,src:t,bgColor:o=n})=>{const i=window.KalturaPlayer,{Button:r,Icon:d,IconType:a}=i.ui.components,{h:l}=i.ui.preact,{useRef:s,useState:u,useCallback:c}=i.ui.preactHooks,m=c((()=>{e(),h(!1)})),b=c((()=>{g(!0)})),p=c((()=>{g(!0),P(!0)})),y=s(),[f,h]=u(!0),[v,g]=u(!1),[I,P]=u(!1);return f?l("div",{style:{width:"100%",height:"100%",position:"relative",backgroundColor:I?o:n}},I?void 0:l("img",{src:t,ref:y,onLoad:b,onError:p,style:{width:"100%",height:"100%","object-fit":"contain"}}),v?l("div",{className:i.ui.style.prePlaybackPlayOverlay,style:{width:"100%",height:"100%"}},l(r,{className:i.ui.style.prePlaybackPlayButton,tabIndex:0,onClick:m},l(d,{type:a.Play}))):void 0):void 0}},512:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.thumbnailEmbed=void 0;const o=n(14);t.thumbnailEmbed=({config:e,mediaInfo:t,mediaOptions:n={},version:i=1e4,bgColor:r})=>{if(!e||!t)return;const d=(e=>{var t,n,o,i;if(null===(t=e.provider.env)||void 0===t?void 0:t.cdnUrl)return null===(n=e.provider.env)||void 0===n?void 0:n.cdnUrl;const r=window.__kalturaplayerdata;return r?null===(i=null===(o=r.provider)||void 0===o?void 0:o.env)||void 0===i?void 0:i.cdnUrl:"https://cdnapisec.kaltura.com"})(e),{targetId:a,provider:{partnerId:l,ks:s}}=e,u=window.KalturaPlayer;var c=document.getElementById(a);if(!c||!u||u.getPlayer&&u.getPlayer(a))return;let m=1920,b=1080;c.clientWidth&&c.clientHeight&&(m=c.clientWidth,b=c.clientHeight);const p=`${d.endsWith("/")?d:d+"/"}p/${l}/sp/${l}00/thumbnail/entry_id/${t.entryId}/version/${i}/width/${m}/height/${b}`+(s?`/ks/${s}`:""),{h:y,render:f}=u.ui.preact;f(y(o.ThumbnailEmbedComponent,{src:p,bgColor:r,onClick:()=>{try{const o=u.setup(e);o.loadMedia(t,n),o.play()}catch(e){}}}),c)}},371:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.thumbEmbed=t.embed=void 0;const o=n(593),i=n(890),r=window.KalturaPlayer;t.embed=e=>{console.log("## v2Config -----\x3e",e);const{targetId:t,partnerId:n,uiConfId:o,mediaInfo:d}=(0,i.getInfoFromV2Config)(e);let a={log:{level:"DEBUG"},targetId:t,provider:{partnerId:n}};const l=(0,i.buildConfigFromFlashvars)(e),s=Object.assign({},a,l);try{const e=r.setup(s),n=document.getElementById(t);n&&(n.addJsListener=(t,n)=>{"mediaLoaded"===t&&e.addEventListener("medialoaded",(()=>{n()}))});const o=d.id;d.isPlaylist?e.loadPlaylist({playlistId:o}):e.loadMedia({entryId:o})}catch(e){}},t.thumbEmbed=e=>{const{targetId:t,partnerId:n,uiConfId:r,mediaInfo:d}=(0,i.getInfoFromV2Config)(e);try{const e={config:{targetId:t,provider:{partnerId:n}},mediaInfo:{entryId:d.id}};(0,o.thumbnailEmbed)(e)}catch(e){}}},890:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.buildConfigFromFlashvars=t.getMediaInfo=t.getInfoFromV2Config=void 0,t.getInfoFromV2Config=e=>({targetId:e.targetId,partnerId:e.wid.match(/\d+/g).join(""),uiConfId:e.uiconf_id,mediaInfo:(0,t.getMediaInfo)(e)}),t.getMediaInfo=e=>{if(e.entry_id)return{id:e.entry_id,isPlaylist:!1};let t="";const n=e.flashvars;return n.hasOwnProperty("playlistAPI.kpl0Id")?t=n["playlistAPI.kpl0Id"]:n.hasOwnProperty("playlistAPI")&&n.playlistAPI.hasOwnProperty("kpl0Id")&&(t=n.playlistAPI.kpl0Id),{id:t,isPlaylist:!0}},t.buildConfigFromFlashvars=e=>{let t={text:{},playback:{},streaming:{},abr:{},drm:{},network:{},plugins:{}};if(e.hasOwnProperty("flashvars")){const n=e.flashvars;n.hasOwnProperty("autoPlay")&&(t.playback.autoplay=n.autoPlay)}return t}}},t={};function n(o){var i=t[o];if(void 0!==i)return i.exports;var r=t[o]={exports:{}};return e[o](r,r.exports,n),r.exports}!function(){const e=n(371);window.kWidget={embed:e.embed,thumbEmbed:e.thumbEmbed}}()}();'; $bundleContent = $bundleContent . $v2ToV7Code; } From 9996a862824962c09d3318c2e300fa5b42b28728 Mon Sep 17 00:00:00 2001 From: MosheMaorKaltura Date: Sun, 11 Aug 2024 14:52:14 +0300 Subject: [PATCH 09/96] PLAT-24912: Add support in caching of v2tov7 facade --- alpha/apps/kaltura/lib/v2Tov7Utils.class.php | 31 +++++++++++++++++++ .../actions/embedIframeJsAction.class.php | 2 ++ .../actions/embedPlaykitJsAction.class.php | 6 ++-- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/alpha/apps/kaltura/lib/v2Tov7Utils.class.php b/alpha/apps/kaltura/lib/v2Tov7Utils.class.php index ccd11b26d9a..12499d903b6 100644 --- a/alpha/apps/kaltura/lib/v2Tov7Utils.class.php +++ b/alpha/apps/kaltura/lib/v2Tov7Utils.class.php @@ -125,4 +125,35 @@ private static function v2toV7PluginMap() "bumper" => [ "playkit-bumper" , "bumper" ], "infoScreen" => ["playkit-info", "playkit-js-info"]]; } + + public static function getBundledFacade() + { + //build key based on version + $facadeVersion = kConf::getArrayValue('v2tov7FacadeVersion','playkit-js'); + $facadeVersion .= "/v2tov7Facade.js"; + + //try get value from local memcache + $cacheStore = kCacheManager::getSingleLayerCache(kCacheManager::CACHE_TYPE_PLAYKIT_JS); + $bundledFacade = $cacheStore->get($facadeVersion); + if(strlen($bundledFacade)) + { + return $bundledFacade; + } + + //if not local - get it from remote location + $remoteUrl = kConf::getArrayValue('v2tov7FacadeRemoteUrl','playkit-js'); + $remoteUrl .= '/' . $facadeVersion; + + $curlWrapper = new KCurlWrapper(); + + $content = $curlWrapper->exec($remoteUrl,null, null, true); + if(KCurlHeaderResponse::isError($curlWrapper->getHttpCode())) + { + throw new Exception ('Cannot find V2 to V7 facade in the following URL: ' . $remoteUrl . "Error code:" . $curlWrapper->getHttpCode()); + } + + //store in local cache for next time + $cacheStore->set($facadeVersion,$content); + return $content; + } } \ No newline at end of file diff --git a/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php index 7309339aebc..0d1fdca08af 100644 --- a/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php @@ -174,6 +174,8 @@ private function redirectToV7($v7Id, $v2UiConfId, $partnerId, $shouldTranslatePl $config['bundleConfig'], $config['playerConfig']); } + //validate that the facade is reachable + v2Tov7Utils::getBundledFacade(); } catch(Exception $e) { diff --git a/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php index 342cb27caa7..7d82b379bd1 100644 --- a/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php @@ -74,9 +74,9 @@ public function execute() $bundleContent = $this->formatBundleContent($bundleContent, $i18nContent, $extraModulesNames); if($this->getRequestParameter(v2Tov7Utils::V2TOV7_PARAM_NAME)) { - KalturaLog::log("Adding v2 to v7 facade"); - //Will be replaced with URL to remote player code - $v2ToV7Code = PHP_EOL . PHP_EOL . '!function(){"use strict";var e={593:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.ThumbnailEmbedComponent=t.thumbnailEmbed=void 0;const o=n(14);Object.defineProperty(t,"ThumbnailEmbedComponent",{enumerable:!0,get:function(){return o.ThumbnailEmbedComponent}});const i=n(512);Object.defineProperty(t,"thumbnailEmbed",{enumerable:!0,get:function(){return i.thumbnailEmbed}}),window.__thumbnailEmbed=i.thumbnailEmbed},14:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ThumbnailEmbedComponent=void 0;const n="#000";t.ThumbnailEmbedComponent=({onClick:e,src:t,bgColor:o=n})=>{const i=window.KalturaPlayer,{Button:r,Icon:d,IconType:a}=i.ui.components,{h:l}=i.ui.preact,{useRef:s,useState:u,useCallback:c}=i.ui.preactHooks,m=c((()=>{e(),h(!1)})),b=c((()=>{g(!0)})),p=c((()=>{g(!0),P(!0)})),y=s(),[f,h]=u(!0),[v,g]=u(!1),[I,P]=u(!1);return f?l("div",{style:{width:"100%",height:"100%",position:"relative",backgroundColor:I?o:n}},I?void 0:l("img",{src:t,ref:y,onLoad:b,onError:p,style:{width:"100%",height:"100%","object-fit":"contain"}}),v?l("div",{className:i.ui.style.prePlaybackPlayOverlay,style:{width:"100%",height:"100%"}},l(r,{className:i.ui.style.prePlaybackPlayButton,tabIndex:0,onClick:m},l(d,{type:a.Play}))):void 0):void 0}},512:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.thumbnailEmbed=void 0;const o=n(14);t.thumbnailEmbed=({config:e,mediaInfo:t,mediaOptions:n={},version:i=1e4,bgColor:r})=>{if(!e||!t)return;const d=(e=>{var t,n,o,i;if(null===(t=e.provider.env)||void 0===t?void 0:t.cdnUrl)return null===(n=e.provider.env)||void 0===n?void 0:n.cdnUrl;const r=window.__kalturaplayerdata;return r?null===(i=null===(o=r.provider)||void 0===o?void 0:o.env)||void 0===i?void 0:i.cdnUrl:"https://cdnapisec.kaltura.com"})(e),{targetId:a,provider:{partnerId:l,ks:s}}=e,u=window.KalturaPlayer;var c=document.getElementById(a);if(!c||!u||u.getPlayer&&u.getPlayer(a))return;let m=1920,b=1080;c.clientWidth&&c.clientHeight&&(m=c.clientWidth,b=c.clientHeight);const p=`${d.endsWith("/")?d:d+"/"}p/${l}/sp/${l}00/thumbnail/entry_id/${t.entryId}/version/${i}/width/${m}/height/${b}`+(s?`/ks/${s}`:""),{h:y,render:f}=u.ui.preact;f(y(o.ThumbnailEmbedComponent,{src:p,bgColor:r,onClick:()=>{try{const o=u.setup(e);o.loadMedia(t,n),o.play()}catch(e){}}}),c)}},371:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.thumbEmbed=t.embed=void 0;const o=n(593),i=n(890),r=window.KalturaPlayer;t.embed=e=>{console.log("## v2Config -----\x3e",e);const{targetId:t,partnerId:n,uiConfId:o,mediaInfo:d}=(0,i.getInfoFromV2Config)(e);let a={log:{level:"DEBUG"},targetId:t,provider:{partnerId:n}};const l=(0,i.buildConfigFromFlashvars)(e),s=Object.assign({},a,l);try{const e=r.setup(s),n=document.getElementById(t);n&&(n.addJsListener=(t,n)=>{"mediaLoaded"===t&&e.addEventListener("medialoaded",(()=>{n()}))});const o=d.id;d.isPlaylist?e.loadPlaylist({playlistId:o}):e.loadMedia({entryId:o})}catch(e){}},t.thumbEmbed=e=>{const{targetId:t,partnerId:n,uiConfId:r,mediaInfo:d}=(0,i.getInfoFromV2Config)(e);try{const e={config:{targetId:t,provider:{partnerId:n}},mediaInfo:{entryId:d.id}};(0,o.thumbnailEmbed)(e)}catch(e){}}},890:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.buildConfigFromFlashvars=t.getMediaInfo=t.getInfoFromV2Config=void 0,t.getInfoFromV2Config=e=>({targetId:e.targetId,partnerId:e.wid.match(/\d+/g).join(""),uiConfId:e.uiconf_id,mediaInfo:(0,t.getMediaInfo)(e)}),t.getMediaInfo=e=>{if(e.entry_id)return{id:e.entry_id,isPlaylist:!1};let t="";const n=e.flashvars;return n.hasOwnProperty("playlistAPI.kpl0Id")?t=n["playlistAPI.kpl0Id"]:n.hasOwnProperty("playlistAPI")&&n.playlistAPI.hasOwnProperty("kpl0Id")&&(t=n.playlistAPI.kpl0Id),{id:t,isPlaylist:!0}},t.buildConfigFromFlashvars=e=>{let t={text:{},playback:{},streaming:{},abr:{},drm:{},network:{},plugins:{}};if(e.hasOwnProperty("flashvars")){const n=e.flashvars;n.hasOwnProperty("autoPlay")&&(t.playback.autoplay=n.autoPlay)}return t}}},t={};function n(o){var i=t[o];if(void 0!==i)return i.exports;var r=t[o]={exports:{}};return e[o](r,r.exports,n),r.exports}!function(){const e=n(371);window.kWidget={embed:e.embed,thumbEmbed:e.thumbEmbed}}()}();'; + //Will be replaced with URL to remote player code + $v2ToV7Code = v2Tov7Utils::getBundledFacade(); + $v2ToV7Code = PHP_EOL . PHP_EOL . $v2ToV7Code; $bundleContent = $bundleContent . $v2ToV7Code; } From 9cd4d193b7030ddd71a1ac3eb3aa8b71b9fa205d Mon Sep 17 00:00:00 2001 From: MosheMaorKaltura Date: Mon, 12 Aug 2024 14:34:21 +0300 Subject: [PATCH 10/96] PLAT-24912: Code review remarks --- alpha/lib/model/uiConf.php | 1564 ++++++++++++++++++------------------ 1 file changed, 782 insertions(+), 782 deletions(-) diff --git a/alpha/lib/model/uiConf.php b/alpha/lib/model/uiConf.php index d5a9ae153eb..815673d3925 100644 --- a/alpha/lib/model/uiConf.php +++ b/alpha/lib/model/uiConf.php @@ -10,792 +10,792 @@ */ class uiConf extends BaseuiConf implements ISyncableFile, IRelatedObject { - const MYSQL_CODE_DUPLICATE_KEY = 23000; - - const UI_CONF_TYPE_GENERIC = 0; - const UI_CONF_TYPE_WIDGET = 1; - const UI_CONF_TYPE_CW = 2; - const UI_CONF_TYPE_EDITOR = 3; - const UI_CONF_TYPE_ADVANCED_EDITOR = 4; - const UI_CONF_TYPE_PLAYLIST = 5; // maybe this is in fact type WIDGET with some flags switched on ?!? - const UI_CONF_TYPE_KMC_APP_STUDIO = 6; - const UI_CONF_TYPE_KRECORD = 7; - const UI_CONF_TYPE_KDP3 = 8; - const UI_CONF_TYPE_KMC_ACCOUNT = 9; - const UI_CONF_TYPE_KMC_ANALYTICS = 10; - const UI_CONF_TYPE_KMC_CONTENT = 11; - const UI_CONF_TYPE_KMC_DASHBOARD = 12; - const UI_CONF_TYPE_KMC_LOGIN = 13; - const UI_CONF_TYPE_SLP = 14; - const UI_CONF_CLIENTSIDE_ENCODER = 15; - const UI_CONF_KMC_GENERAL = 16; - const UI_CONF_KMC_ROLES_AND_PERMISSIONS = 17; - const UI_CONF_CLIPPER = 18; - const UI_CONF_TYPE_KSR = 19; - const UI_CONF_TYPE_KUPLOAD = 20; - const UI_CONF_TYPE_WEBCASTING = 21; - const UI_CONF_TYPE_SAP = 22; - - - const UI_CONF_CREATION_MODE_MANUAL = 1; - const UI_CONF_CREATION_MODE_WIZARD = 2; - const UI_CONF_CREATION_MODE_ADVANCED = 3; - - // status - const UI_CONF_STATUS_PENDING = 1; - const UI_CONF_STATUS_READY = 2; - const UI_CONF_STATUS_DELETED = 3; - - const FILE_NAME_FEATURES = "features"; - const FILE_NAME_CONFIG = "config"; - - const FILE_SYNC_UICONF_SUB_TYPE_DATA = 1; - const FILE_SYNC_UICONF_SUB_TYPE_FEATURES = 2; - const FILE_SYNC_UICONF_SUB_TYPE_CONFIG = 3; - - private static $UI_CONF_OBJ_TYPE_MAP = null; - private static $REQUIRE_UI_CONF_FILE_FOR_TYPE = null; - - private static $validSubTypes = array(self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG, self::FILE_SYNC_UICONF_SUB_TYPE_DATA, self::FILE_SYNC_UICONF_SUB_TYPE_FEATURES); - private $content = array(); - - private $swf_url_version = null; - - //UI_CONF_TYPE_KSR:: This is a general path value the actual jar file should be symlinked under each KSR version dir - private static $swf_names = array(self::UI_CONF_TYPE_WIDGET => "kdp.swf", - self::UI_CONF_TYPE_CW => "ContributionWizard.swf", - self::UI_CONF_TYPE_EDITOR => "simpleeditor.swf", - self::UI_CONF_TYPE_ADVANCED_EDITOR => "KalturaAdvancedVideoEditor.swf", - self::UI_CONF_TYPE_PLAYLIST => "kdp.swf", - self::UI_CONF_TYPE_KMC_APP_STUDIO => "applicationstudio.swf", - self::UI_CONF_TYPE_KDP3 => "kdp3.swf", - self::UI_CONF_TYPE_KMC_ACCOUNT => "account.swf", - self::UI_CONF_TYPE_KMC_ANALYTICS => "ReportsAndAnalytics.swf", - self::UI_CONF_TYPE_KMC_CONTENT => "content.swf", - self::UI_CONF_TYPE_KMC_DASHBOARD => "dashboard.swf", - self::UI_CONF_TYPE_KMC_LOGIN => "login.swf", - self::UI_CONF_TYPE_SLP => "KalturaPlayer.xap", - self::UI_CONF_CLIENTSIDE_ENCODER => "KEU_0.8_win.msi", - self::UI_CONF_KMC_GENERAL => "kmc.swf", - self::UI_CONF_KMC_ROLES_AND_PERMISSIONS => "", - self::UI_CONF_CLIPPER => "", - self::UI_CONF_TYPE_KSR => "ScreencastOMaticRun.jar", - self::UI_CONF_TYPE_KRECORD => "KRecord.swf", - self::UI_CONF_TYPE_KUPLOAD => "KUpload.swf", - self::UI_CONF_TYPE_WEBCASTING => "", - self::UI_CONF_TYPE_SAP => "", - ); - - private static $swf_directory_map = array( - self::UI_CONF_TYPE_WIDGET => "kdp", - self::UI_CONF_TYPE_CW => "kcw", - self::UI_CONF_TYPE_EDITOR => "kse", - self::UI_CONF_TYPE_ADVANCED_EDITOR => "kae", - self::UI_CONF_TYPE_PLAYLIST => "kdp", - self::UI_CONF_TYPE_KMC_APP_STUDIO => "kmc/appstudio", - self::UI_CONF_TYPE_KDP3 => "kdp3", - self::UI_CONF_TYPE_KMC_ACCOUNT => "kmc/account", - self::UI_CONF_TYPE_KMC_ANALYTICS => "kmc/analytics", - self::UI_CONF_TYPE_KMC_CONTENT => "kmc/content", - self::UI_CONF_TYPE_KMC_DASHBOARD => "kmc/dashboard", - self::UI_CONF_TYPE_KMC_LOGIN => "kmc/login", - self::UI_CONF_TYPE_SLP => "slp", - self::UI_CONF_CLIENTSIDE_ENCODER => "expressUploader", - self::UI_CONF_KMC_GENERAL => "kmc", - self::UI_CONF_KMC_ROLES_AND_PERMISSIONS => "", - self::UI_CONF_CLIPPER => "kclip", - self::UI_CONF_TYPE_KSR => "ksr", - self::UI_CONF_TYPE_KRECORD => 'krecord', - self::UI_CONF_TYPE_KUPLOAD => "kupload", - self::UI_CONF_TYPE_WEBCASTING => "", - self::UI_CONF_TYPE_SAP => "", - ); - - const CUSTOM_DATA_CON_FILE_VERSION = 'conf_file_version'; - const CUSTOM_DATA_CONF_FILE_FEATURES_VERSION = 'conf_file_features_version'; - - //v2 to b7 - const CUSTOM_DATA_V2V7_ID = "v2v7_id"; - const CUSTOM_DATA_V2V7_APPROVED = "v2v7_approved"; - const CUSTOM_DATA_V2V7_TRANSLATE_PLUGINS = "v2v7_translate_plugins"; - - public function save(PropelPDO $con = null) - { - try { - $res = parent::save($con); - } catch (PropelException $e) { - /** - * Because many ui-conf objects have hard-coded id, the auto-incremented id of new ui-conf could exist in the db. - * Just retry to save the ui-conf with a different auto-inceremented id. - */ - - if ($e->getCause() && $e->getCause()->getCode() == self::MYSQL_CODE_DUPLICATE_KEY) //unique constraint - { - $res = parent::save($con); - } else { - throw $e; // Rethrow the unfamiliar exception - } - } - - if ($this->shouldSetContent()) { - foreach ($this->content as $contentItem) { - $confFile = $this->getConfFileBySuffix($contentItem['suffix']); - if ($confFile) - $this->saveConfFileToDisk($confFile, $contentItem['suffix']); - $contentItem['shouldSet'] = false; - - } - $res = parent::save($con); - } - $this->getConfFilePath(); - - return $res; - } - - private function isUiConfContentSet($subType) - { - if (!array_key_exists($subType, $this->content)) - return false; - $contentItem = $this->content[$subType]; - if (!$contentItem || !$contentItem['data']) - return false; - - return true; - } - - /* (non-PHPdoc) - * @see lib/model/om/BaseuiConf#postUpdate() - */ - public function postUpdate(PropelPDO $con = null) - { - if ($this->alreadyInSave) - return parent::postUpdate($con); - - $objectDeleted = false; - if ($this->isColumnModified(uiConfPeer::STATUS) && $this->getStatus() == self::UI_CONF_STATUS_DELETED) - $objectDeleted = true; - - $ret = parent::postUpdate($con); - - if ($objectDeleted) - kEventsManager::raiseEvent(new kObjectDeletedEvent($this)); - - return $ret; - } - - private static function initUiConfTypeMap() - { - if (self::$UI_CONF_OBJ_TYPE_MAP == null) { - self::$UI_CONF_OBJ_TYPE_MAP = array( - self::UI_CONF_TYPE_GENERIC => "Generic", - self::UI_CONF_TYPE_WIDGET => "Widget", - self::UI_CONF_TYPE_CW => "Contribution Wizard", - self::UI_CONF_TYPE_EDITOR => "Simple Editor", - self::UI_CONF_TYPE_ADVANCED_EDITOR => "Advanced Editor", - self::UI_CONF_TYPE_PLAYLIST => "Playlist", - self::UI_CONF_TYPE_KDP3 => "KDP3", - self::UI_CONF_TYPE_KMC_APP_STUDIO => "KMC AppStudio", - self::UI_CONF_TYPE_KMC_ACCOUNT => "KMC Account", - self::UI_CONF_TYPE_KMC_ANALYTICS => "KMC Analytics", - self::UI_CONF_TYPE_KMC_CONTENT => "KMC Content", - self::UI_CONF_TYPE_KMC_DASHBOARD => "KMC Dashboard", - self::UI_CONF_TYPE_KMC_LOGIN => "KMC Login", - self::UI_CONF_TYPE_SLP => "SLP", - self::UI_CONF_CLIENTSIDE_ENCODER => "Express Uploader", - self::UI_CONF_KMC_GENERAL => "KMC", - self::UI_CONF_KMC_ROLES_AND_PERMISSIONS => "KMC Roles and Permissions", - self::UI_CONF_CLIPPER => "Kaltura Clipper", - self::UI_CONF_TYPE_KSR => "Kaltura Screen Recorder", - self::UI_CONF_TYPE_KUPLOAD => "Kaltura Simple Uploader", - self::UI_CONF_TYPE_WEBCASTING => "Kaltura Webcasting Studio", - self::UI_CONF_TYPE_SAP => "Slim Audio Player", - ); - } - } - - public function isValid() - { - return true; - } - - public function getUiConfTypeMap() - { - self::initUiConfTypeMap(); - return self::$UI_CONF_OBJ_TYPE_MAP; - } - - public function getObjTypeAsString() - { - self::initUiConfTypeMap(); - return self::$UI_CONF_OBJ_TYPE_MAP[$this->getType()]; - } - - public function getType() - { - $t = parent::getObjType(); - if (empty ($t)) $t = self::UI_CONF_TYPE_WIDGET; - return $t; - } - - /** - * (non-PHPdoc) - * @see lib/model/ISyncableFile#getSyncKey() - */ - public function getSyncKey($sub_type, $version = null) - { - self::validateFileSyncSubType($sub_type); - $key = new FileSyncKey(); - $key->object_type = FileSyncObjectType::UICONF; - $key->object_sub_type = $sub_type; - $key->object_id = $this->getId(); + const MYSQL_CODE_DUPLICATE_KEY = 23000; + + const UI_CONF_TYPE_GENERIC = 0; + const UI_CONF_TYPE_WIDGET = 1; + const UI_CONF_TYPE_CW = 2; + const UI_CONF_TYPE_EDITOR = 3; + const UI_CONF_TYPE_ADVANCED_EDITOR = 4; + const UI_CONF_TYPE_PLAYLIST = 5; // maybe this is in fact type WIDGET with some flags switched on ?!? + const UI_CONF_TYPE_KMC_APP_STUDIO = 6; + const UI_CONF_TYPE_KRECORD = 7; + const UI_CONF_TYPE_KDP3 = 8; + const UI_CONF_TYPE_KMC_ACCOUNT = 9; + const UI_CONF_TYPE_KMC_ANALYTICS = 10; + const UI_CONF_TYPE_KMC_CONTENT = 11; + const UI_CONF_TYPE_KMC_DASHBOARD = 12; + const UI_CONF_TYPE_KMC_LOGIN = 13; + const UI_CONF_TYPE_SLP = 14; + const UI_CONF_CLIENTSIDE_ENCODER = 15; + const UI_CONF_KMC_GENERAL = 16; + const UI_CONF_KMC_ROLES_AND_PERMISSIONS = 17; + const UI_CONF_CLIPPER = 18; + const UI_CONF_TYPE_KSR = 19; + const UI_CONF_TYPE_KUPLOAD = 20; + const UI_CONF_TYPE_WEBCASTING = 21; + const UI_CONF_TYPE_SAP = 22; + + + const UI_CONF_CREATION_MODE_MANUAL = 1; + const UI_CONF_CREATION_MODE_WIZARD = 2; + const UI_CONF_CREATION_MODE_ADVANCED = 3; + + // status + const UI_CONF_STATUS_PENDING = 1; + const UI_CONF_STATUS_READY = 2; + const UI_CONF_STATUS_DELETED = 3; + + const FILE_NAME_FEATURES = "features"; + const FILE_NAME_CONFIG = "config"; + + const FILE_SYNC_UICONF_SUB_TYPE_DATA = 1; + const FILE_SYNC_UICONF_SUB_TYPE_FEATURES = 2; + const FILE_SYNC_UICONF_SUB_TYPE_CONFIG = 3; + + private static $UI_CONF_OBJ_TYPE_MAP = null; + private static $REQUIRE_UI_CONF_FILE_FOR_TYPE = null; + + private static $validSubTypes = array(self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG, self::FILE_SYNC_UICONF_SUB_TYPE_DATA, self::FILE_SYNC_UICONF_SUB_TYPE_FEATURES); + private $content = array(); + + private $swf_url_version = null; + + //UI_CONF_TYPE_KSR:: This is a general path value the actual jar file should be symlinked under each KSR version dir + private static $swf_names = array(self::UI_CONF_TYPE_WIDGET => "kdp.swf", + self::UI_CONF_TYPE_CW => "ContributionWizard.swf", + self::UI_CONF_TYPE_EDITOR => "simpleeditor.swf", + self::UI_CONF_TYPE_ADVANCED_EDITOR => "KalturaAdvancedVideoEditor.swf", + self::UI_CONF_TYPE_PLAYLIST => "kdp.swf", + self::UI_CONF_TYPE_KMC_APP_STUDIO => "applicationstudio.swf", + self::UI_CONF_TYPE_KDP3 => "kdp3.swf", + self::UI_CONF_TYPE_KMC_ACCOUNT => "account.swf", + self::UI_CONF_TYPE_KMC_ANALYTICS => "ReportsAndAnalytics.swf", + self::UI_CONF_TYPE_KMC_CONTENT => "content.swf", + self::UI_CONF_TYPE_KMC_DASHBOARD => "dashboard.swf", + self::UI_CONF_TYPE_KMC_LOGIN => "login.swf", + self::UI_CONF_TYPE_SLP => "KalturaPlayer.xap", + self::UI_CONF_CLIENTSIDE_ENCODER => "KEU_0.8_win.msi", + self::UI_CONF_KMC_GENERAL => "kmc.swf", + self::UI_CONF_KMC_ROLES_AND_PERMISSIONS => "", + self::UI_CONF_CLIPPER => "", + self::UI_CONF_TYPE_KSR => "ScreencastOMaticRun.jar", + self::UI_CONF_TYPE_KRECORD => "KRecord.swf", + self::UI_CONF_TYPE_KUPLOAD => "KUpload.swf", + self::UI_CONF_TYPE_WEBCASTING => "", + self::UI_CONF_TYPE_SAP => "", + ); + + private static $swf_directory_map = array( + self::UI_CONF_TYPE_WIDGET => "kdp", + self::UI_CONF_TYPE_CW => "kcw", + self::UI_CONF_TYPE_EDITOR => "kse", + self::UI_CONF_TYPE_ADVANCED_EDITOR => "kae", + self::UI_CONF_TYPE_PLAYLIST => "kdp", + self::UI_CONF_TYPE_KMC_APP_STUDIO => "kmc/appstudio", + self::UI_CONF_TYPE_KDP3 => "kdp3", + self::UI_CONF_TYPE_KMC_ACCOUNT => "kmc/account", + self::UI_CONF_TYPE_KMC_ANALYTICS => "kmc/analytics", + self::UI_CONF_TYPE_KMC_CONTENT => "kmc/content", + self::UI_CONF_TYPE_KMC_DASHBOARD => "kmc/dashboard", + self::UI_CONF_TYPE_KMC_LOGIN => "kmc/login", + self::UI_CONF_TYPE_SLP => "slp", + self::UI_CONF_CLIENTSIDE_ENCODER => "expressUploader", + self::UI_CONF_KMC_GENERAL => "kmc", + self::UI_CONF_KMC_ROLES_AND_PERMISSIONS => "", + self::UI_CONF_CLIPPER => "kclip", + self::UI_CONF_TYPE_KSR => "ksr", + self::UI_CONF_TYPE_KRECORD => 'krecord', + self::UI_CONF_TYPE_KUPLOAD => "kupload", + self::UI_CONF_TYPE_WEBCASTING => "", + self::UI_CONF_TYPE_SAP => "", + ); + + const CUSTOM_DATA_CON_FILE_VERSION = 'conf_file_version'; + const CUSTOM_DATA_CONF_FILE_FEATURES_VERSION = 'conf_file_features_version'; + + //v2 to b7 + const CUSTOM_DATA_V2V7_ID = "v2v7_id"; + const CUSTOM_DATA_V2V7_APPROVED = "v2v7_approved"; + const CUSTOM_DATA_V2V7_TRANSLATE_PLUGINS = "v2v7_translate_plugins"; + + public function save(PropelPDO $con = null) + { + try { + $res = parent::save($con); + } catch (PropelException $e) { + /** + * Because many ui-conf objects have hard-coded id, the auto-incremented id of new ui-conf could exist in the db. + * Just retry to save the ui-conf with a different auto-inceremented id. + */ + + if ($e->getCause() && $e->getCause()->getCode() == self::MYSQL_CODE_DUPLICATE_KEY) //unique constraint + { + $res = parent::save($con); + } else { + throw $e; // Rethrow the unfamiliar exception + } + } + + if ($this->shouldSetContent()) { + foreach ($this->content as $contentItem) { + $confFile = $this->getConfFileBySuffix($contentItem['suffix']); + if ($confFile) + $this->saveConfFileToDisk($confFile, $contentItem['suffix']); + $contentItem['shouldSet'] = false; + + } + $res = parent::save($con); + } + $this->getConfFilePath(); + + return $res; + } + + private function isUiConfContentSet($subType) + { + if (!array_key_exists($subType, $this->content)) + return false; + $contentItem = $this->content[$subType]; + if (!$contentItem || !$contentItem['data']) + return false; + + return true; + } + + /* (non-PHPdoc) + * @see lib/model/om/BaseuiConf#postUpdate() + */ + public function postUpdate(PropelPDO $con = null) + { + if ($this->alreadyInSave) + return parent::postUpdate($con); + + $objectDeleted = false; + if ($this->isColumnModified(uiConfPeer::STATUS) && $this->getStatus() == self::UI_CONF_STATUS_DELETED) + $objectDeleted = true; + + $ret = parent::postUpdate($con); + + if ($objectDeleted) + kEventsManager::raiseEvent(new kObjectDeletedEvent($this)); + + return $ret; + } + + private static function initUiConfTypeMap() + { + if (self::$UI_CONF_OBJ_TYPE_MAP == null) { + self::$UI_CONF_OBJ_TYPE_MAP = array( + self::UI_CONF_TYPE_GENERIC => "Generic", + self::UI_CONF_TYPE_WIDGET => "Widget", + self::UI_CONF_TYPE_CW => "Contribution Wizard", + self::UI_CONF_TYPE_EDITOR => "Simple Editor", + self::UI_CONF_TYPE_ADVANCED_EDITOR => "Advanced Editor", + self::UI_CONF_TYPE_PLAYLIST => "Playlist", + self::UI_CONF_TYPE_KDP3 => "KDP3", + self::UI_CONF_TYPE_KMC_APP_STUDIO => "KMC AppStudio", + self::UI_CONF_TYPE_KMC_ACCOUNT => "KMC Account", + self::UI_CONF_TYPE_KMC_ANALYTICS => "KMC Analytics", + self::UI_CONF_TYPE_KMC_CONTENT => "KMC Content", + self::UI_CONF_TYPE_KMC_DASHBOARD => "KMC Dashboard", + self::UI_CONF_TYPE_KMC_LOGIN => "KMC Login", + self::UI_CONF_TYPE_SLP => "SLP", + self::UI_CONF_CLIENTSIDE_ENCODER => "Express Uploader", + self::UI_CONF_KMC_GENERAL => "KMC", + self::UI_CONF_KMC_ROLES_AND_PERMISSIONS => "KMC Roles and Permissions", + self::UI_CONF_CLIPPER => "Kaltura Clipper", + self::UI_CONF_TYPE_KSR => "Kaltura Screen Recorder", + self::UI_CONF_TYPE_KUPLOAD => "Kaltura Simple Uploader", + self::UI_CONF_TYPE_WEBCASTING => "Kaltura Webcasting Studio", + self::UI_CONF_TYPE_SAP => "Slim Audio Player", + ); + } + } + + public function isValid() + { + return true; + } + + public function getUiConfTypeMap() + { + self::initUiConfTypeMap(); + return self::$UI_CONF_OBJ_TYPE_MAP; + } + + public function getObjTypeAsString() + { + self::initUiConfTypeMap(); + return self::$UI_CONF_OBJ_TYPE_MAP[$this->getType()]; + } + + public function getType() + { + $t = parent::getObjType(); + if (empty ($t)) $t = self::UI_CONF_TYPE_WIDGET; + return $t; + } + + /** + * (non-PHPdoc) + * @see lib/model/ISyncableFile#getSyncKey() + */ + public function getSyncKey($sub_type, $version = null) + { + self::validateFileSyncSubType($sub_type); + $key = new FileSyncKey(); + $key->object_type = FileSyncObjectType::UICONF; + $key->object_sub_type = $sub_type; + $key->object_id = $this->getId(); // if ( $sub_type == self::FILE_SYNC_UICONF_SUB_TYPE_DATA ) - // TODO - add version to the DB - $key->version = $this->getVersion($sub_type); - - $key->partner_id = $this->getPartnerId(); - return $key; - } - - - /* (non-PHPdoc) - * @see lib/model/ISyncableFile#generateFileName() - */ - public function generateFileName($sub_type, $version = null) - { - self::validateFileSyncSubType($sub_type); - - $suffix = $this->getSuffixBySubType($sub_type); - if ($suffix == null) - return "ui_conf{$version}.xml"; - else - return "ui_conf." . $suffix . $version . ".xml"; - - return null; - } - - /** - * (non-PHPdoc) - * @see lib/model/ISyncableFile#generateFilePathArr() - */ - public function generateFilePathArr($sub_type, $version = null, $externalPath = false) - { - // TODO - implement field version - self::validateFileSyncSubType($sub_type); - $suffix = $this->getSuffixBySubType($sub_type); - $incVersion = false; - if ($sub_type == self::FILE_SYNC_UICONF_SUB_TYPE_DATA) { - $incVersion = true; - } - - $res = $this->getConfFilePathImpl($suffix, $incVersion, $version); - - if ($externalPath) { - $file_root = myCloudUtils::getPartnerSharedStorageBaseDir($this->getPartnerId()); - $dir = myContentStorage::getScatteredPathFromIntId($this->getId() * 10); - $file_path = "/generatedUiConf/$dir/ui_conf_{$this->getId()}_$version.xml"; - if ($suffix) { - $file_path = str_replace("xml", "$suffix.xml", $file_path); - } - } else { - $file_root = myContentStorage::getFSContentRootPath(); - $file_path = str_replace(myContentStorage::getFSContentRootPath(), "", $res); - } - - return array($file_root, $file_path); - } - - - /** - * Enter description here... - * - * @var FileSync - */ - private $m_file_sync; - - /** - * @return FileSync - */ - public function getFileSync() - { - return $this->m_file_sync; - } - - public function setFileSync(FileSync $file_sync) - { - $this->m_file_sync = $file_sync; - } - - private static function validateFileSyncSubType($sub_type) - { - if (!in_array($sub_type, self::$validSubTypes)) - throw new FileSyncException (FileSyncObjectType::UICONF, $sub_type, $validSubTypes); - } - - private function saveConfFileToDisk($v, $file_suffix = null, $isClone = false) - { - if ($this->getCreationMode() == self::UI_CONF_CREATION_MODE_MANUAL) { - throw new Exception ("Should not edit MANUAL ui_confs via the API!! Only via the SVN"); - } - - $subType = $this->getSubTypeBySuffix($file_suffix); - $this->incrementVersion($subType); - $sync_key = $this->getSyncKey($subType); - - $this->setUpdatedAt(time()); // make sure will be updated in the DB - if (version_compare($this->getSwfUrlVersion(), "2.5", ">=")) { - $v = str_replace('.entryName}', '.name}', $v); - } - - // This is only called on Save, after parent::save(), so ID is present. - kFileSyncUtils::file_put_contents($sync_key, $v); //replaced__setFileContent - } - - private function setConfFileBySuffix($suffix = null, $v) - { - $subType = $this->getSubTypeBySuffix($suffix); - $contentItem = array(); - $contentItem['suffix'] = $suffix; - $contentItem['shouldSet'] = true; - $contentItem['subType'] = $subType; - - if ($v !== null) { - $contentItem['data'] = $v; - $this->content[$subType] = $contentItem; - } - } - - private function getConfFileBySuffix($suffix = null, $force_fetch = false) - { - $subType = $this->getSubTypeBySuffix($suffix); - $contents = ""; - if ($this->isUiConfContentSet($subType) && !$force_fetch) - return $this->content[$subType]['data']; - - $sync_key = $this->getSyncKey($subType); - - $contents = kFileSyncUtils::file_get_contents($sync_key, true, false); - - if (!$contents) - KalturaLog::debug("Conf file of sub type [$subType] not found for key [$sync_key]"); - return $contents; - } - - public function setConfFile($v /*, $increment_version = true */) - { - $this->setConfFileBySuffix(null, $v); - } - - public function getConfFile($force_fetch = false) - { - return $this->getConfFileBySuffix(null, $force_fetch); - } - - public function setConfFileFeatures($v) - { - $this->setConfFileBySuffix(self::FILE_NAME_FEATURES, $v); - } - - // check this ! - public function getConfFileFeatures($force_fetch = false) - { - return $this->getConfFileBySuffix(self::FILE_NAME_FEATURES, $force_fetch); - } - - public function setConfig($v /*, $increment_version = true */) - { - $this->setConfFileBySuffix(self::FILE_NAME_CONFIG, $v); - } - - // will fetch - public function getConfig($force_fetch = false) - { - return $this->getConfFileBySuffix(self::FILE_NAME_CONFIG, $force_fetch); - } - - private $m_file_time; - - private function getFileTime() - { - if (!$this->m_file_time) - $this->m_file_time = strftime("%Y-%m-%d_%H-%M-%S", time()); - return $this->m_file_time; - } - - public function getSwfUrl($raw_only = false) - { - $raw = parent::getSwfUrl(); - if ($raw_only) return $raw; - $root_url = kConf::get("flash_root_url"); - if (!$root_url) - return $raw; - if (strpos($raw, $root_url) === 0) { - // if the raw url already has the exact prefix of root_url - return the raw - no need to re-append it - return $raw; - } - - if (strpos($raw, "http://") === 0) { - // if the raw url starts with http - don't append to it - return $raw; - } - - return $root_url . $raw; - } - - // use this field only if the version is not empty - public function setSwfUrlVersion($version) - { - $flashUrl = myContentStorage::getFSFlashRootPath(); - $swfName = $this->getSwfNameFromType(); - $dir = $this->getDirectoryFromType(); - - if ($version) { - if (strpos($this->swf_url, "kdp3") !== false) - $this->setSwfUrl("$flashUrl/kdp3/v{$version}/kdp3.swf"); - else - $this->setSwfUrl("$flashUrl/$dir/v{$version}/$swfName"); - } - } - - public function getSwfUrlVersion() - { - $swf_url = $this->getSwfUrl(); - $flash_url = myContentStorage::getFSFlashRootPath(); - $match = preg_match('/\/v([\w\d\.]+)/', $swf_url, $version); - if ($match) { - return $version[1]; - } - return null; - } - - private function getCachedContent($kaltura_config, $confFilePath) - { - if (!file_exists($confFilePath)) return null; - if (strpos($confFilePath, "://") != FALSE) { - // remote file (http:// or ftp://) - store the cache in a directory near the base file - //$cache_path = dirname( $kaltura_config ) . "cache/" . $confFilePath . "_cache.xml" ; - // for now - don't cache for remote files - $cache_path = null; - } else { - // this is a local file - store the cache file in the same directory - $cache_path = str_replace("/uiconf/", "/cacheuiconf/", $confFilePath) . "_cache.xml"; - kFile::fullMkdir($cache_path); - } - try { - $s_time = microtime(true); - $config = new kXmlConfig($kaltura_config, $confFilePath); - $content = $config->getConfig($cache_path); - $e_time = microtime(true); - - if ($config->createdCache()) - KalturaLog::log(__METHOD__ . " created config cache file [$kaltura_config]+[$confFilePath]->[$cache_path].\ntook [" . ($e_time - $s_time) . "] seconds"); - - return $content; - } catch (Exception $ex) { - KalturaLog::log(__METHOD__ . " Error creating config [$kaltura_config]+[$confFilePath]:" . $ex->getMessage()); - return null; - } - } - - // TODO fix when add creation_mode to the DB - public function getCreationModeAsStr() - { - return self::UI_CONF_CREATION_MODE_WIZARD; - } - - // TODO - remove this function after Andromeda deployment is stable - public function internalGetParentConfFilePath() - { - return parent::getConfFilePath(); - } - - public function getConfFilePath($file_suffix = null, $inc_version = false) - { - return $this->getConfFilePathImpl($file_suffix, $inc_version); - } - - private function getConfFilePathImpl($file_suffix = null, $inc_version = false, $version = null) - { - $conf_file_path = parent::getConfFilePath(); - - if ($this->getCreationMode() != self::UI_CONF_CREATION_MODE_MANUAL) { - if (!$conf_file_path || $inc_version || $version) { - if (!$this->getId()) - return null; - - $conf_file_path = $this->createConfFilePath($version); - $this->setConfFilePath($conf_file_path); - } - } - - // will fix the current problem in the DB- we hold the root in the conf_file_path - $conf_file_path = myContentStorage::getFSContentRootPath() . str_replace("/web/", "", $conf_file_path); - - if ($file_suffix) { - // use the file_suffix before the extension - $extension = pathinfo($conf_file_path, PATHINFO_EXTENSION); - $conf_file_path = str_replace($extension, "$file_suffix.$extension", $conf_file_path); - } - - return $conf_file_path; - } - - /* - * Should not be used as updateable field until the paths on disk are safe to set - */ - public function setConfFilePath($v) - { - if (kString::beginsWith($v, "..")) { - $err = "Error in " . __METHOD__ . ": attmpting to set ConfFilePath to [$v]"; - KalturaLog::log($err); - throw new APIException (APIErrors::ERROR_SETTING_FILE_PATH_FOR_UI_CONF, $v); - } - - if ($this->getCreationMode() == self::UI_CONF_CREATION_MODE_MANUAL) { - if (!kString::beginsWith($v, $this->getUiConfRootDirectory() . "uiconf/")) { - $v = $this->getUiConfRootDirectory() . "uiconf/" . $v; - } - - $real_v = realpath(dirname($v)) . "/" . pathinfo($v, PATHINFO_BASENAME); - - if ($v) { - if ($real_v) { - /* - * TODO - add this id the service IS externally use via the API - // the file exists - make sure we're not overiding someone elses file - $ui_confs_with_same_path = uiConfPeer::retrieveByConfFilePath ( $real_v , $this->getId() ); - foreach ( $ui_confs_with_same_path as $ui_conf ) - { - if ( $ui_conf->getPartnerId ( ) != $this->getPartnerId() ) - { - $err = "Error in " . __METHOD__ . ": attmpting to set ConfFilePath to [$v]"; - KalturaLog::log( $err ); - throw new APIException ( APIErrors::ERROR_SETTING_FILE_PATH_FOR_UI_CONF , $v ); - } - } - */ - $v = $real_v; - } - } - parent::setConfFilePath($v); - } else { - parent::setConfFilePath($v); + // TODO - add version to the DB + $key->version = $this->getVersion($sub_type); + + $key->partner_id = $this->getPartnerId(); + return $key; + } + + + /* (non-PHPdoc) + * @see lib/model/ISyncableFile#generateFileName() + */ + public function generateFileName($sub_type, $version = null) + { + self::validateFileSyncSubType($sub_type); + + $suffix = $this->getSuffixBySubType($sub_type); + if ($suffix == null) + return "ui_conf{$version}.xml"; + else + return "ui_conf." . $suffix . $version . ".xml"; + + return null; + } + + /** + * (non-PHPdoc) + * @see lib/model/ISyncableFile#generateFilePathArr() + */ + public function generateFilePathArr($sub_type, $version = null, $externalPath = false) + { + // TODO - implement field version + self::validateFileSyncSubType($sub_type); + $suffix = $this->getSuffixBySubType($sub_type); + $incVersion = false; + if ($sub_type == self::FILE_SYNC_UICONF_SUB_TYPE_DATA) { + $incVersion = true; + } + + $res = $this->getConfFilePathImpl($suffix, $incVersion, $version); + + if ($externalPath) { + $file_root = myCloudUtils::getPartnerSharedStorageBaseDir($this->getPartnerId()); + $dir = myContentStorage::getScatteredPathFromIntId($this->getId() * 10); + $file_path = "/generatedUiConf/$dir/ui_conf_{$this->getId()}_$version.xml"; + if ($suffix) { + $file_path = str_replace("xml", "$suffix.xml", $file_path); + } + } else { + $file_root = myContentStorage::getFSContentRootPath(); + $file_path = str_replace(myContentStorage::getFSContentRootPath(), "", $res); + } + + return array($file_root, $file_path); + } + + + /** + * Enter description here... + * + * @var FileSync + */ + private $m_file_sync; + + /** + * @return FileSync + */ + public function getFileSync() + { + return $this->m_file_sync; + } + + public function setFileSync(FileSync $file_sync) + { + $this->m_file_sync = $file_sync; + } + + private static function validateFileSyncSubType($sub_type) + { + if (!in_array($sub_type, self::$validSubTypes)) + throw new FileSyncException (FileSyncObjectType::UICONF, $sub_type, $validSubTypes); + } + + private function saveConfFileToDisk($v, $file_suffix = null, $isClone = false) + { + if ($this->getCreationMode() == self::UI_CONF_CREATION_MODE_MANUAL) { + throw new Exception ("Should not edit MANUAL ui_confs via the API!! Only via the SVN"); + } + + $subType = $this->getSubTypeBySuffix($file_suffix); + $this->incrementVersion($subType); + $sync_key = $this->getSyncKey($subType); + + $this->setUpdatedAt(time()); // make sure will be updated in the DB + if (version_compare($this->getSwfUrlVersion(), "2.5", ">=")) { + $v = str_replace('.entryName}', '.name}', $v); + } + + // This is only called on Save, after parent::save(), so ID is present. + kFileSyncUtils::file_put_contents($sync_key, $v); //replaced__setFileContent + } + + private function setConfFileBySuffix($suffix = null, $v) + { + $subType = $this->getSubTypeBySuffix($suffix); + $contentItem = array(); + $contentItem['suffix'] = $suffix; + $contentItem['shouldSet'] = true; + $contentItem['subType'] = $subType; + + if ($v !== null) { + $contentItem['data'] = $v; + $this->content[$subType] = $contentItem; + } + } + + private function getConfFileBySuffix($suffix = null, $force_fetch = false) + { + $subType = $this->getSubTypeBySuffix($suffix); + $contents = ""; + if ($this->isUiConfContentSet($subType) && !$force_fetch) + return $this->content[$subType]['data']; + + $sync_key = $this->getSyncKey($subType); + + $contents = kFileSyncUtils::file_get_contents($sync_key, true, false); + + if (!$contents) + KalturaLog::debug("Conf file of sub type [$subType] not found for key [$sync_key]"); + return $contents; + } + + public function setConfFile($v /*, $increment_version = true */) + { + $this->setConfFileBySuffix(null, $v); + } + + public function getConfFile($force_fetch = false) + { + return $this->getConfFileBySuffix(null, $force_fetch); + } + + public function setConfFileFeatures($v) + { + $this->setConfFileBySuffix(self::FILE_NAME_FEATURES, $v); + } + + // check this ! + public function getConfFileFeatures($force_fetch = false) + { + return $this->getConfFileBySuffix(self::FILE_NAME_FEATURES, $force_fetch); + } + + public function setConfig($v /*, $increment_version = true */) + { + $this->setConfFileBySuffix(self::FILE_NAME_CONFIG, $v); + } + + // will fetch + public function getConfig($force_fetch = false) + { + return $this->getConfFileBySuffix(self::FILE_NAME_CONFIG, $force_fetch); + } + + private $m_file_time; + + private function getFileTime() + { + if (!$this->m_file_time) + $this->m_file_time = strftime("%Y-%m-%d_%H-%M-%S", time()); + return $this->m_file_time; + } + + public function getSwfUrl($raw_only = false) + { + $raw = parent::getSwfUrl(); + if ($raw_only) return $raw; + $root_url = kConf::get("flash_root_url"); + if (!$root_url) + return $raw; + if (strpos($raw, $root_url) === 0) { + // if the raw url already has the exact prefix of root_url - return the raw - no need to re-append it + return $raw; + } + + if (strpos($raw, "http://") === 0) { + // if the raw url starts with http - don't append to it + return $raw; + } + + return $root_url . $raw; + } + + // use this field only if the version is not empty + public function setSwfUrlVersion($version) + { + $flashUrl = myContentStorage::getFSFlashRootPath(); + $swfName = $this->getSwfNameFromType(); + $dir = $this->getDirectoryFromType(); + + if ($version) { + if (strpos($this->swf_url, "kdp3") !== false) + $this->setSwfUrl("$flashUrl/kdp3/v{$version}/kdp3.swf"); + else + $this->setSwfUrl("$flashUrl/$dir/v{$version}/$swfName"); + } + } + + public function getSwfUrlVersion() + { + $swf_url = $this->getSwfUrl(); + $flash_url = myContentStorage::getFSFlashRootPath(); + $match = preg_match('/\/v([\w\d\.]+)/', $swf_url, $version); + if ($match) { + return $version[1]; + } + return null; + } + + private function getCachedContent($kaltura_config, $confFilePath) + { + if (!file_exists($confFilePath)) return null; + if (strpos($confFilePath, "://") != FALSE) { + // remote file (http:// or ftp://) - store the cache in a directory near the base file + //$cache_path = dirname( $kaltura_config ) . "cache/" . $confFilePath . "_cache.xml" ; + // for now - don't cache for remote files + $cache_path = null; + } else { + // this is a local file - store the cache file in the same directory + $cache_path = str_replace("/uiconf/", "/cacheuiconf/", $confFilePath) . "_cache.xml"; + kFile::fullMkdir($cache_path); + } + try { + $s_time = microtime(true); + $config = new kXmlConfig($kaltura_config, $confFilePath); + $content = $config->getConfig($cache_path); + $e_time = microtime(true); + + if ($config->createdCache()) + KalturaLog::log(__METHOD__ . " created config cache file [$kaltura_config]+[$confFilePath]->[$cache_path].\ntook [" . ($e_time - $s_time) . "] seconds"); + + return $content; + } catch (Exception $ex) { + KalturaLog::log(__METHOD__ . " Error creating config [$kaltura_config]+[$confFilePath]:" . $ex->getMessage()); + return null; + } + } + + // TODO fix when add creation_mode to the DB + public function getCreationModeAsStr() + { + return self::UI_CONF_CREATION_MODE_WIZARD; + } + + // TODO - remove this function after Andromeda deployment is stable + public function internalGetParentConfFilePath() + { + return parent::getConfFilePath(); + } + + public function getConfFilePath($file_suffix = null, $inc_version = false) + { + return $this->getConfFilePathImpl($file_suffix, $inc_version); + } + + private function getConfFilePathImpl($file_suffix = null, $inc_version = false, $version = null) + { + $conf_file_path = parent::getConfFilePath(); + + if ($this->getCreationMode() != self::UI_CONF_CREATION_MODE_MANUAL) { + if (!$conf_file_path || $inc_version || $version) { + if (!$this->getId()) + return null; + + $conf_file_path = $this->createConfFilePath($version); + $this->setConfFilePath($conf_file_path); + } + } + + // will fix the current problem in the DB- we hold the root in the conf_file_path + $conf_file_path = myContentStorage::getFSContentRootPath() . str_replace("/web/", "", $conf_file_path); + + if ($file_suffix) { + // use the file_suffix before the extension + $extension = pathinfo($conf_file_path, PATHINFO_EXTENSION); + $conf_file_path = str_replace($extension, "$file_suffix.$extension", $conf_file_path); + } + + return $conf_file_path; + } + + /* + * Should not be used as updateable field until the paths on disk are safe to set + */ + public function setConfFilePath($v) + { + if (kString::beginsWith($v, "..")) { + $err = "Error in " . __METHOD__ . ": attmpting to set ConfFilePath to [$v]"; + KalturaLog::log($err); + throw new APIException (APIErrors::ERROR_SETTING_FILE_PATH_FOR_UI_CONF, $v); + } + + if ($this->getCreationMode() == self::UI_CONF_CREATION_MODE_MANUAL) { + if (!kString::beginsWith($v, $this->getUiConfRootDirectory() . "uiconf/")) { + $v = $this->getUiConfRootDirectory() . "uiconf/" . $v; + } + + $real_v = realpath(dirname($v)) . "/" . pathinfo($v, PATHINFO_BASENAME); + + if ($v) { + if ($real_v) { + /* + * TODO - add this id the service IS externally use via the API + // the file exists - make sure we're not overiding someone elses file + $ui_confs_with_same_path = uiConfPeer::retrieveByConfFilePath ( $real_v , $this->getId() ); + foreach ( $ui_confs_with_same_path as $ui_conf ) + { + if ( $ui_conf->getPartnerId ( ) != $this->getPartnerId() ) + { + $err = "Error in " . __METHOD__ . ": attmpting to set ConfFilePath to [$v]"; + KalturaLog::log( $err ); + throw new APIException ( APIErrors::ERROR_SETTING_FILE_PATH_FOR_UI_CONF , $v ); + } + } + */ + $v = $real_v; + } + } + parent::setConfFilePath($v); + } else { + parent::setConfFilePath($v); // throw new APIException ( APIErrors::ERROR_SETTING_FILE_PATH_FOR_UI_CONF , $v ); - } - } - - private function createConfFilePath($version = null) - { - if ($this->getVersion() || $version) - $version = "_" . ($version ? $version : $this->getVersion()); - else - $version = ""; - - $dir = (intval($this->getId() / 1000000)) . '/' . (intval($this->getId() / 1000) % 1000); - $file_name = "/content/generatedUiConf/$dir/ui_conf_{$this->getId()}_{$version}.xml"; - return $file_name; - } - - // IMPORTANT : WILL NOT include the uiconf or generatedUiconf part of the path - private function getUiConfRootDirectory() - { - $content_path = myContentStorage::getFSContentRootPath(); - return $content_path . "content/"; - } - - /* - * will create a new uiConf object in the DB from this object while using fields from - */ - public function cloneToNew($new_ui_conf_obj, $new_name = null) - { - $cloned = new uiConf(); - $cloned->setCopiedFrom($this); - - $all_fields = uiConfPeer::getFieldNames(); - $ignore_list = array("Id", "ConfFilePath"); - // clone from current - baseObjectUtils::fillObjectFromObject($all_fields, - $this, - $cloned, - baseObjectUtils::CLONE_POLICY_PREFER_NEW, $ignore_list, BasePeer::TYPE_PHPNAME); + } + } + + private function createConfFilePath($version = null) + { + if ($this->getVersion() || $version) + $version = "_" . ($version ? $version : $this->getVersion()); + else + $version = ""; + + $dir = (intval($this->getId() / 1000000)) . '/' . (intval($this->getId() / 1000) % 1000); + $file_name = "/content/generatedUiConf/$dir/ui_conf_{$this->getId()}_{$version}.xml"; + return $file_name; + } + + // IMPORTANT : WILL NOT include the uiconf or generatedUiconf part of the path + private function getUiConfRootDirectory() + { + $content_path = myContentStorage::getFSContentRootPath(); + return $content_path . "content/"; + } + + /* + * will create a new uiConf object in the DB from this object while using fields from + */ + public function cloneToNew($new_ui_conf_obj, $new_name = null) + { + $cloned = new uiConf(); + $cloned->setCopiedFrom($this); + + $all_fields = uiConfPeer::getFieldNames(); + $ignore_list = array("Id", "ConfFilePath"); + // clone from current + baseObjectUtils::fillObjectFromObject($all_fields, + $this, + $cloned, + baseObjectUtils::CLONE_POLICY_PREFER_NEW, $ignore_list, BasePeer::TYPE_PHPNAME); // $cloned->setNew(true); - // override with data from the $new_ui_conf_obj - the name can be chosen to override - if ($new_ui_conf_obj) { - baseObjectUtils::fillObjectFromObject($all_fields, // assume the new_ui_conf_obj can be fully copied to the cloned - $new_ui_conf_obj, - $cloned, - baseObjectUtils::CLONE_POLICY_PREFER_NEW, null, BasePeer::TYPE_PHPNAME); - } - - if ($new_name) { - $cloned->setName($new_name); - } - - foreach (self::$validSubTypes as $subType) { - $suffix = $this->getSuffixBySubType($subType); - $content = $this->getConfFileBySuffix($suffix); - $cloned->setConfFileBySuffix($suffix, $content); - } - - $cloned->save(null); - return $cloned; - } - - public function getSwfNameFromType() - { - $name = @self::$swf_names [$this->getObjType()]; - if ($name) - return $name; - return ""; - } - - public function getDirectoryFromType() - { - if (isset(self::$swf_directory_map[$this->getObjType()])) - return self::$swf_directory_map[$this->getObjType()]; - - return ""; - } - - public function getDirectoryMap() - { - return self::$swf_directory_map; - } - - public function getSwfNames() - { - return self::$swf_names; - } - - - public function getAutoplay() - { - return $this->getFromCustomData("autoplay", null, false); - } - - public function setAutoplay($v) - { - return $this->putInCustomData("autoplay", $v); - } - - public function getAutomuted() - { - return $this->getFromCustomData("automuted", null, false); - } - - public function setAutomuted($v) - { - return $this->putInCustomData("automuted", $v); - } - - public function getConfFileVersion() - { - return $this->getFromCustomData(self::CUSTOM_DATA_CON_FILE_VERSION, null, 0); - } - - public function setConfFileVersion($v) - { - return $this->putInCustomData(self::CUSTOM_DATA_CON_FILE_VERSION, $v); - } - - public function getConfFileFeaturesVersion() - { - return $this->getFromCustomData(self::CUSTOM_DATA_CONF_FILE_FEATURES_VERSION, null, 0); - } - - public function setConfFileFeaturesVersion($v) - { - return $this->putInCustomData(self::CUSTOM_DATA_CONF_FILE_FEATURES_VERSION, $v); - } - - - public function getCacheInvalidationKeys() - { - return array("uiConf:id=" . strtolower($this->getId()), "uiConf:partnerId=" . strtolower($this->getPartnerId())); - } - - private function shouldSetContent() - { - foreach ($this->content as $contentItem) { - if ($contentItem['shouldSet']) - return true; - } - return false; - } - - private function getSubTypeBySuffix($suffix = null) - { - if ($suffix == null) - return self::FILE_SYNC_UICONF_SUB_TYPE_DATA; - if ($suffix == self::FILE_NAME_FEATURES) - return self::FILE_SYNC_UICONF_SUB_TYPE_FEATURES; - if ($suffix == self::FILE_NAME_CONFIG) - return self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG; - } - - private function getSuffixBySubType($subType) - { - if ($subType == self::FILE_SYNC_UICONF_SUB_TYPE_DATA) - return null; - if ($subType == self::FILE_SYNC_UICONF_SUB_TYPE_FEATURES) - return self::FILE_NAME_FEATURES; - if ($subType == self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG) - return self::FILE_NAME_CONFIG; - } - - public function incrementVersion($subType = self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG) - { - $version = $this->getVersion($subType); - $newVersion = kFileSyncUtils::calcObjectNewVersion($this->getId(), $version, FileSyncObjectType::UICONF, $subType); - if ($subType == self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG) { - if (!$this->getConfFileVersion() && $this->getConfFileBySuffix()) { - $this->setConfFileVersion($version); - } - if (!$this->getConfFileFeaturesVersion() && $this->getConfFileBySuffix(self::FILE_NAME_FEATURES)) { - $this->setConfFileFeaturesVersion($version); - } - } - - $this->setVersion($newVersion, $subType); - } - - //by default version of the config file is returned - public function getVersion($subType = self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG) - { - switch ($subType) { - case self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG: - return parent::getVersion(); - case self::FILE_SYNC_UICONF_SUB_TYPE_DATA: - $version = $this->getConfFileVersion(); - if ($version) - return $version; - else - return parent::getVersion(); - case self::FILE_SYNC_UICONF_SUB_TYPE_FEATURES: - $version = $this->getConfFileFeaturesVersion(); - if ($version) - return $version; - else - return parent::getVersion(); - - } - - return parent::getVersion(); - } - - public function setVersion($v, $subType = self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG) - { - switch ($subType) { - case self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG: - return parent::setVersion($v); - case self::FILE_SYNC_UICONF_SUB_TYPE_DATA: - return $this->setConfFileVersion($v); - case self::FILE_SYNC_UICONF_SUB_TYPE_FEATURES: - return $this->setConfFileFeaturesVersion($v); - } - - return parent::setVersion($v); - } + // override with data from the $new_ui_conf_obj - the name can be chosen to override + if ($new_ui_conf_obj) { + baseObjectUtils::fillObjectFromObject($all_fields, // assume the new_ui_conf_obj can be fully copied to the cloned + $new_ui_conf_obj, + $cloned, + baseObjectUtils::CLONE_POLICY_PREFER_NEW, null, BasePeer::TYPE_PHPNAME); + } + + if ($new_name) { + $cloned->setName($new_name); + } + + foreach (self::$validSubTypes as $subType) { + $suffix = $this->getSuffixBySubType($subType); + $content = $this->getConfFileBySuffix($suffix); + $cloned->setConfFileBySuffix($suffix, $content); + } + + $cloned->save(null); + return $cloned; + } + + public function getSwfNameFromType() + { + $name = @self::$swf_names [$this->getObjType()]; + if ($name) + return $name; + return ""; + } + + public function getDirectoryFromType() + { + if (isset(self::$swf_directory_map[$this->getObjType()])) + return self::$swf_directory_map[$this->getObjType()]; + + return ""; + } + + public function getDirectoryMap() + { + return self::$swf_directory_map; + } + + public function getSwfNames() + { + return self::$swf_names; + } + + + public function getAutoplay() + { + return $this->getFromCustomData("autoplay", null, false); + } + + public function setAutoplay($v) + { + return $this->putInCustomData("autoplay", $v); + } + + public function getAutomuted() + { + return $this->getFromCustomData("automuted", null, false); + } + + public function setAutomuted($v) + { + return $this->putInCustomData("automuted", $v); + } + + public function getConfFileVersion() + { + return $this->getFromCustomData(self::CUSTOM_DATA_CON_FILE_VERSION, null, 0); + } + + public function setConfFileVersion($v) + { + return $this->putInCustomData(self::CUSTOM_DATA_CON_FILE_VERSION, $v); + } + + public function getConfFileFeaturesVersion() + { + return $this->getFromCustomData(self::CUSTOM_DATA_CONF_FILE_FEATURES_VERSION, null, 0); + } + + public function setConfFileFeaturesVersion($v) + { + return $this->putInCustomData(self::CUSTOM_DATA_CONF_FILE_FEATURES_VERSION, $v); + } + + + public function getCacheInvalidationKeys() + { + return array("uiConf:id=" . strtolower($this->getId()), "uiConf:partnerId=" . strtolower($this->getPartnerId())); + } + + private function shouldSetContent() + { + foreach ($this->content as $contentItem) { + if ($contentItem['shouldSet']) + return true; + } + return false; + } + + private function getSubTypeBySuffix($suffix = null) + { + if ($suffix == null) + return self::FILE_SYNC_UICONF_SUB_TYPE_DATA; + if ($suffix == self::FILE_NAME_FEATURES) + return self::FILE_SYNC_UICONF_SUB_TYPE_FEATURES; + if ($suffix == self::FILE_NAME_CONFIG) + return self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG; + } + + private function getSuffixBySubType($subType) + { + if ($subType == self::FILE_SYNC_UICONF_SUB_TYPE_DATA) + return null; + if ($subType == self::FILE_SYNC_UICONF_SUB_TYPE_FEATURES) + return self::FILE_NAME_FEATURES; + if ($subType == self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG) + return self::FILE_NAME_CONFIG; + } + + public function incrementVersion($subType = self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG) + { + $version = $this->getVersion($subType); + $newVersion = kFileSyncUtils::calcObjectNewVersion($this->getId(), $version, FileSyncObjectType::UICONF, $subType); + if ($subType == self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG) { + if (!$this->getConfFileVersion() && $this->getConfFileBySuffix()) { + $this->setConfFileVersion($version); + } + if (!$this->getConfFileFeaturesVersion() && $this->getConfFileBySuffix(self::FILE_NAME_FEATURES)) { + $this->setConfFileFeaturesVersion($version); + } + } + + $this->setVersion($newVersion, $subType); + } + + //by default version of the config file is returned + public function getVersion($subType = self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG) + { + switch ($subType) { + case self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG: + return parent::getVersion(); + case self::FILE_SYNC_UICONF_SUB_TYPE_DATA: + $version = $this->getConfFileVersion(); + if ($version) + return $version; + else + return parent::getVersion(); + case self::FILE_SYNC_UICONF_SUB_TYPE_FEATURES: + $version = $this->getConfFileFeaturesVersion(); + if ($version) + return $version; + else + return parent::getVersion(); + + } + + return parent::getVersion(); + } + + public function setVersion($v, $subType = self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG) + { + switch ($subType) { + case self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG: + return parent::setVersion($v); + case self::FILE_SYNC_UICONF_SUB_TYPE_DATA: + return $this->setConfFileVersion($v); + case self::FILE_SYNC_UICONF_SUB_TYPE_FEATURES: + return $this->setConfFileFeaturesVersion($v); + } + + return parent::setVersion($v); + } //v2 to v7 public function getV2tov7id() From 937fae046a6757d7ed3a2dacf202a50019dabbb9 Mon Sep 17 00:00:00 2001 From: MosheMaorKaltura Date: Mon, 12 Aug 2024 14:40:48 +0300 Subject: [PATCH 11/96] Code review remarks --- alpha/lib/model/uiConf.php | 567 +++++++++++++++++++------------------ 1 file changed, 292 insertions(+), 275 deletions(-) diff --git a/alpha/lib/model/uiConf.php b/alpha/lib/model/uiConf.php index 815673d3925..508678c3876 100644 --- a/alpha/lib/model/uiConf.php +++ b/alpha/lib/model/uiConf.php @@ -11,13 +11,13 @@ class uiConf extends BaseuiConf implements ISyncableFile, IRelatedObject { const MYSQL_CODE_DUPLICATE_KEY = 23000; - + const UI_CONF_TYPE_GENERIC = 0; const UI_CONF_TYPE_WIDGET = 1; const UI_CONF_TYPE_CW = 2; const UI_CONF_TYPE_EDITOR = 3; const UI_CONF_TYPE_ADVANCED_EDITOR = 4; - const UI_CONF_TYPE_PLAYLIST = 5; // maybe this is in fact type WIDGET with some flags switched on ?!? + const UI_CONF_TYPE_PLAYLIST = 5; // maybe this is in fact type WIDGET with some flags switched on ?!? const UI_CONF_TYPE_KMC_APP_STUDIO = 6; const UI_CONF_TYPE_KRECORD = 7; const UI_CONF_TYPE_KDP3 = 8; @@ -55,38 +55,38 @@ class uiConf extends BaseuiConf implements ISyncableFile, IRelatedObject private static $UI_CONF_OBJ_TYPE_MAP = null; private static $REQUIRE_UI_CONF_FILE_FOR_TYPE = null; - + private static $validSubTypes = array(self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG, self::FILE_SYNC_UICONF_SUB_TYPE_DATA, self::FILE_SYNC_UICONF_SUB_TYPE_FEATURES); private $content = array(); private $swf_url_version = null; //UI_CONF_TYPE_KSR:: This is a general path value the actual jar file should be symlinked under each KSR version dir - private static $swf_names = array(self::UI_CONF_TYPE_WIDGET => "kdp.swf", - self::UI_CONF_TYPE_CW => "ContributionWizard.swf", - self::UI_CONF_TYPE_EDITOR => "simpleeditor.swf", - self::UI_CONF_TYPE_ADVANCED_EDITOR => "KalturaAdvancedVideoEditor.swf", - self::UI_CONF_TYPE_PLAYLIST => "kdp.swf", - self::UI_CONF_TYPE_KMC_APP_STUDIO => "applicationstudio.swf", - self::UI_CONF_TYPE_KDP3 => "kdp3.swf", - self::UI_CONF_TYPE_KMC_ACCOUNT => "account.swf", - self::UI_CONF_TYPE_KMC_ANALYTICS => "ReportsAndAnalytics.swf", - self::UI_CONF_TYPE_KMC_CONTENT => "content.swf", - self::UI_CONF_TYPE_KMC_DASHBOARD => "dashboard.swf", - self::UI_CONF_TYPE_KMC_LOGIN => "login.swf", - self::UI_CONF_TYPE_SLP => "KalturaPlayer.xap", - self::UI_CONF_CLIENTSIDE_ENCODER => "KEU_0.8_win.msi", - self::UI_CONF_KMC_GENERAL => "kmc.swf", - self::UI_CONF_KMC_ROLES_AND_PERMISSIONS => "", - self::UI_CONF_CLIPPER => "", - self::UI_CONF_TYPE_KSR => "ScreencastOMaticRun.jar", - self::UI_CONF_TYPE_KRECORD => "KRecord.swf", - self::UI_CONF_TYPE_KUPLOAD => "KUpload.swf", - self::UI_CONF_TYPE_WEBCASTING => "", - self::UI_CONF_TYPE_SAP => "", - ); - - private static $swf_directory_map = array( + private static $swf_names = array ( self::UI_CONF_TYPE_WIDGET => "kdp.swf" , + self::UI_CONF_TYPE_CW => "ContributionWizard.swf" , + self::UI_CONF_TYPE_EDITOR => "simpleeditor.swf" , + self::UI_CONF_TYPE_ADVANCED_EDITOR => "KalturaAdvancedVideoEditor.swf" , + self::UI_CONF_TYPE_PLAYLIST => "kdp.swf" , + self::UI_CONF_TYPE_KMC_APP_STUDIO => "applicationstudio.swf", + self::UI_CONF_TYPE_KDP3 => "kdp3.swf", + self::UI_CONF_TYPE_KMC_ACCOUNT => "account.swf", + self::UI_CONF_TYPE_KMC_ANALYTICS => "ReportsAndAnalytics.swf", + self::UI_CONF_TYPE_KMC_CONTENT => "content.swf", + self::UI_CONF_TYPE_KMC_DASHBOARD => "dashboard.swf", + self::UI_CONF_TYPE_KMC_LOGIN => "login.swf", + self::UI_CONF_TYPE_SLP => "KalturaPlayer.xap", + self::UI_CONF_CLIENTSIDE_ENCODER => "KEU_0.8_win.msi", + self::UI_CONF_KMC_GENERAL => "kmc.swf", + self::UI_CONF_KMC_ROLES_AND_PERMISSIONS => "", + self::UI_CONF_CLIPPER => "", + self::UI_CONF_TYPE_KSR => "ScreencastOMaticRun.jar", + self::UI_CONF_TYPE_KRECORD => "KRecord.swf", + self::UI_CONF_TYPE_KUPLOAD => "KUpload.swf", + self::UI_CONF_TYPE_WEBCASTING => "", + self::UI_CONF_TYPE_SAP => "", + ); + + private static $swf_directory_map = array ( self::UI_CONF_TYPE_WIDGET => "kdp", self::UI_CONF_TYPE_CW => "kcw", self::UI_CONF_TYPE_EDITOR => "kse", @@ -114,53 +114,59 @@ class uiConf extends BaseuiConf implements ISyncableFile, IRelatedObject const CUSTOM_DATA_CON_FILE_VERSION = 'conf_file_version'; const CUSTOM_DATA_CONF_FILE_FEATURES_VERSION = 'conf_file_features_version'; - //v2 to b7 const CUSTOM_DATA_V2V7_ID = "v2v7_id"; const CUSTOM_DATA_V2V7_APPROVED = "v2v7_approved"; const CUSTOM_DATA_V2V7_TRANSLATE_PLUGINS = "v2v7_translate_plugins"; - public function save(PropelPDO $con = null) + public function save(PropelPDO $con = null) { - try { - $res = parent::save($con); - } catch (PropelException $e) { + try + { + $res = parent::save( $con ); + } + catch (PropelException $e) + { /** * Because many ui-conf objects have hard-coded id, the auto-incremented id of new ui-conf could exist in the db. * Just retry to save the ui-conf with a different auto-inceremented id. */ - if ($e->getCause() && $e->getCause()->getCode() == self::MYSQL_CODE_DUPLICATE_KEY) //unique constraint + if($e->getCause() && $e->getCause()->getCode() == self::MYSQL_CODE_DUPLICATE_KEY) //unique constraint + { + $res = parent::save( $con ); + } + else { - $res = parent::save($con); - } else { throw $e; // Rethrow the unfamiliar exception } } - - if ($this->shouldSetContent()) { - foreach ($this->content as $contentItem) { + + if($this->shouldSetContent()) + { + foreach ($this->content as $contentItem) + { $confFile = $this->getConfFileBySuffix($contentItem['suffix']); if ($confFile) $this->saveConfFileToDisk($confFile, $contentItem['suffix']); $contentItem['shouldSet'] = false; - + } - $res = parent::save($con); + $res = parent::save( $con ); } $this->getConfFilePath(); - + return $res; } - + private function isUiConfContentSet($subType) { - if (!array_key_exists($subType, $this->content)) + if(!array_key_exists($subType, $this->content)) return false; $contentItem = $this->content[$subType]; - if (!$contentItem || !$contentItem['data']) + if(!$contentItem || !$contentItem['data']) return false; - - return true; + + return true; } /* (non-PHPdoc) @@ -172,12 +178,12 @@ public function postUpdate(PropelPDO $con = null) return parent::postUpdate($con); $objectDeleted = false; - if ($this->isColumnModified(uiConfPeer::STATUS) && $this->getStatus() == self::UI_CONF_STATUS_DELETED) + if($this->isColumnModified(uiConfPeer::STATUS) && $this->getStatus() == self::UI_CONF_STATUS_DELETED) $objectDeleted = true; $ret = parent::postUpdate($con); - if ($objectDeleted) + if($objectDeleted) kEventsManager::raiseEvent(new kObjectDeletedEvent($this)); return $ret; @@ -185,8 +191,9 @@ public function postUpdate(PropelPDO $con = null) private static function initUiConfTypeMap() { - if (self::$UI_CONF_OBJ_TYPE_MAP == null) { - self::$UI_CONF_OBJ_TYPE_MAP = array( + if ( self::$UI_CONF_OBJ_TYPE_MAP == null ) + { + self::$UI_CONF_OBJ_TYPE_MAP = array ( self::UI_CONF_TYPE_GENERIC => "Generic", self::UI_CONF_TYPE_WIDGET => "Widget", self::UI_CONF_TYPE_CW => "Contribution Wizard", @@ -224,7 +231,7 @@ public function getUiConfTypeMap() return self::$UI_CONF_OBJ_TYPE_MAP; } - public function getObjTypeAsString() + public function getObjTypeAsString ( ) { self::initUiConfTypeMap(); return self::$UI_CONF_OBJ_TYPE_MAP[$this->getType()]; @@ -233,7 +240,7 @@ public function getObjTypeAsString() public function getType() { $t = parent::getObjType(); - if (empty ($t)) $t = self::UI_CONF_TYPE_WIDGET; + if ( empty ( $t ) ) $t = self::UI_CONF_TYPE_WIDGET; return $t; } @@ -241,9 +248,9 @@ public function getType() * (non-PHPdoc) * @see lib/model/ISyncableFile#getSyncKey() */ - public function getSyncKey($sub_type, $version = null) + public function getSyncKey ( $sub_type , $version = null ) { - self::validateFileSyncSubType($sub_type); + self::validateFileSyncSubType ( $sub_type ); $key = new FileSyncKey(); $key->object_type = FileSyncObjectType::UICONF; $key->object_sub_type = $sub_type; @@ -252,23 +259,24 @@ public function getSyncKey($sub_type, $version = null) // TODO - add version to the DB $key->version = $this->getVersion($sub_type); - $key->partner_id = $this->getPartnerId(); + $key->partner_id=$this->getPartnerId(); return $key; } + /* (non-PHPdoc) * @see lib/model/ISyncableFile#generateFileName() */ - public function generateFileName($sub_type, $version = null) + public function generateFileName( $sub_type, $version = null) { - self::validateFileSyncSubType($sub_type); + self::validateFileSyncSubType ( $sub_type ); $suffix = $this->getSuffixBySubType($sub_type); - if ($suffix == null) + if($suffix == null) return "ui_conf{$version}.xml"; - else - return "ui_conf." . $suffix . $version . ".xml"; + else + return "ui_conf.".$suffix.$version.".xml"; return null; } @@ -277,31 +285,36 @@ public function generateFileName($sub_type, $version = null) * (non-PHPdoc) * @see lib/model/ISyncableFile#generateFilePathArr() */ - public function generateFilePathArr($sub_type, $version = null, $externalPath = false) + public function generateFilePathArr($sub_type, $version = null, $externalPath = false ) { // TODO - implement field version - self::validateFileSyncSubType($sub_type); + self::validateFileSyncSubType ( $sub_type ); $suffix = $this->getSuffixBySubType($sub_type); $incVersion = false; - if ($sub_type == self::FILE_SYNC_UICONF_SUB_TYPE_DATA) { + if($sub_type == self::FILE_SYNC_UICONF_SUB_TYPE_DATA) + { $incVersion = true; } - + $res = $this->getConfFilePathImpl($suffix, $incVersion, $version); - - if ($externalPath) { + + if ($externalPath) + { $file_root = myCloudUtils::getPartnerSharedStorageBaseDir($this->getPartnerId()); $dir = myContentStorage::getScatteredPathFromIntId($this->getId() * 10); $file_path = "/generatedUiConf/$dir/ui_conf_{$this->getId()}_$version.xml"; - if ($suffix) { + if ($suffix) + { $file_path = str_replace("xml", "$suffix.xml", $file_path); } - } else { + } + else + { $file_root = myContentStorage::getFSContentRootPath(); $file_path = str_replace(myContentStorage::getFSContentRootPath(), "", $res); } - - return array($file_root, $file_path); + + return array ( $file_root , $file_path ) ; } @@ -315,39 +328,41 @@ public function generateFilePathArr($sub_type, $version = null, $externalPath = /** * @return FileSync */ - public function getFileSync() + public function getFileSync ( ) { return $this->m_file_sync; } - public function setFileSync(FileSync $file_sync) + public function setFileSync ( FileSync $file_sync ) { - $this->m_file_sync = $file_sync; + $this->m_file_sync = $file_sync; } - private static function validateFileSyncSubType($sub_type) + private static function validateFileSyncSubType ( $sub_type ) { - if (!in_array($sub_type, self::$validSubTypes)) - throw new FileSyncException (FileSyncObjectType::UICONF, $sub_type, $validSubTypes); + if ( !in_array($sub_type, self::$validSubTypes)) + throw new FileSyncException ( FileSyncObjectType::UICONF ,$sub_type , $validSubTypes ); } - private function saveConfFileToDisk($v, $file_suffix = null, $isClone = false) + private function saveConfFileToDisk($v , $file_suffix = null , $isClone = false) { - if ($this->getCreationMode() == self::UI_CONF_CREATION_MODE_MANUAL) { - throw new Exception ("Should not edit MANUAL ui_confs via the API!! Only via the SVN"); + if ( $this->getCreationMode() == self::UI_CONF_CREATION_MODE_MANUAL ) + { + throw new Exception ( "Should not edit MANUAL ui_confs via the API!! Only via the SVN" ); } - + $subType = $this->getSubTypeBySuffix($file_suffix); $this->incrementVersion($subType); - $sync_key = $this->getSyncKey($subType); - - $this->setUpdatedAt(time()); // make sure will be updated in the DB - if (version_compare($this->getSwfUrlVersion(), "2.5", ">=")) { + $sync_key = $this->getSyncKey( $subType ); + + $this->setUpdatedAt( time() ); // make sure will be updated in the DB + if (version_compare($this->getSwfUrlVersion(), "2.5", ">=")) + { $v = str_replace('.entryName}', '.name}', $v); } // This is only called on Save, after parent::save(), so ID is present. - kFileSyncUtils::file_put_contents($sync_key, $v); //replaced__setFileContent + kFileSyncUtils::file_put_contents( $sync_key , $v ); //replaced__setFileContent } private function setConfFileBySuffix($suffix = null, $v) @@ -357,85 +372,87 @@ private function setConfFileBySuffix($suffix = null, $v) $contentItem['suffix'] = $suffix; $contentItem['shouldSet'] = true; $contentItem['subType'] = $subType; - - if ($v !== null) { + + if ( $v !== null ) + { $contentItem['data'] = $v; $this->content[$subType] = $contentItem; } } - + private function getConfFileBySuffix($suffix = null, $force_fetch = false) { $subType = $this->getSubTypeBySuffix($suffix); $contents = ""; - if ($this->isUiConfContentSet($subType) && !$force_fetch) + if($this->isUiConfContentSet($subType) && ! $force_fetch ) return $this->content[$subType]['data']; - - $sync_key = $this->getSyncKey($subType); - - $contents = kFileSyncUtils::file_get_contents($sync_key, true, false); - - if (!$contents) + + $sync_key = $this->getSyncKey( $subType ); + + $contents = kFileSyncUtils::file_get_contents( $sync_key , true , false ); + + if(!$contents) KalturaLog::debug("Conf file of sub type [$subType] not found for key [$sync_key]"); return $contents; } - - public function setConfFile($v /*, $increment_version = true */) + + public function setConfFile ( $v /*, $increment_version = true */ ) { $this->setConfFileBySuffix(null, $v); } - public function getConfFile($force_fetch = false) + public function getConfFile( $force_fetch = false ) { - return $this->getConfFileBySuffix(null, $force_fetch); + return $this->getConfFileBySuffix( null, $force_fetch); } - public function setConfFileFeatures($v) + public function setConfFileFeatures ( $v ) { $this->setConfFileBySuffix(self::FILE_NAME_FEATURES, $v); } // check this ! - public function getConfFileFeatures($force_fetch = false) + public function getConfFileFeatures ( $force_fetch = false ) { - return $this->getConfFileBySuffix(self::FILE_NAME_FEATURES, $force_fetch); + return $this->getConfFileBySuffix( self::FILE_NAME_FEATURES, $force_fetch ); } - public function setConfig($v /*, $increment_version = true */) + public function setConfig ( $v /*, $increment_version = true */ ) { $this->setConfFileBySuffix(self::FILE_NAME_CONFIG, $v); } // will fetch - public function getConfig($force_fetch = false) + public function getConfig ( $force_fetch = false ) { - return $this->getConfFileBySuffix(self::FILE_NAME_CONFIG, $force_fetch); + return $this->getConfFileBySuffix( self::FILE_NAME_CONFIG, $force_fetch ); } - + private $m_file_time; - private function getFileTime() { - if (!$this->m_file_time) - $this->m_file_time = strftime("%Y-%m-%d_%H-%M-%S", time()); + if ( ! $this->m_file_time ) + $this->m_file_time = strftime( "%Y-%m-%d_%H-%M-%S" , time() ); return $this->m_file_time; } - public function getSwfUrl($raw_only = false) + public function getSwfUrl ( $raw_only = false ) { $raw = parent::getSwfUrl(); - if ($raw_only) return $raw; - $root_url = kConf::get("flash_root_url"); - if (!$root_url) + if ( $raw_only ) return $raw; + $root_url = kConf::get ( "flash_root_url"); + if ( ! $root_url ) return $raw; - if (strpos($raw, $root_url) === 0) { + if ( strpos ( $raw , $root_url) === 0 ) + { // if the raw url already has the exact prefix of root_url - return the raw - no need to re-append it - return $raw; + return $raw; } - if (strpos($raw, "http://") === 0) { + if ( strpos ( $raw , "http://" ) === 0 ) + { // if the raw url starts with http - don't append to it - return $raw; + return $raw; } return $root_url . $raw; @@ -447,8 +464,9 @@ public function setSwfUrlVersion($version) $flashUrl = myContentStorage::getFSFlashRootPath(); $swfName = $this->getSwfNameFromType(); $dir = $this->getDirectoryFromType(); - - if ($version) { + + if($version) + { if (strpos($this->swf_url, "kdp3") !== false) $this->setSwfUrl("$flashUrl/kdp3/v{$version}/kdp3.swf"); else @@ -456,42 +474,49 @@ public function setSwfUrlVersion($version) } } - public function getSwfUrlVersion() + public function getSwfUrlVersion () { $swf_url = $this->getSwfUrl(); - $flash_url = myContentStorage::getFSFlashRootPath(); - $match = preg_match('/\/v([\w\d\.]+)/', $swf_url, $version); - if ($match) { + $flash_url = myContentStorage::getFSFlashRootPath (); + $match = preg_match ( '/\/v([\w\d\.]+)/' , $swf_url , $version ); + if ( $match ) + { return $version[1]; } return null; } - private function getCachedContent($kaltura_config, $confFilePath) + private function getCachedContent ( $kaltura_config , $confFilePath ) { - if (!file_exists($confFilePath)) return null; - if (strpos($confFilePath, "://") != FALSE) { + if ( ! file_exists ( $confFilePath ) ) return null; + if ( strpos ( $confFilePath , "://" ) != FALSE ) + { // remote file (http:// or ftp://) - store the cache in a directory near the base file //$cache_path = dirname( $kaltura_config ) . "cache/" . $confFilePath . "_cache.xml" ; // for now - don't cache for remote files $cache_path = null; - } else { + } + else + { // this is a local file - store the cache file in the same directory - $cache_path = str_replace("/uiconf/", "/cacheuiconf/", $confFilePath) . "_cache.xml"; - kFile::fullMkdir($cache_path); + $cache_path = str_replace ( "/uiconf/" , "/cacheuiconf/" ,$confFilePath ) . "_cache.xml"; + kFile::fullMkdir( $cache_path ); } - try { - $s_time = microtime(true); - $config = new kXmlConfig($kaltura_config, $confFilePath); - $content = $config->getConfig($cache_path); - $e_time = microtime(true); + try + { + $s_time = microtime( true ); + $config = new kXmlConfig( $kaltura_config , $confFilePath ); + $content = $config->getConfig( $cache_path ); + $e_time = microtime( true ); - if ($config->createdCache()) - KalturaLog::log(__METHOD__ . " created config cache file [$kaltura_config]+[$confFilePath]->[$cache_path].\ntook [" . ($e_time - $s_time) . "] seconds"); + if ( $config->createdCache() ) + KalturaLog::log( __METHOD__ . " created config cache file [$kaltura_config]+[$confFilePath]->[$cache_path].\ntook [" . ($e_time - $s_time) . "] seconds" ); return $content; - } catch (Exception $ex) { - KalturaLog::log(__METHOD__ . " Error creating config [$kaltura_config]+[$confFilePath]:" . $ex->getMessage()); + } + catch ( Exception $ex ) + { + KalturaLog::log( __METHOD__ . " Error creating config [$kaltura_config]+[$confFilePath]:" . $ex->getMessage() ); return null; } } @@ -508,32 +533,35 @@ public function internalGetParentConfFilePath() return parent::getConfFilePath(); } - public function getConfFilePath($file_suffix = null, $inc_version = false) + public function getConfFilePath( $file_suffix = null , $inc_version = false ) { - return $this->getConfFilePathImpl($file_suffix, $inc_version); + return $this->getConfFilePathImpl( $file_suffix ,$inc_version ); } - private function getConfFilePathImpl($file_suffix = null, $inc_version = false, $version = null) + private function getConfFilePathImpl( $file_suffix = null , $inc_version = false, $version = null ) { $conf_file_path = parent::getConfFilePath(); - if ($this->getCreationMode() != self::UI_CONF_CREATION_MODE_MANUAL) { - if (!$conf_file_path || $inc_version || $version) { - if (!$this->getId()) + if ( $this->getCreationMode() != self::UI_CONF_CREATION_MODE_MANUAL ) + { + if( ! $conf_file_path || $inc_version || $version) + { + if ( ! $this->getId() ) return null; $conf_file_path = $this->createConfFilePath($version); - $this->setConfFilePath($conf_file_path); + $this->setConfFilePath( $conf_file_path ); } } // will fix the current problem in the DB- we hold the root in the conf_file_path - $conf_file_path = myContentStorage::getFSContentRootPath() . str_replace("/web/", "", $conf_file_path); + $conf_file_path = myContentStorage::getFSContentRootPath( ).str_replace ( "/web/" , "" , $conf_file_path ) ; - if ($file_suffix) { + if ( $file_suffix ) + { // use the file_suffix before the extension - $extension = pathinfo($conf_file_path, PATHINFO_EXTENSION); - $conf_file_path = str_replace($extension, "$file_suffix.$extension", $conf_file_path); + $extension = pathinfo ( $conf_file_path , PATHINFO_EXTENSION ); + $conf_file_path = str_replace ( $extension , "$file_suffix.$extension" , $conf_file_path ); } return $conf_file_path; @@ -542,122 +570,132 @@ private function getConfFilePathImpl($file_suffix = null, $inc_version = false, /* * Should not be used as updateable field until the paths on disk are safe to set */ - public function setConfFilePath($v) + public function setConfFilePath( $v ) { - if (kString::beginsWith($v, "..")) { + if ( kString::beginsWith( $v , ".." ) ) + { $err = "Error in " . __METHOD__ . ": attmpting to set ConfFilePath to [$v]"; - KalturaLog::log($err); - throw new APIException (APIErrors::ERROR_SETTING_FILE_PATH_FOR_UI_CONF, $v); + KalturaLog::log( $err ); + throw new APIException ( APIErrors::ERROR_SETTING_FILE_PATH_FOR_UI_CONF , $v ); } - if ($this->getCreationMode() == self::UI_CONF_CREATION_MODE_MANUAL) { - if (!kString::beginsWith($v, $this->getUiConfRootDirectory() . "uiconf/")) { - $v = $this->getUiConfRootDirectory() . "uiconf/" . $v; + if ( $this->getCreationMode() == self::UI_CONF_CREATION_MODE_MANUAL ) + { + if ( ! kString::beginsWith( $v , $this->getUiConfRootDirectory() . "uiconf/" ) ) + { + $v = $this->getUiConfRootDirectory() . "uiconf/" . $v ; } - $real_v = realpath(dirname($v)) . "/" . pathinfo($v, PATHINFO_BASENAME); - - if ($v) { - if ($real_v) { - /* - * TODO - add this id the service IS externally use via the API - // the file exists - make sure we're not overiding someone elses file - $ui_confs_with_same_path = uiConfPeer::retrieveByConfFilePath ( $real_v , $this->getId() ); - foreach ( $ui_confs_with_same_path as $ui_conf ) - { - if ( $ui_conf->getPartnerId ( ) != $this->getPartnerId() ) - { - $err = "Error in " . __METHOD__ . ": attmpting to set ConfFilePath to [$v]"; - KalturaLog::log( $err ); - throw new APIException ( APIErrors::ERROR_SETTING_FILE_PATH_FOR_UI_CONF , $v ); - } - } - */ + $real_v = realpath( dirname( $v ) ) . "/" . pathinfo( $v , PATHINFO_BASENAME ); + + if ( $v ) + { + if ( $real_v ) + { +/* + * TODO - add this id the service IS externally use via the API + // the file exists - make sure we're not overiding someone elses file + $ui_confs_with_same_path = uiConfPeer::retrieveByConfFilePath ( $real_v , $this->getId() ); + foreach ( $ui_confs_with_same_path as $ui_conf ) + { + if ( $ui_conf->getPartnerId ( ) != $this->getPartnerId() ) + { + $err = "Error in " . __METHOD__ . ": attmpting to set ConfFilePath to [$v]"; + KalturaLog::log( $err ); + throw new APIException ( APIErrors::ERROR_SETTING_FILE_PATH_FOR_UI_CONF , $v ); + } + } +*/ $v = $real_v; } } - parent::setConfFilePath($v); - } else { - parent::setConfFilePath($v); + parent::setConfFilePath( $v ); + } + else + { + parent::setConfFilePath( $v ); // throw new APIException ( APIErrors::ERROR_SETTING_FILE_PATH_FOR_UI_CONF , $v ); } } - private function createConfFilePath($version = null) + private function createConfFilePath ($version = null) { - if ($this->getVersion() || $version) + if ( $this->getVersion() || $version) $version = "_" . ($version ? $version : $this->getVersion()); else $version = ""; - - $dir = (intval($this->getId() / 1000000)) . '/' . (intval($this->getId() / 1000) % 1000); + + $dir = (intval($this->getId() / 1000000)).'/'. (intval($this->getId() / 1000) % 1000); $file_name = "/content/generatedUiConf/$dir/ui_conf_{$this->getId()}_{$version}.xml"; return $file_name; } // IMPORTANT : WILL NOT include the uiconf or generatedUiconf part of the path - private function getUiConfRootDirectory() + private function getUiConfRootDirectory () { $content_path = myContentStorage::getFSContentRootPath(); - return $content_path . "content/"; + return $content_path . "content/"; } /* * will create a new uiConf object in the DB from this object while using fields from */ - public function cloneToNew($new_ui_conf_obj, $new_name = null) + public function cloneToNew ( $new_ui_conf_obj , $new_name = null ) { $cloned = new uiConf(); $cloned->setCopiedFrom($this); - $all_fields = uiConfPeer::getFieldNames(); - $ignore_list = array("Id", "ConfFilePath"); + $all_fields = uiConfPeer::getFieldNames (); + $ignore_list = array ( "Id" , "ConfFilePath" ); // clone from current - baseObjectUtils::fillObjectFromObject($all_fields, - $this, - $cloned, - baseObjectUtils::CLONE_POLICY_PREFER_NEW, $ignore_list, BasePeer::TYPE_PHPNAME); + baseObjectUtils::fillObjectFromObject( $all_fields , + $this , + $cloned , + baseObjectUtils::CLONE_POLICY_PREFER_NEW , $ignore_list , BasePeer::TYPE_PHPNAME ); // $cloned->setNew(true); // override with data from the $new_ui_conf_obj - the name can be chosen to override - if ($new_ui_conf_obj) { - baseObjectUtils::fillObjectFromObject($all_fields, // assume the new_ui_conf_obj can be fully copied to the cloned - $new_ui_conf_obj, - $cloned, - baseObjectUtils::CLONE_POLICY_PREFER_NEW, null, BasePeer::TYPE_PHPNAME); + if ( $new_ui_conf_obj ) + { + baseObjectUtils::fillObjectFromObject( $all_fields , // assume the new_ui_conf_obj can be fully copied to the cloned + $new_ui_conf_obj , + $cloned , + baseObjectUtils::CLONE_POLICY_PREFER_NEW , null , BasePeer::TYPE_PHPNAME ); } - if ($new_name) { - $cloned->setName($new_name); + if ($new_name) + { + $cloned->setName( $new_name ); } - - foreach (self::$validSubTypes as $subType) { + + foreach (self::$validSubTypes as $subType) + { $suffix = $this->getSuffixBySubType($subType); $content = $this->getConfFileBySuffix($suffix); - $cloned->setConfFileBySuffix($suffix, $content); + $cloned->setConfFileBySuffix($suffix, $content); } - + $cloned->save(null); return $cloned; } - public function getSwfNameFromType() + public function getSwfNameFromType () { - $name = @self::$swf_names [$this->getObjType()]; - if ($name) + $name = @self::$swf_names [ $this->getObjType()]; + if($name) return $name; return ""; } - + public function getDirectoryFromType() { - if (isset(self::$swf_directory_map[$this->getObjType()])) + if(isset(self::$swf_directory_map[$this->getObjType()])) return self::$swf_directory_map[$this->getObjType()]; - + return ""; } - public function getDirectoryMap() + public function getDirectoryMap () { return self::$swf_directory_map; } @@ -668,132 +706,111 @@ public function getSwfNames() } - public function getAutoplay() - { - return $this->getFromCustomData("autoplay", null, false); - } - - public function setAutoplay($v) - { - return $this->putInCustomData("autoplay", $v); - } - - public function getAutomuted() - { - return $this->getFromCustomData("automuted", null, false); - } - public function setAutomuted($v) - { - return $this->putInCustomData("automuted", $v); - } - - public function getConfFileVersion() - { - return $this->getFromCustomData(self::CUSTOM_DATA_CON_FILE_VERSION, null, 0); - } - - public function setConfFileVersion($v) - { - return $this->putInCustomData(self::CUSTOM_DATA_CON_FILE_VERSION, $v); - } - - public function getConfFileFeaturesVersion() - { - return $this->getFromCustomData(self::CUSTOM_DATA_CONF_FILE_FEATURES_VERSION, null, 0); - } - - public function setConfFileFeaturesVersion($v) - { - return $this->putInCustomData(self::CUSTOM_DATA_CONF_FILE_FEATURES_VERSION, $v); - } + public function getAutoplay () { return $this->getFromCustomData( "autoplay" , null , false ); } + public function setAutoplay( $v ) { return $this->putInCustomData( "autoplay", $v ); } + public function getAutomuted () { return $this->getFromCustomData( "automuted" , null , false ); } + public function setAutomuted( $v ) { return $this->putInCustomData( "automuted", $v ); } + + public function getConfFileVersion () { return $this->getFromCustomData( self::CUSTOM_DATA_CON_FILE_VERSION, null, 0); } + public function setConfFileVersion( $v ) { return $this->putInCustomData( self::CUSTOM_DATA_CON_FILE_VERSION, $v ); } + + public function getConfFileFeaturesVersion () { return $this->getFromCustomData( self::CUSTOM_DATA_CONF_FILE_FEATURES_VERSION, null, 0); } + public function setConfFileFeaturesVersion( $v ) { return $this->putInCustomData( self::CUSTOM_DATA_CONF_FILE_FEATURES_VERSION, $v ); } + public function getCacheInvalidationKeys() { - return array("uiConf:id=" . strtolower($this->getId()), "uiConf:partnerId=" . strtolower($this->getPartnerId())); + return array("uiConf:id=".strtolower($this->getId()), "uiConf:partnerId=".strtolower($this->getPartnerId())); } - + private function shouldSetContent() { - foreach ($this->content as $contentItem) { - if ($contentItem['shouldSet']) + foreach ($this->content as $contentItem) + { + if($contentItem['shouldSet']) return true; } return false; } - + private function getSubTypeBySuffix($suffix = null) { - if ($suffix == null) + if($suffix == null) return self::FILE_SYNC_UICONF_SUB_TYPE_DATA; - if ($suffix == self::FILE_NAME_FEATURES) + if($suffix == self::FILE_NAME_FEATURES) return self::FILE_SYNC_UICONF_SUB_TYPE_FEATURES; - if ($suffix == self::FILE_NAME_CONFIG) - return self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG; + if($suffix == self::FILE_NAME_CONFIG) + return self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG; } - + private function getSuffixBySubType($subType) { - if ($subType == self::FILE_SYNC_UICONF_SUB_TYPE_DATA) + if($subType == self::FILE_SYNC_UICONF_SUB_TYPE_DATA) return null; - if ($subType == self::FILE_SYNC_UICONF_SUB_TYPE_FEATURES) + if($subType == self::FILE_SYNC_UICONF_SUB_TYPE_FEATURES) return self::FILE_NAME_FEATURES; - if ($subType == self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG) - return self::FILE_NAME_CONFIG; + if($subType == self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG) + return self::FILE_NAME_CONFIG; } public function incrementVersion($subType = self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG) { $version = $this->getVersion($subType); $newVersion = kFileSyncUtils::calcObjectNewVersion($this->getId(), $version, FileSyncObjectType::UICONF, $subType); - if ($subType == self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG) { - if (!$this->getConfFileVersion() && $this->getConfFileBySuffix()) { + if($subType == self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG) + { + if(!$this->getConfFileVersion() && $this->getConfFileBySuffix()) + { $this->setConfFileVersion($version); } - if (!$this->getConfFileFeaturesVersion() && $this->getConfFileBySuffix(self::FILE_NAME_FEATURES)) { + if(!$this->getConfFileFeaturesVersion() && $this->getConfFileBySuffix(self::FILE_NAME_FEATURES)) + { $this->setConfFileFeaturesVersion($version); } } - + $this->setVersion($newVersion, $subType); } - + //by default version of the config file is returned public function getVersion($subType = self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG) { - switch ($subType) { + switch ($subType) + { case self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG: return parent::getVersion(); case self::FILE_SYNC_UICONF_SUB_TYPE_DATA: $version = $this->getConfFileVersion(); - if ($version) + if($version) return $version; else return parent::getVersion(); case self::FILE_SYNC_UICONF_SUB_TYPE_FEATURES: $version = $this->getConfFileFeaturesVersion(); - if ($version) + if($version) return $version; else return parent::getVersion(); - + } - + return parent::getVersion(); } - + public function setVersion($v, $subType = self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG) { - switch ($subType) { + switch ($subType) + { case self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG: return parent::setVersion($v); case self::FILE_SYNC_UICONF_SUB_TYPE_DATA: return $this->setConfFileVersion($v); case self::FILE_SYNC_UICONF_SUB_TYPE_FEATURES: - return $this->setConfFileFeaturesVersion($v); + return $this->setConfFileFeaturesVersion($v); } - + return parent::setVersion($v); } From 45a92c5ae26f352558fc2cedfe1b81877665e765 Mon Sep 17 00:00:00 2001 From: MosheMaorKaltura Date: Mon, 12 Aug 2024 16:45:33 +0300 Subject: [PATCH 12/96] PLAT-24912: support v2 to v7 --- .../modules/extwidget/actions/embedIframeJsAction.class.php | 3 --- .../modules/extwidget/actions/embedPlaykitJsAction.class.php | 1 - 2 files changed, 4 deletions(-) diff --git a/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php index 0d1fdca08af..759c698b8e5 100644 --- a/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php @@ -1,7 +1,4 @@ Date: Tue, 13 Aug 2024 15:04:11 +0300 Subject: [PATCH 13/96] 1. Map entryId filter to contextId for queries over cnc datasource 2. Add new report type for engagement over time --- .../lib/reports/kKavaEventPlatformReports.php | 23 +++++++++++++++++++ .../lib/reports/kKavaReportsMgr.class.php | 13 ++++++++--- alpha/lib/enums/ReportType.php | 1 + 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/alpha/apps/kaltura/lib/reports/kKavaEventPlatformReports.php b/alpha/apps/kaltura/lib/reports/kKavaEventPlatformReports.php index 67d33f1a487..3d8ae62297e 100644 --- a/alpha/apps/kaltura/lib/reports/kKavaEventPlatformReports.php +++ b/alpha/apps/kaltura/lib/reports/kKavaEventPlatformReports.php @@ -319,6 +319,29 @@ class kKavaEventPlatformReports extends kKavaReportsMgr self::METRIC_UNIQUE_VOD_VIEW_PERIOD_USERS, self::METRIC_VOD_UNIQUE_PERCENTILES_RATIO ) + ), + + ReportType::EP_WEBCAST_ENGAGEMENT_OVER_TIME => array( + self::REPORT_DIMENSION_MAP => array( + 'position' => self::DIMENSION_POSITION + ), + self::REPORT_FILTER => array( + self::DRUID_TYPE => self::DRUID_NOT, + self::DRUID_FILTER => array( + self::DRUID_DIMENSION => self::DIMENSION_POSITION, + self::DRUID_VALUES => array(self::VALUE_UNKNOWN, "0", "") + ) + ), + self::REPORT_JOIN_REPORTS => array( + array( + self::REPORT_UNION_DATA_SOURCES => array(self::DATASOURCE_HISTORICAL, self::DATASOURCE_MEETING_HISTORICAL), + self::REPORT_METRICS => array(self::METRIC_UNIQUE_COMBINED_LIVE_VIEW_PERIOD_USERS, self::METRIC_COMBINED_LIVE_ENGAGED_USERS_RATIO) + ), + array( + self::REPORT_DATA_SOURCE => self::DATASOURCE_CNC_EVENTS, + self::REPORT_METRICS => array(self::EVENT_TYPE_MESSAGE_LIKED, self::EVENT_TYPE_REACTION_CLICKED, self::EVENT_TYPE_GROUP_MESSAGE_SENT) + ) + ) ) ); diff --git a/alpha/apps/kaltura/lib/reports/kKavaReportsMgr.class.php b/alpha/apps/kaltura/lib/reports/kKavaReportsMgr.class.php index 9b47e7b3e1c..572f517771e 100644 --- a/alpha/apps/kaltura/lib/reports/kKavaReportsMgr.class.php +++ b/alpha/apps/kaltura/lib/reports/kKavaReportsMgr.class.php @@ -2833,6 +2833,12 @@ protected static function getEntryKuserDimension($data_source) return in_array($data_source, array(self::DATASOURCE_ENTRY_LIFECYCLE, self::DATASOURCE_STORAGE_USAGE)) ? self::DIMENSION_KUSER_ID : self::DIMENSION_ENTRY_OWNER_ID; } + protected static function getEntryIdDimension($data_source) + { + return $data_source === self::DATASOURCE_CNC_EVENTS ? self::DIMENSION_CONTEXT_ID : self::DIMENSION_ENTRY_ID; + } + + protected static function getDruidFilter($partner_id, $report_def, $input_filter, $object_ids, $response_options) { $druid_filter = array(); @@ -2888,6 +2894,7 @@ protected static function getDruidFilter($partner_id, $report_def, $input_filter ); } + $entry_id_dimension = self::getEntryIdDimension($data_source); $field_dim_map = array( 'categoriesIds' => array(self::DRUID_DIMENSION => self::DIMENSION_CATEGORIES), 'countries' => array(self::DRUID_DIMENSION => self::DIMENSION_LOCATION_COUNTRY), @@ -2906,8 +2913,8 @@ protected static function getDruidFilter($partner_id, $report_def, $input_filter 'cities' => array(self::DRUID_DIMENSION => self::DIMENSION_LOCATION_CITY), 'media_types' => array(self::DRUID_DIMENSION => self::DIMENSION_MEDIA_TYPE), 'source_types' => array(self::DRUID_DIMENSION => self::DIMENSION_SOURCE_TYPE), - 'entries_ids' => array(self::DRUID_DIMENSION => self::DIMENSION_ENTRY_ID), - 'entries_ids_not_in' => array(self::DRUID_DIMENSION => self::DIMENSION_ENTRY_ID, self::DRUID_TYPE => self::DRUID_NOT), + 'entries_ids' => array(self::DRUID_DIMENSION => $entry_id_dimension), + 'entries_ids_not_in' => array(self::DRUID_DIMENSION => $entry_id_dimension, self::DRUID_TYPE => self::DRUID_NOT), 'playback_context_ids' => array(self::DRUID_DIMENSION => self::DIMENSION_PLAYBACK_CONTEXT), 'root_entries_ids' => array(self::DRUID_DIMENSION => self::DIMENSION_ROOT_ENTRY_ID), 'event_var1' => array(self::DRUID_DIMENSION => self::DIMENSION_EVENT_VAR1), @@ -3066,7 +3073,7 @@ protected static function getDruidFilter($partner_id, $report_def, $input_filter if (count($entry_ids_from_db)) { $druid_filter[] = array( - self::DRUID_DIMENSION => self::DIMENSION_ENTRY_ID, + self::DRUID_DIMENSION => $entry_id_dimension, self::DRUID_VALUES => array_values(array_unique($entry_ids_from_db)) ); } diff --git a/alpha/lib/enums/ReportType.php b/alpha/lib/enums/ReportType.php index df477437701..492922346c3 100644 --- a/alpha/lib/enums/ReportType.php +++ b/alpha/lib/enums/ReportType.php @@ -229,6 +229,7 @@ interface ReportType extends BaseEnum const EP_VIEWTIME = 60015; const EP_TOP_MOMENTS = 60016; const EP_TOP_SESSIONS = 60017; + const EP_WEBCAST_ENGAGEMENT_OVER_TIME = 60018; const CNC_PARTICIPATION = 70001; } From 0b1ca2eb8d26802bdfdfd850b52dc9eb8c1dfef3 Mon Sep 17 00:00:00 2001 From: drorsouhami Date: Tue, 13 Aug 2024 09:54:09 +0300 Subject: [PATCH 14/96] REACH2-1235: Display all reach tasks in Reach Requests tab --- .../reach/admin/ReachRequestsListAction.php | 46 ++++++++++++++++++- .../admin/forms/EntryVendorTasksFilter.php | 22 +++++++++ .../plugin/reach-requests-list-action.phtml | 2 + 3 files changed, 68 insertions(+), 2 deletions(-) diff --git a/plugins/reach/admin/ReachRequestsListAction.php b/plugins/reach/admin/ReachRequestsListAction.php index a218ec8a173..7da672ed8bc 100644 --- a/plugins/reach/admin/ReachRequestsListAction.php +++ b/plugins/reach/admin/ReachRequestsListAction.php @@ -38,6 +38,8 @@ public function doAction(Zend_Controller_Action $action) $entryVendorTaskFilterForm = self::getFilterForm($request, $action); $action->view->filterForm = $entryVendorTaskFilterForm; $action->view->paginator = $paginator; + + $this->addCreatedAtParamsToFilter($request, $action, $entryVendorTaskFilter); } protected function initFilter($request) @@ -106,7 +108,7 @@ protected function setStatusFilter($request, $entryVendorTaskFilter) } else { - $entryVendorTaskFilter->statusIn = EntryVendorTaskStatus::PENDING . ',' . EntryVendorTaskStatus::PROCESSING . ',' . EntryVendorTaskStatus::ERROR . ',' . EntryVendorTaskStatus::SCHEDULED; + $entryVendorTaskFilter->statusIn = EntryVendorTaskStatus::READY . ',' . EntryVendorTaskStatus::PENDING . ',' . EntryVendorTaskStatus::PROCESSING . ',' . EntryVendorTaskStatus::ERROR . ',' . EntryVendorTaskStatus::SCHEDULED; } } @@ -131,4 +133,44 @@ public function isAllowedForPartner($partnerId) $isAllowed = ($result->totalCount > 0) && ($result->objects[0]->status == Kaltura_Client_Enum_PermissionStatus::ACTIVE); return $isAllowed; } -} \ No newline at end of file + + private function addCreatedAtParamsToFilter($request, $action, &$entryVendorTaskFilter) + { + if ($request->getParam('createdAtFrom', false)) + { + $createdAtFrom = new Zend_Date($this->_getParam('createdAtFrom', $this->getDefaultFromDate())); + $entryVendorTaskFilter->createdAtGreaterThanOrEqual = $createdAtFrom->toString(Zend_Date::TIMESTAMP); + } + else + { + $createdAtFrom = $action->view->filterForm->getElement('createdAtFrom'); + $createdAtFrom->setValue(date('m/d/Y', $this->getDefaultFromDate())); + + $entryVendorTaskFilter->createdAtGreaterThanOrEqual = $this->getDefaultFromDate(); + } + + if ($request->getParam('createdAtTo', false)) + { + $createdAtTo = new Zend_Date($this->_getParam('createdAtTo', $this->getDefaultToDate())); + $createdAtTo->addDay(1); + $entryVendorTaskFilter->createdAtLessThanOrEqual = $createdAtTo->toString(Zend_Date::TIMESTAMP); + } + else + { + $createdAtTo = $action->view->filterForm->getElement('createdAtTo'); + $createdAtTo->setValue(date('m/d/Y', $this->getDefaultToDate())); + + $entryVendorTaskFilter->createdAtLessThanOrEqual = $this->getDefaultToDate(); + } + } + + private function getDefaultFromDate() + { + return time() - (60 * 60 * 12); + } + + private function getDefaultToDate() + { + return time() + (60 * 60 * 12); + } +} diff --git a/plugins/reach/admin/forms/EntryVendorTasksFilter.php b/plugins/reach/admin/forms/EntryVendorTasksFilter.php index 13b8be03dc3..577f18ee2d0 100644 --- a/plugins/reach/admin/forms/EntryVendorTasksFilter.php +++ b/plugins/reach/admin/forms/EntryVendorTasksFilter.php @@ -14,6 +14,7 @@ public function init() $filterType = $this->getElement('filter_type'); $filterType->setMultiOptions(array( + 'idEqual' => 'Task ID', 'vendorPartnerIdEqual' => 'Vendor Partner ID', 'partnerIdEqual' => 'Partner ID' )); @@ -24,6 +25,7 @@ public function init() 'decorators' => array('ViewHelper'), 'multiOptions' => array( '' => 'Status', + EntryVendorTaskStatus::READY => 'READY', EntryVendorTaskStatus::PENDING => 'PENDING', EntryVendorTaskStatus::SCHEDULED => 'SCHEDULED', EntryVendorTaskStatus::PROCESSING => 'PROCESSING', @@ -51,6 +53,26 @@ public function init() 'decorators' => array('ViewHelper'), )); + $this->addElement('hidden', 'newLine1', array( + 'decorators' => array('ViewHelper', array('Label', array('placement' => 'append')), array('HtmlTag', array('tag' => 'br', 'class' => 'newLine'))) + )); + + $this->addElement('hidden', 'newLine2', array( + 'decorators' => array('ViewHelper', array('Label', array('placement' => 'append')), array('HtmlTag', array('tag' => 'br', 'class' => 'newLine'))) + )); + + $this->addElement('text', 'createdAtFrom', array( + 'label' => 'From Date:', + )); + + $this->addElement('hidden', 'newLine3', array( + 'decorators' => array('ViewHelper', array('Label', array('placement' => 'append')), array('HtmlTag', array('tag' => 'br', 'class' => 'newLine'))) + )); + + $this->addElement('text', 'createdAtTo', array( + 'label' => 'To Date:', + )); + $this->addElement('hidden', 'crossLine', array( 'decorators' => array('ViewHelper', array('Label', array('placement' => 'append')), array('HtmlTag', array('tag' => 'hr', 'class' => 'crossLine'))) )); diff --git a/plugins/reach/admin/scripts/plugin/reach-requests-list-action.phtml b/plugins/reach/admin/scripts/plugin/reach-requests-list-action.phtml index 6354199720a..be898c1dfc2 100644 --- a/plugins/reach/admin/scripts/plugin/reach-requests-list-action.phtml +++ b/plugins/reach/admin/scripts/plugin/reach-requests-list-action.phtml @@ -80,6 +80,8 @@ jQuery('#filter_type').change(); + jQuery('#createdAtFrom, #createdAtTo').datepicker({showOn: 'both', buttonImage: 'baseUrl('images/calendar.gif'); ?>', buttonImageOnly: true}); + function exportToCsv(filterType, filterInput, status, dueDate){ dueDate = dueDate.replace('+','%2B'); var paramsStr = '/filter_type/' + filterType + '/filter_input/' + filterInput + '/filter_status/' + status + '/due_date/' + dueDate; From 4d1a6d575405f9ade09ed0c9a7b72b6414945252 Mon Sep 17 00:00:00 2001 From: MosheMaorKaltura Date: Wed, 14 Aug 2024 16:25:33 +0300 Subject: [PATCH 15/96] PLAT-24912: add config tp the bundle --- alpha/apps/kaltura/lib/v2Tov7Utils.class.php | 33 +++++-------------- .../actions/embedIframeJsAction.class.php | 2 +- .../actions/embedPlaykitJsAction.class.php | 15 +++++---- 3 files changed, 17 insertions(+), 33 deletions(-) diff --git a/alpha/apps/kaltura/lib/v2Tov7Utils.class.php b/alpha/apps/kaltura/lib/v2Tov7Utils.class.php index 12499d903b6..afd6cee5e6b 100644 --- a/alpha/apps/kaltura/lib/v2Tov7Utils.class.php +++ b/alpha/apps/kaltura/lib/v2Tov7Utils.class.php @@ -67,40 +67,23 @@ static function addV2toV7plugins($flashvars, &$bundleConfig, &$playerConfig) } } - static function addV2toV7config($config, $flashvars, $uiconfId) + static function addV2toV7config($flashvars, $uiconfId) { + $config = []; //Merge v7 config - if (!isset($config["provider"])) { - $config["provider"] = new stdClass(); - } - $unHandledVars = array(); $config["uiconf_id"] = $uiconfId; if($flashvars) { + $config["flashvars"] = []; foreach ($flashvars as $key => $value) { - if(self::isVarPlugin($key)) - { - continue; - } $key = trim(trim($key, '"'), "'"); - $providerParams = ["partnerId", "uiconf_id", "entry_id", "cache_st", "wid", "ks", "autoPlay", "playlistAPI.autoContinue"]; - if (in_array($key, $providerParams)) { - if ($value) { - KalturaLog::log("V2toV7 adding {$key}: " . $value); - $config["provider"]->$key = $value; - } - } - else{ - $unHandledVars[] = $key; - } - } - if(sizeof($unHandledVars)) - { - throw new Exception("UnHandled params:" . implode(",",$unHandledVars)); + //$providerParams = ["partnerId", "uiconf_id", "entry_id", "cache_st", "wid", "ks", "autoPlay", "playlistAPI.autoContinue"]; + $config['flashvars'][$key] = $value; } } - - return $config; + $ret = PHP_EOL.'window.__kalturaplayerdataV2toV7=' . json_encode($config); + KalturaLog::log("Adding config code:" . $ret); + return $ret; } private static function isVarPlugin($varKeyName) diff --git a/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php index 759c698b8e5..4b14d28d172 100644 --- a/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php @@ -163,7 +163,7 @@ private function redirectToV7($v7Id, $v2UiConfId, $partnerId, $shouldTranslatePl $config = array(); $config['bundleConfig'] = null; $config['playerConfig'] = new stdClass(); - $config = v2Tov7Utils::addV2toV7config($config,$this->getRequestParameter(v2Tov7Utils::FLASHVARS_PARAM_NAME),$v7Id); + v2Tov7Utils::addV2toV7config($this->getRequestParameter(v2Tov7Utils::FLASHVARS_PARAM_NAME),$v7Id); if($shouldTranslatePlugins) { v2Tov7Utils::addV2toV7plugins( diff --git a/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php index 06ef02fe4fc..27096e807c7 100644 --- a/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php @@ -77,6 +77,7 @@ public function execute() $v2ToV7Code = v2Tov7Utils::getBundledFacade(); $v2ToV7Code = PHP_EOL . PHP_EOL . $v2ToV7Code; $bundleContent = $bundleContent . $v2ToV7Code; + } // send cache headers @@ -172,6 +173,13 @@ private function formatBundleContent($bundleContent, $i18nContent, $extraModules $autoEmbed = $this->getRequestParameter(self::AUTO_EMBED_PARAM_NAME); $iframeEmbed = $this->getRequestParameter(self::IFRAME_EMBED_PARAM_NAME); + //Add v2 to v7 config + if($this->getRequestParameter(v2Tov7Utils::V2TOV7_PARAM_NAME)) + { + $v2ToV7config = v2Tov7Utils::addV2toV7config($this->getRequestParameter(v2Tov7Utils::FLASHVARS_PARAM_NAME),$this->uiconfId); + $bundleContent .= $v2ToV7config; + } + //if auto embed selected add embed script to bundle content if ($autoEmbed) { @@ -514,13 +522,6 @@ private function getAutoEmbedCode($targetId = null) } $config["targetId"] = $targetId; - - //Add v2 to v7 config - if($this->uiConf->getV2tov7id() && ($this->getRequestParameter(v2Tov7Utils::V2TOV7_PARAM_NAME) || $this->uiConf->getV2tov7Approved()) ) - { - $config = v2Tov7Utils::addV2toV7config($config,$this->getRequestParameter(v2Tov7Utils::FLASHVARS_PARAM_NAME),$this->uiconfId); - } - $config = json_encode($config); if ($config === false) { From 898c528ca14b21025be212732190e2078b81ebca Mon Sep 17 00:00:00 2001 From: drorsouhami Date: Mon, 19 Aug 2024 13:04:14 +0300 Subject: [PATCH 16/96] REACH2-1236: Require source language captions via API --- plugins/reach/errors/KalturaReachErrors.php | 2 ++ .../reach/services/EntryVendorTaskService.php | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/plugins/reach/errors/KalturaReachErrors.php b/plugins/reach/errors/KalturaReachErrors.php index 00ae3b818e4..6835db99ebe 100644 --- a/plugins/reach/errors/KalturaReachErrors.php +++ b/plugins/reach/errors/KalturaReachErrors.php @@ -90,6 +90,8 @@ class KalturaReachErrors implements kReachErrors const TOO_LATE_ORDER = "TOO_LATE_ORDER;EVENT_ID,CATALOG_ITEM_ID,MINIMAL_ORDER_TIME;Task created too late for event [@EVENT_ID@], minimal order time for catalog item [@CATALOG_ITEM_ID@] is [@MINIMAL_ORDER_TIME@ min]"; const TOO_LONG_SCHEDULED_TASK = "TOO_LONG_SCHEDULED_TASK;TASK_DURATION,DURATION_LIMIT,CATALOG_ITEM_ID;The task duration [@TASK_DURATION@] is exceeding the limit [@DURATION_LIMIT@] defined in catalogItem [@CATALOG_ITEM_ID@]"; + + const REQUIRE_CAPTION = "REQUIRE_CAPTION;CATALOG_ITEM_ID;Caption Asset must be provided for catalog item [@CATALOG_ITEM_ID@]"; /* Credit */ diff --git a/plugins/reach/services/EntryVendorTaskService.php b/plugins/reach/services/EntryVendorTaskService.php index 26625ecb9bb..2713e764f86 100644 --- a/plugins/reach/services/EntryVendorTaskService.php +++ b/plugins/reach/services/EntryVendorTaskService.php @@ -39,21 +39,21 @@ public function initService($serviceId, $serviceName, $actionName) public function addAction(KalturaEntryVendorTask $entryVendorTask) { $entryVendorTask->validateForInsert(); - + $dbEntry = entryPeer::retrieveByPK($entryVendorTask->entryId); - if(!$dbEntry) + if (!$dbEntry) { throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $entryVendorTask->entryId); } $dbReachProfile = ReachProfilePeer::retrieveActiveByPk($entryVendorTask->reachProfileId); - if(!$dbReachProfile) + if (!$dbReachProfile) { throw new KalturaAPIException(KalturaReachErrors::REACH_PROFILE_NOT_FOUND, $entryVendorTask->reachProfileId); } $partnerCatalogItem = PartnerCatalogItemPeer::retrieveByCatalogItemId($entryVendorTask->catalogItemId, kCurrentContext::getCurrentPartnerId()); - if(!$partnerCatalogItem) + if (!$partnerCatalogItem) { throw new KalturaAPIException(KalturaReachErrors::CATALOG_ITEM_NOT_ENABLED_FOR_ACCOUNT, $entryVendorTask->catalogItemId); } @@ -63,11 +63,19 @@ public function addAction(KalturaEntryVendorTask $entryVendorTask) $taskVersion = $dbVendorCatalogItem->getTaskVersion($dbEntry->getId(), $dbTaskData); $taskDuration = $dbTaskData ? $dbTaskData->getEntryDuration() : null; $featureType = $dbVendorCatalogItem->getServiceFeature(); - if(!kReachUtils::isFeatureTypeSupportedForEntry($dbEntry, $featureType)) + if (!kReachUtils::isFeatureTypeSupportedForEntry($dbEntry, $featureType)) { throw new KalturaAPIException(KalturaReachErrors::FEATURE_TYPE_NOT_SUPPORTED_FOR_ENTRY, $featureType, $entryVendorTask->entryId); } + if ($dbVendorCatalogItem instanceof VendorTranslationCatalogItem && $dbVendorCatalogItem->getRequireSource()) + { + if (!$dbTaskData instanceof kTranslationVendorTaskData || !$dbTaskData->getCaptionAssetId()) + { + throw new KalturaAPIException(KalturaReachErrors::REQUIRE_CAPTION, $dbVendorCatalogItem->getId()); + } + } + //check if credit has expired if(kReachUtils::hasCreditExpired($dbReachProfile) && $dbVendorCatalogItem->getPricing() && $dbVendorCatalogItem->getPricing()->getPricePerUnit()) { From ae2f00e9eb2930235b3cabc0c2834279d882b4d8 Mon Sep 17 00:00:00 2001 From: MosheMaorKaltura Date: Mon, 19 Aug 2024 15:31:15 +0300 Subject: [PATCH 17/96] PLAT-24912: Add support in flash vars translations --- alpha/apps/kaltura/lib/v2Tov7Utils.class.php | 7 ++-- .../actions/embedPlaykitJsAction.class.php | 32 +++++++++---------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/alpha/apps/kaltura/lib/v2Tov7Utils.class.php b/alpha/apps/kaltura/lib/v2Tov7Utils.class.php index afd6cee5e6b..fea68098eee 100644 --- a/alpha/apps/kaltura/lib/v2Tov7Utils.class.php +++ b/alpha/apps/kaltura/lib/v2Tov7Utils.class.php @@ -77,13 +77,10 @@ static function addV2toV7config($flashvars, $uiconfId) $config["flashvars"] = []; foreach ($flashvars as $key => $value) { $key = trim(trim($key, '"'), "'"); - //$providerParams = ["partnerId", "uiconf_id", "entry_id", "cache_st", "wid", "ks", "autoPlay", "playlistAPI.autoContinue"]; - $config['flashvars'][$key] = $value; + $config['flashvars'][$key] = json_decode($value); } } - $ret = PHP_EOL.'window.__kalturaplayerdataV2toV7=' . json_encode($config); - KalturaLog::log("Adding config code:" . $ret); - return $ret; + return $config; } private static function isVarPlugin($varKeyName) diff --git a/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php index 27096e807c7..479437b3178 100644 --- a/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php @@ -65,21 +65,16 @@ public function execute() list($bundleContent, $i18nContent, $extraModulesNames) = kLock::runLocked($this->bundle_name, array("embedPlaykitJsAction", "buildBundleLocked"), array($this)); } - - $lastModified = $this->getLastModified($bundleContent); - //Format bundle content - $bundleContent = $this->formatBundleContent($bundleContent, $i18nContent, $extraModulesNames); if($this->getRequestParameter(v2Tov7Utils::V2TOV7_PARAM_NAME)) { - //Will be replaced with URL to remote player code - $v2ToV7Code = v2Tov7Utils::getBundledFacade(); - $v2ToV7Code = PHP_EOL . PHP_EOL . $v2ToV7Code; - $bundleContent = $bundleContent . $v2ToV7Code; - + $bundleContent .= PHP_EOL . v2Tov7Utils::getBundledFacade(); } + //Format bundle content + $bundleContent = $this->formatBundleContent($bundleContent, $i18nContent, $extraModulesNames); + // send cache headers $this->sendHeaders($bundleContent, $lastModified); @@ -173,13 +168,6 @@ private function formatBundleContent($bundleContent, $i18nContent, $extraModules $autoEmbed = $this->getRequestParameter(self::AUTO_EMBED_PARAM_NAME); $iframeEmbed = $this->getRequestParameter(self::IFRAME_EMBED_PARAM_NAME); - //Add v2 to v7 config - if($this->getRequestParameter(v2Tov7Utils::V2TOV7_PARAM_NAME)) - { - $v2ToV7config = v2Tov7Utils::addV2toV7config($this->getRequestParameter(v2Tov7Utils::FLASHVARS_PARAM_NAME),$this->uiconfId); - $bundleContent .= $v2ToV7config; - } - //if auto embed selected add embed script to bundle content if ($autoEmbed) { @@ -528,9 +516,19 @@ private function getAutoEmbedCode($targetId = null) KExternalErrors::dieError(KExternalErrors::INVALID_PARAMETER, "Invalid config object"); } + $v2tov7ConfigJs=""; + if($this->getRequestParameter(v2Tov7Utils::V2TOV7_PARAM_NAME)) + { + $v2ToV7config = v2Tov7Utils::addV2toV7config($this->getRequestParameter(v2Tov7Utils::FLASHVARS_PARAM_NAME), $this->uiconfId); + $v2tov7ConfigJs = "var v2toV7Config = window.v2tov7_buildConfigFromFlashvars(" . JSON_encode($v2ToV7config) . "); + config = {...config,...v2toV7Config};"; + } + $autoEmbedCode = " try { - var kalturaPlayer = KalturaPlayer.setup($config); + var config=$config; + $v2tov7ConfigJs + var kalturaPlayer = KalturaPlayer.setup(config); $loadContentMethod } catch (e) { console.error(e.message); From 633d309eea6f74b188e2a35df50af9dc7c72f854 Mon Sep 17 00:00:00 2001 From: MosheMaorKaltura Date: Mon, 19 Aug 2024 15:35:27 +0300 Subject: [PATCH 18/96] PLAT-24912: code review remarks --- .../extwidget/actions/embedPlaykitJsAction.class.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php index 479437b3178..c9a7101a1fe 100644 --- a/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php @@ -492,7 +492,6 @@ private function getAutoEmbedCode($targetId = null) foreach ($config as $key=>$val) { $config[$key] = json_decode($val); - KalturaLog::log("Key:" .$key ." value:" . $val); } if (!isset($config["provider"])) @@ -516,12 +515,12 @@ private function getAutoEmbedCode($targetId = null) KExternalErrors::dieError(KExternalErrors::INVALID_PARAMETER, "Invalid config object"); } - $v2tov7ConfigJs=""; + $v2tov7ConfigJs=''; if($this->getRequestParameter(v2Tov7Utils::V2TOV7_PARAM_NAME)) { $v2ToV7config = v2Tov7Utils::addV2toV7config($this->getRequestParameter(v2Tov7Utils::FLASHVARS_PARAM_NAME), $this->uiconfId); - $v2tov7ConfigJs = "var v2toV7Config = window.v2tov7_buildConfigFromFlashvars(" . JSON_encode($v2ToV7config) . "); - config = {...config,...v2toV7Config};"; + $v2tov7ConfigJs = 'var v2toV7Config = window.v2tov7_buildConfigFromFlashvars(' . JSON_encode($v2ToV7config) . '); + config = {...config,...v2toV7Config};'; } $autoEmbedCode = " From 9852f8f82ab493d6c4577b6e1f1ef4732d2ca33c Mon Sep 17 00:00:00 2001 From: MosheMaorKaltura Date: Mon, 19 Aug 2024 15:48:20 +0300 Subject: [PATCH 19/96] PLAT-24912: code review --- .../modules/extwidget/actions/embedPlaykitJsAction.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php index c9a7101a1fe..e2442264fe0 100644 --- a/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php @@ -488,7 +488,6 @@ private function getAutoEmbedCode($targetId = null) } $config = $this->getRequestParameter(self::CONFIG_PARAM_NAME, array()); //enable passing nested config options - //KalturaLog::log("Autoembed:" .$config); foreach ($config as $key=>$val) { $config[$key] = json_decode($val); From b09fb6a16cc46b3299598cb9e4afa3680d25c7c0 Mon Sep 17 00:00:00 2001 From: drorsouhami Date: Tue, 20 Aug 2024 12:47:27 +0300 Subject: [PATCH 20/96] REACH2-1267: Add search Catalog Items by id --- plugins/reach/admin/CatalogItemListAction.php | 69 +++++++++++-------- .../reach/admin/forms/CatalogItemFilter.php | 2 +- 2 files changed, 40 insertions(+), 31 deletions(-) diff --git a/plugins/reach/admin/CatalogItemListAction.php b/plugins/reach/admin/CatalogItemListAction.php index cbd0b3ef145..2747bacf660 100644 --- a/plugins/reach/admin/CatalogItemListAction.php +++ b/plugins/reach/admin/CatalogItemListAction.php @@ -25,38 +25,19 @@ public function getTemplatePath() public function doAction(Zend_Controller_Action $action) { $request = $action->getRequest(); - $page = $this->_getParam('page', 1); - $pageSize = $this->_getParam('pageSize', 10); - $vendorPartnerId = $this->_getParam('filter_input') ? $this->_getParam('filter_input') : $request->getParam('partnerId'); - $serviceFeature = $this->_getParam('filterServiceFeature') != "" ? $this->_getParam('filterServiceFeature') : null; - $serviceType = $this->_getParam('filterServiceType') != "" ? $this->_getParam('filterServiceType') : null; - $turnAroundTime = $this->_getParam('filterTurnAroundTime') != "" ? $this->_getParam('filterTurnAroundTime') : null; - $sourceLanguage = $this->_getParam('filterSourceLanguage') != "" ? $this->_getParam('filterSourceLanguage') : null; - $targetLanguage = $this->_getParam('filterTargetLanguage') != "" ? $this->_getParam('filterTargetLanguage') : null; - $partnerId = null; - $action->view->allowed = $this->isAllowedForPartner($partnerId); + $catalogItemFilter = $this->getCatalogItemFilter($action); - // init filter - $catalogItemProfileFilter = $this->getCatalogItemFilter($serviceFeature); - $catalogItemProfileFilter->orderBy = "-id"; - $catalogItemProfileFilter->serviceFeatureEqual = $serviceFeature; - $catalogItemProfileFilter->serviceTypeEqual = $serviceType; - $catalogItemProfileFilter->turnAroundTimeEqual = $turnAroundTime; - $catalogItemProfileFilter->vendorPartnerIdEqual = $vendorPartnerId; - $catalogItemProfileFilter->sourceLanguageEqual = $sourceLanguage; - - if(in_array($serviceFeature, array(Kaltura_Client_Reach_Enum_VendorServiceFeature::TRANSLATION, Kaltura_Client_Reach_Enum_VendorServiceFeature::DUBBING))) - { - $catalogItemProfileFilter->targetLanguageEqual = $targetLanguage; - } + $action->view->allowed = $this->isAllowedForPartner(null); $client = Infra_ClientHelper::getClient(); $reachPluginClient = Kaltura_Client_Reach_Plugin::get($client); // get results and paginate - $paginatorAdapter = new Infra_FilterPaginator($reachPluginClient->vendorCatalogItem, "listAction", $partnerId, $catalogItemProfileFilter); + $paginatorAdapter = new Infra_FilterPaginator($reachPluginClient->vendorCatalogItem, "listAction", null, $catalogItemFilter); $paginator = new Infra_Paginator($paginatorAdapter, $request); + $page = $this->_getParam('page', 1); + $pageSize = $this->_getParam('pageSize', 10); $paginator->setCurrentPageNumber($page); $paginator->setItemCountPerPage($pageSize); @@ -73,13 +54,10 @@ public function doAction(Zend_Controller_Action $action) $actionUrl = $action->view->url(array('controller' => 'plugin', 'action' => 'CatalogItemConfigure'), null, true); $createProfileForm->setAction($actionUrl); - if ($partnerId) - $createProfileForm->getElement("newPartnerId")->setValue($partnerId); - $action->view->newCatalogItemFolderForm = $createProfileForm; } - protected function getCatalogItemFilter($serviceFeature) + protected function getCatalogItemFilterByServiceFeature($serviceFeature) { if ($serviceFeature == Kaltura_Client_Reach_Enum_VendorServiceFeature::CAPTIONS) return new Kaltura_Client_Reach_Type_VendorCaptionsCatalogItemFilter(); @@ -103,6 +81,38 @@ protected function getCatalogItemFilter($serviceFeature) return new Kaltura_Client_Reach_Type_VendorCatalogItemFilter(); } + protected function getCatalogItemFilter($action) + { + $request = $action->getRequest(); + + $serviceFeature = $this->_getParam('filterServiceFeature') != "" ? $this->_getParam('filterServiceFeature') : null; + $serviceType = $this->_getParam('filterServiceType') != "" ? $this->_getParam('filterServiceType') : null; + $turnAroundTime = $this->_getParam('filterTurnAroundTime') != "" ? $this->_getParam('filterTurnAroundTime') : null; + $sourceLanguage = $this->_getParam('filterSourceLanguage') != "" ? $this->_getParam('filterSourceLanguage') : null; + $targetLanguage = $this->_getParam('filterTargetLanguage') != "" ? $this->_getParam('filterTargetLanguage') : null; + + $catalogItemFilter = $this->getCatalogItemFilterByServiceFeature($serviceFeature); + $catalogItemFilter->orderBy = "-id"; + $catalogItemFilter->serviceFeatureEqual = $serviceFeature; + $catalogItemFilter->serviceTypeEqual = $serviceType; + $catalogItemFilter->turnAroundTimeEqual = $turnAroundTime; + $catalogItemFilter->sourceLanguageEqual = $sourceLanguage; + + $filterInput = $request->getParam('filter_input'); + if (strlen($filterInput)) + { + $filterType = $request->getParam('filter_type'); + $catalogItemFilter->$filterType = $filterInput; + } + + if(in_array($serviceFeature, array(Kaltura_Client_Reach_Enum_VendorServiceFeature::TRANSLATION, Kaltura_Client_Reach_Enum_VendorServiceFeature::DUBBING))) + { + $catalogItemFilter->targetLanguageEqual = $targetLanguage; + } + + return $catalogItemFilter; + } + public function getInstance($interface) { if ($this instanceof $interface) @@ -131,8 +141,7 @@ public function isAllowedForPartner($partnerId) $isAllowed = ($result->totalCount > 0) && ($result->objects[0]->status == Kaltura_Client_Enum_PermissionStatus::ACTIVE); return $isAllowed; } - - + /** * @return array - array of */ diff --git a/plugins/reach/admin/forms/CatalogItemFilter.php b/plugins/reach/admin/forms/CatalogItemFilter.php index c4eae04a928..d90d37c1676 100644 --- a/plugins/reach/admin/forms/CatalogItemFilter.php +++ b/plugins/reach/admin/forms/CatalogItemFilter.php @@ -13,7 +13,7 @@ public function init() $filterType = $this->getElement('filter_type'); $filterType->setMultiOptions(array( 'vendorPartnerIdEqual' => 'Vendor Partner ID', -// 'idEqual' => 'Catalog Item ID', + 'idEqual' => 'Catalog Item ID', )); $filterServiceFeature = new Kaltura_Form_Element_EnumSelect('filterServiceFeature', array( From b6fe8aa9d9191e44ffc4fc0e033e506cf1d4edee Mon Sep 17 00:00:00 2001 From: drorsouhami Date: Tue, 20 Aug 2024 14:02:10 +0300 Subject: [PATCH 21/96] REACH2-1266: Allow renaming Catalog Items from Admin Console --- plugins/reach/admin/forms/CatalogItemConfigure.php | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/reach/admin/forms/CatalogItemConfigure.php b/plugins/reach/admin/forms/CatalogItemConfigure.php index 5beece43c2a..6fdc6cbe627 100644 --- a/plugins/reach/admin/forms/CatalogItemConfigure.php +++ b/plugins/reach/admin/forms/CatalogItemConfigure.php @@ -50,7 +50,6 @@ public function init() 'required' => true, 'filters' => array('StringTrim'), 'placement' => 'prepend', - 'readonly' => $this->disableAttributes, )); $this->addElement('text', 'systemName', array( From 4c8a1413324870d56f15c89eddd4239272223b85 Mon Sep 17 00:00:00 2001 From: Inbal BD Date: Mon, 12 Aug 2024 12:07:12 +0300 Subject: [PATCH 22/96] Updated version - Tucana-20.18.0 --- VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.txt b/VERSION.txt index 0d78978415b..5955dc01d7b 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -Tucana-20.17.0 +Tucana-20.18.0 From 23119109ee21dce6f4866c3cf1dd4db19d6dde56 Mon Sep 17 00:00:00 2001 From: drorsouhami Date: Sun, 11 Aug 2024 09:40:31 +0300 Subject: [PATCH 23/96] SUP-43860: Purify multilingual fields --- .../types/KalturaMultiLingualStringArray.php | 14 +++++++ api_v3/lib/types/KalturaObject.php | 42 ++++++++++++------- 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/api_v3/lib/types/KalturaMultiLingualStringArray.php b/api_v3/lib/types/KalturaMultiLingualStringArray.php index 9993bfd38ed..3a6f1620961 100644 --- a/api_v3/lib/types/KalturaMultiLingualStringArray.php +++ b/api_v3/lib/types/KalturaMultiLingualStringArray.php @@ -67,4 +67,18 @@ public function toObjectsArray() return $ret; } + + public function toObjectsArrayPurified($objectClass, $objectProp, $thisProp) + { + $ret = array(); + foreach ($this->toArray() as $multiLingualStringObject) + { + /* @var $multiLingualStringObject KalturaMultiLingualString */ + $value = $multiLingualStringObject->value; + $value = $this->purifyObject($objectClass, $objectProp, $thisProp, $value); + + $ret[$multiLingualStringObject->language] = $value; + } + return $ret; + } } \ No newline at end of file diff --git a/api_v3/lib/types/KalturaObject.php b/api_v3/lib/types/KalturaObject.php index 1a109f510c7..576ccf31274 100644 --- a/api_v3/lib/types/KalturaObject.php +++ b/api_v3/lib/types/KalturaObject.php @@ -512,6 +512,10 @@ public function toObject($object_to_fill = null, $props_to_skip = array()) { $value = null; } + elseif ($value instanceof KalturaMultiLingualStringArray) + { + $value = $value->toObjectsArrayPurified(get_class($object_to_fill), $object_prop, $this_prop); + } elseif ($value instanceof KalturaTypedArray) { $value = $value->toObjectsArray(); @@ -539,27 +543,16 @@ public function toObject($object_to_fill = null, $props_to_skip = array()) } elseif (is_string($value)) { - if (! kXml::isXMLValidContent($value)) - throw new KalturaAPIException ( KalturaErrors::INVALID_PARAMETER_CHAR, $this_prop ); - else if($this->shouldPurify()) - { - try - { - $value = kHtmlPurifier::purify(get_class($object_to_fill), $object_prop, $value); - } - catch (Exception $e) - { - throw new KalturaAPIException(KalturaErrors::UNSAFE_HTML_TAGS, get_class($object_to_fill), $object_prop); - } - } + $value = $this->purifyObject(get_class($object_to_fill), $object_prop, $this_prop, $value); } - + $setter_callback = array ( $object_to_fill ,"set{$object_prop}"); if (is_callable($setter_callback)) call_user_func_array( $setter_callback , array ($value ) ); else KalturaLog::alert("setter for property [$object_prop] was not found on object class [" . get_class($object_to_fill) . "] defined as property [$this_prop] on api class [$class]"); } + KalturaLog::debug('Ending toObject - ' . print_r($object_to_fill, true)); return $object_to_fill; } @@ -930,6 +923,27 @@ protected function enablePurify() KalturaObject::$purifyHtml = true; } + protected function purifyObject($objectClass, $objectProp, $thisProp, $value) + { + if (!kXml::isXMLValidContent($value)) + { + throw new KalturaAPIException (KalturaErrors::INVALID_PARAMETER_CHAR, $thisProp); + } + if (!$this->shouldPurify()) + { + return $value; + } + + try + { + return kHtmlPurifier::purify($objectClass, $objectProp, $value); + } + catch (Exception $e) + { + throw new KalturaAPIException(KalturaErrors::UNSAFE_HTML_TAGS, $objectClass, $objectProp); + } + } + public function __debugInfo() { $className = get_class($this); From ca9d5fbb1c68fbc3651541dbe2327d6bf3a99b85 Mon Sep 17 00:00:00 2001 From: drorsouhami Date: Sun, 11 Aug 2024 09:42:27 +0300 Subject: [PATCH 24/96] SUP-43860: Remove print --- api_v3/lib/types/KalturaMultiLingualStringArray.php | 2 +- api_v3/lib/types/KalturaObject.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api_v3/lib/types/KalturaMultiLingualStringArray.php b/api_v3/lib/types/KalturaMultiLingualStringArray.php index 3a6f1620961..aa4362de1e7 100644 --- a/api_v3/lib/types/KalturaMultiLingualStringArray.php +++ b/api_v3/lib/types/KalturaMultiLingualStringArray.php @@ -81,4 +81,4 @@ public function toObjectsArrayPurified($objectClass, $objectProp, $thisProp) } return $ret; } -} \ No newline at end of file +} diff --git a/api_v3/lib/types/KalturaObject.php b/api_v3/lib/types/KalturaObject.php index 576ccf31274..5fc5428e74b 100644 --- a/api_v3/lib/types/KalturaObject.php +++ b/api_v3/lib/types/KalturaObject.php @@ -552,7 +552,7 @@ public function toObject($object_to_fill = null, $props_to_skip = array()) else KalturaLog::alert("setter for property [$object_prop] was not found on object class [" . get_class($object_to_fill) . "] defined as property [$this_prop] on api class [$class]"); } - KalturaLog::debug('Ending toObject - ' . print_r($object_to_fill, true)); + return $object_to_fill; } From cbe60d5a0476377e4222890e211d07d14dfef3a9 Mon Sep 17 00:00:00 2001 From: Salma Date: Thu, 18 Jul 2024 14:06:22 +0300 Subject: [PATCH 25/96] PLAT-24840 burn subs (ongoing) --- .../kaltura/lib/clipconcat/kClipManager.php | 29 +++++++---- .../lib/data/resource/kOperationResource.php | 2 +- .../lib/data/resource/kOperationResources.php | 23 ++++++++- .../resource/operations/kBurnCaptions.php | 50 +++++++++++++++++++ .../resource/operations/kClipAttributes.php | 45 ++++++++++++++++- alpha/lib/enums/ClipAspectRatio.php | 9 ++++ api_v3/lib/KalturaEntryService.php | 7 +-- .../batch/KalturaMultiClipConcatJobData.php | 10 +++- .../types/enums/KalturaClipAspectRatio.php | 8 +++ .../resource/KalturaOperationResources.php | 10 +++- .../operations/KalturaBurnCaption.php | 39 +++++++++++++++ .../operations/KalturaClipAttributes.php | 16 +++++- api_v3/services/MediaService.php | 2 +- 13 files changed, 229 insertions(+), 21 deletions(-) create mode 100644 alpha/lib/data/resource/operations/kBurnCaptions.php create mode 100644 alpha/lib/enums/ClipAspectRatio.php create mode 100644 api_v3/lib/types/enums/KalturaClipAspectRatio.php create mode 100644 api_v3/lib/types/resource/operations/KalturaBurnCaption.php diff --git a/alpha/apps/kaltura/lib/clipconcat/kClipManager.php b/alpha/apps/kaltura/lib/clipconcat/kClipManager.php index cde59e51449..acd293d1958 100644 --- a/alpha/apps/kaltura/lib/clipconcat/kClipManager.php +++ b/alpha/apps/kaltura/lib/clipconcat/kClipManager.php @@ -13,6 +13,7 @@ class kClipManager implements kBatchJobStatusEventConsumer const AUDIO_CHANNELS = 'audioChannels'; const AUDIO_SAMPLE_RATE = 'audioSamplingRate'; const IMAGE_TO_VIDEO = 'imageToVideo'; + const ASPECT_RATIO = 'aspectRatio'; const CONVERSION_PARAMS = 'conversionParams'; const MEDIA_INFO_OBJECT = 'mediaInfoObject'; const VIDEO_DURATION = 'videoDuration'; @@ -637,7 +638,7 @@ protected function allClipConcatJobsFinished($rootJob) /** * @throws KalturaAPIException */ - public function calculateAndEditConversionParams(&$resourcesData, $conversionProfileId) + public function calculateAndEditConversionParams(&$resourcesData, $decidedAspectRatio, $conversionProfileId) { // choose min height and min width of input dimensions and conversion profile max dimensions // choose the most common of aspect ratio and audio channels @@ -687,7 +688,7 @@ public function calculateAndEditConversionParams(&$resourcesData, $conversionPro $audioChannels = $this->decideAudioChannels($allAudioChannels); $audioSampleRate = $this->decideAudioSamplingRate($allAudioSampleRates); - $aspectRatio = $this->decideAspectRatio($aspectRatios); + $aspectRatio = $this->decideAspectRatio($aspectRatios, $decidedAspectRatio); $this->decideResolution($conversionProfileId, $aspectRatio, $width, $height); KalturaLog::debug("Multi Clip dimensions: width [$width], height [$height]"); @@ -832,12 +833,18 @@ protected function adjustResolutionByAspectRatios($aspectRatio, &$width, &$heigh } } - protected function decideAspectRatio($inputARs) + protected function decideAspectRatio($inputARs, $decidedAspectRatio) { if(count($inputARs) == 0) { throw new KalturaAPIException(KalturaErrors::INCOMPATIBLE_RESOURCES_DIMENSIONS); } + + // TODO should be int ? + if($decidedAspectRatio != ClipAspectRatio::AUTO) + { + return $decidedAspectRatio; + } $maxDurationAspectRatio = max($inputARs); return array_search($maxDurationAspectRatio, $inputARs); } @@ -1196,15 +1203,16 @@ protected function getConvertCommandForFile($jobData, $operationAttribute) return $this->getAddSilentAudioCommand($jobData, $operationAttribute, $effectsFilter); } - return $this->getDefaultConvertCommandForFile($jobData, $effectsFilter); + if($effectsFilter) + { + return $this->getEffectsOnlyCommand($jobData, $effectsFilter); + } + + return "-"; } - protected function getDefaultConvertCommandForFile($jobData, $effectsFilter) + protected function getEffectsOnlyCommand($jobData, $effectsFilter) { - if(!$effectsFilter) - { - return "-"; - } $flavorParamsObj = assetParamsPeer::getTempAssetParamByPk(kClipAttributes::SYSTEM_DEFAULT_FLAVOR_PARAMS_ID); if(!$flavorParamsObj) { @@ -1471,6 +1479,8 @@ protected function fixConversionParam($flavorParamsObj, $singleAttribute, $origi $allowEffects = !$conversionData || (!isset($conversionData[self::IMAGE_TO_VIDEO]) && !isset($conversionData[self::WIDTH])); $newExtraConversionParams = $this->editConversionEngineExtraParam($conversionEngines, $singleAttribute, $conversionExtraParams, $isAudio, $extraParams, $allowEffects); $flavorParamsObj->setConversionEnginesExtraParams($newExtraConversionParams); + $flavorParamsObj->setSubtitlesData(json_encode(array("action" => "render", "filename" => "/opt/kaltura/app/example.srt", "force_style" => array("Alignment" => 1, "FontSize" => 20,"MarginL" => 65), "language" => "English"))); + $flavorParamsObj->setSubtitlesData(json_encode(array("action" => "render", "force_style" => array("Alignment" => 1, "FontSize" => 20,"MarginL" => 65), "language" => "English", "filename" => "/opt/kaltura/app/example.srt"))); if($conversionData && $flavorParamsObj instanceof flavorParams) { $this->editConversionParams($flavorParamsObj, $conversionData); @@ -1485,6 +1495,7 @@ protected function editConversionParams(&$flavorParamsObj, $conversionParams) if($conversionParams) { $flavorParamsObj->setForceFrameToMultiplication16(0); + $flavorParamsObj->setSubtitlesData(json_encode('{"action": "render", "force_style": {"Alignment":1,"FontSize":20,"MarginL":65}}')); $flavorParamsObj->setHeight($conversionParams[self::HEIGHT]); if(isset($conversionParams[self::FRAME_RATE])) { diff --git a/alpha/lib/data/resource/kOperationResource.php b/alpha/lib/data/resource/kOperationResource.php index ae82383f3bd..da1cc9da37b 100644 --- a/alpha/lib/data/resource/kOperationResource.php +++ b/alpha/lib/data/resource/kOperationResource.php @@ -98,4 +98,4 @@ public function setAssetParamsId($assetParamsId) $this->assetParamsId = $assetParamsId; } -} \ No newline at end of file +} diff --git a/alpha/lib/data/resource/kOperationResources.php b/alpha/lib/data/resource/kOperationResources.php index 343aaa2b365..4aa41d54657 100644 --- a/alpha/lib/data/resource/kOperationResources.php +++ b/alpha/lib/data/resource/kOperationResources.php @@ -16,6 +16,19 @@ class kOperationResources extends kContentResource */ private $chapterNamePolicy; + /** + * @var KalturaClipAspectRatio + */ + private $aspectRatio; + + /** + * @return KalturaClipAspectRatio + */ + public function getAspectRatio() + { + return $this->aspectRatio; + } + /** * @return array */ @@ -47,4 +60,12 @@ public function setChapterNamePolicy($chapterNamePolicy) { $this->chapterNamePolicy = $chapterNamePolicy; } -} \ No newline at end of file + + /** + * @param KalturaClipAspectRatio $aspectRatio + */ + public function setAspectRatio($aspectRatio) + { + $this->aspectRatio = $aspectRatio; + } +} diff --git a/alpha/lib/data/resource/operations/kBurnCaptions.php b/alpha/lib/data/resource/operations/kBurnCaptions.php new file mode 100644 index 00000000000..a73bc40d2a7 --- /dev/null +++ b/alpha/lib/data/resource/operations/kBurnCaptions.php @@ -0,0 +1,50 @@ +fontSize; + } + + /** + * @param $fontSize int + */ + public function setFontSize($fontSize) + { + $this->fontSize = $fontSize; + } + + /** + * @return int + */ + public function getAlignment() + { + return $this->alignment; + } + + /** + * @param int $alignment + */ + public function setAlignment($alignment) + { + $this->alignment = $alignment; + } +} diff --git a/alpha/lib/data/resource/operations/kClipAttributes.php b/alpha/lib/data/resource/operations/kClipAttributes.php index f8223502032..a83a4c54eb4 100644 --- a/alpha/lib/data/resource/operations/kClipAttributes.php +++ b/alpha/lib/data/resource/operations/kClipAttributes.php @@ -34,6 +34,17 @@ class kClipAttributes extends kOperationAttributes private $effectArray; + /** + * @var kBurnCaptions + */ + private $burnCaptions; + + /** + * @var int + */ + private $cropAlignment; + + /* (non-PHPdoc) * @see kOperationAttributes::toArray() */ @@ -44,6 +55,8 @@ public function toArray() 'ClipDuration' => $this->duration, 'globalOffsetInDestination' => $this->globalOffsetInDestination, 'effectArray' => $this->effectArray, + 'cropAlignment' => $this->cropAlignment, + 'burnCaptions' => $this->burnCaptions ); } @@ -135,5 +148,35 @@ public function setEffectArray($effectArray) $this->effectArray = $effectArray; } + /** + * @return int + */ + public function getCropAlignment() + { + return $this->cropAlignment; + } + + /** + * @param int $cropAlignment + */ + public function setCropAlignment($cropAlignment) + { + return $this->cropAlignment = $cropAlignment; + } -} \ No newline at end of file + /** + * @return kBurnCaptions + */ + public function getBurnCaptions() + { + return $this->burnCaptions; + } + + /** + * @param kBurnCaptions $burnCaptions + */ + public function setBurnCaptions($burnCaptions) + { + return $this->burnCaptions = $burnCaptions; + } +} diff --git a/alpha/lib/enums/ClipAspectRatio.php b/alpha/lib/enums/ClipAspectRatio.php new file mode 100644 index 00000000000..be2071e18f8 --- /dev/null +++ b/alpha/lib/enums/ClipAspectRatio.php @@ -0,0 +1,9 @@ + $resources->getAspectRatio(), kClipManager::SOURCE_ENTRY => $sourceEntry, kClipManager::TEMP_ENTRY => $tempEntry, kClipManager::MEDIA_INFO_OBJECT => $mediaInfoObj, @@ -1991,7 +1992,7 @@ protected function handleMultiResourceMultiClipRequest($resources, entry $destEn } - $clipManager->calculateAndEditConversionParams($resourcesData, $destEntry->getConversionProfileId()); + $clipManager->calculateAndEditConversionParams($resourcesData, $resources->getAspectRatio(), $destEntry->getConversionProfileId()); $multiTempEntry = $clipManager->createTempEntryForClip($this->getPartnerId(), 'MULTI_TEMP_'); $clipManager->addMultiClipTrackEntries($sourceEntryIds, $tempEntryIds, $multiTempEntry->getId(), $destEntry->getId()); $rootJob = $clipManager->startMultiClipConcatBatchJob($resources, $destEntry, $multiTempEntry); @@ -2020,7 +2021,7 @@ protected function getValidatedEntryForResource($resourceObj) $sourceEntryId = $resourceObj->getEntry(); throw new APIException(KalturaErrors::ENTRY_ID_TYPE_NOT_SUPPORTED, $sourceEntryId->getId(), $sourceEntryId->getType()); } - elseif($resourceObj instanceof kFileSyncResource) + else { throw new APIException(APIErrors::ENTRY_ID_NOT_FOUND, $resourceObj->getOriginEntryId()); } diff --git a/api_v3/lib/types/batch/KalturaMultiClipConcatJobData.php b/api_v3/lib/types/batch/KalturaMultiClipConcatJobData.php index 947b2086531..c84f6625c4a 100644 --- a/api_v3/lib/types/batch/KalturaMultiClipConcatJobData.php +++ b/api_v3/lib/types/batch/KalturaMultiClipConcatJobData.php @@ -31,6 +31,11 @@ class KalturaMultiClipConcatJobData extends KalturaJobData */ public $chapterNamePolicy; + /** + * @var KalturaClipAspectRatio + */ + public $aspectRatio; + /** * @var KalturaOperationResourceArray */ @@ -44,7 +49,8 @@ class KalturaMultiClipConcatJobData extends KalturaJobData 'partnerId', 'priority', 'operationResources', - 'chapterNamePolicy' + 'chapterNamePolicy', + 'aspectRatio' ); /* (non-PHPdoc) @@ -67,4 +73,4 @@ public function toObject($dbData = null, $props_to_skip = array()) return parent::toObject($dbData, $props_to_skip); } -} \ No newline at end of file +} diff --git a/api_v3/lib/types/enums/KalturaClipAspectRatio.php b/api_v3/lib/types/enums/KalturaClipAspectRatio.php new file mode 100644 index 00000000000..08b46f01187 --- /dev/null +++ b/api_v3/lib/types/enums/KalturaClipAspectRatio.php @@ -0,0 +1,8 @@ +resources as $resource) { @@ -114,4 +122,4 @@ public function toObject($object_to_fill = null, $props_to_skip = array()) } return parent::toObject($object_to_fill, $props_to_skip); } -} \ No newline at end of file +} diff --git a/api_v3/lib/types/resource/operations/KalturaBurnCaption.php b/api_v3/lib/types/resource/operations/KalturaBurnCaption.php new file mode 100644 index 00000000000..93b2308c36a --- /dev/null +++ b/api_v3/lib/types/resource/operations/KalturaBurnCaption.php @@ -0,0 +1,39 @@ +handleErrorDuringSetResource($entryId, $e); } $this->validateContent($dbEntry); - $resource->entryHandled($dbEntry); + $resource->entryHandled($dbEntry); } return $this->getEntry($entryId); } From ee909832ac39e82eb037e6d0ec95ae1832700e95 Mon Sep 17 00:00:00 2001 From: Salma Date: Thu, 18 Jul 2024 14:08:44 +0300 Subject: [PATCH 26/96] PLAT-24840 burn subs (ongoing) --- api_v3/lib/KalturaEntryService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api_v3/lib/KalturaEntryService.php b/api_v3/lib/KalturaEntryService.php index 22887b9a0f0..ecd96a729b3 100644 --- a/api_v3/lib/KalturaEntryService.php +++ b/api_v3/lib/KalturaEntryService.php @@ -1982,7 +1982,7 @@ protected function handleMultiResourceMultiClipRequest($resources, entry $destEn } $resourcesData[] = array( -// kClipManager::ASPECT_RATIO => $resources->getAspectRatio(), +// kClipManager::ASPECT_RATIO => $resources->getAspectRatio(), kClipManager::SOURCE_ENTRY => $sourceEntry, kClipManager::TEMP_ENTRY => $tempEntry, kClipManager::MEDIA_INFO_OBJECT => $mediaInfoObj, From 9e47b430d5d069b7e5c4c151c88b00b070cf00be Mon Sep 17 00:00:00 2001 From: Salma Date: Sun, 4 Aug 2024 08:18:56 +0300 Subject: [PATCH 27/96] multi clip burn captions --- alpha/apps/kaltura/lib/KDLWrap.php | 25 ++ .../kaltura/lib/clipconcat/kClipManager.php | 344 ++++++++++++++---- .../actions/flavorParamsAction.class.php | 1 + .../lib/data/resource/kOperationResources.php | 16 +- .../data/resource/operations/kBorderStyle.php | 10 + .../resource/operations/kBurnCaptions.php | 50 --- .../operations/kCaptionsAlignment.php | 17 + .../resource/operations/kCaptionsOptions.php | 322 ++++++++++++++++ .../resource/operations/kClipAttributes.php | 19 +- .../resource/operations/kCropAspectRatio.php | 49 +++ alpha/lib/enums/ClipAspectRatio.php | 9 - alpha/lib/model/flavorParams.php | 3 + alpha/lib/model/flavorParamsOutput.php | 3 + api_v3/lib/KalturaEntryService.php | 42 ++- api_v3/lib/KalturaErrors.php | 2 + .../batch/KalturaMultiClipConcatJobData.php | 2 +- .../types/enums/KalturaClipAspectRatio.php | 8 - .../resource/KalturaOperationResources.php | 27 +- .../operations/KalturaBorderStyle.php | 9 + .../operations/KalturaBurnCaption.php | 39 -- .../operations/KalturaCaptionsAction.php | 9 + .../operations/KalturaCaptionsAlignment.php | 9 + .../operations/KalturaCaptionsOptions.php | 110 ++++++ .../operations/KalturaClipAttributes.php | 48 ++- .../operations/KalturaCropAspectRatio.php | 35 ++ .../KalturaOperationAttributesArray.php | 2 +- .../Engines/KConversionEngineFfmpeg.class.php | 48 ++- infra/cdl/kdl/KDLMediaObjectData.php | 3 + infra/cdl/kdl/KDLOperatorFfmpeg0_10.php | 16 +- infra/cdl/kdl/KDLOperatorFfmpeg2_2.php | 2 +- 30 files changed, 1039 insertions(+), 240 deletions(-) create mode 100644 alpha/lib/data/resource/operations/kBorderStyle.php delete mode 100644 alpha/lib/data/resource/operations/kBurnCaptions.php create mode 100644 alpha/lib/data/resource/operations/kCaptionsAlignment.php create mode 100644 alpha/lib/data/resource/operations/kCaptionsOptions.php create mode 100644 alpha/lib/data/resource/operations/kCropAspectRatio.php delete mode 100644 alpha/lib/enums/ClipAspectRatio.php delete mode 100644 api_v3/lib/types/enums/KalturaClipAspectRatio.php create mode 100644 api_v3/lib/types/resource/operations/KalturaBorderStyle.php delete mode 100644 api_v3/lib/types/resource/operations/KalturaBurnCaption.php create mode 100644 api_v3/lib/types/resource/operations/KalturaCaptionsAction.php create mode 100644 api_v3/lib/types/resource/operations/KalturaCaptionsAlignment.php create mode 100644 api_v3/lib/types/resource/operations/KalturaCaptionsOptions.php create mode 100644 api_v3/lib/types/resource/operations/KalturaCropAspectRatio.php diff --git a/alpha/apps/kaltura/lib/KDLWrap.php b/alpha/apps/kaltura/lib/KDLWrap.php index 1b9a0b59e1b..41edf56f2db 100644 --- a/alpha/apps/kaltura/lib/KDLWrap.php +++ b/alpha/apps/kaltura/lib/KDLWrap.php @@ -410,6 +410,15 @@ public static function ConvertFlavorKdl2Cdl(KDLFlavor $target){ $toJson = json_encode($target->_video->_subtitlesData); $flavor->setSubtitlesData($toJson); } + + /* + * Cropped + */ + if(isset($target->_video->_cropData)) + { + $toJson = json_encode($target->_video->_cropData); + $flavor->setCropData($toJson); + } } if($target->_audio) { @@ -604,6 +613,22 @@ public static function ConvertFlavorCdl2Kdl($cdlFlavor) $kdlFlavor->_video->_subtitlesData = null; } } + + /* + * cropping + */ + $cropData = $cdlFlavor->getCropData(); + if(isset($cropData)) + { + $fromJson = json_decode($cropData); + if(isset($fromJson)) + { + $kdlFlavor->_video->_cropData = $fromJson; + } + else{ + $kdlFlavor->_video->_cropData = null; + } + } } if($kdlFlavor->_video->IsDataSet()==false) diff --git a/alpha/apps/kaltura/lib/clipconcat/kClipManager.php b/alpha/apps/kaltura/lib/clipconcat/kClipManager.php index acd293d1958..0e0950075c9 100644 --- a/alpha/apps/kaltura/lib/clipconcat/kClipManager.php +++ b/alpha/apps/kaltura/lib/clipconcat/kClipManager.php @@ -13,15 +13,18 @@ class kClipManager implements kBatchJobStatusEventConsumer const AUDIO_CHANNELS = 'audioChannels'; const AUDIO_SAMPLE_RATE = 'audioSamplingRate'; const IMAGE_TO_VIDEO = 'imageToVideo'; - const ASPECT_RATIO = 'aspectRatio'; + const CROP = 'crop'; + const CROP_DATA_ARRAY = 'cropDataArray'; + const SUBTITLES_DATA_ARRAY = 'subtitlesDataArray'; const CONVERSION_PARAMS = 'conversionParams'; const MEDIA_INFO_OBJECT = 'mediaInfoObject'; - const VIDEO_DURATION = 'videoDuration'; + const CLIPS_DURATION = 'clipsDuration'; const AUDIO_DURATION = 'audioDuration'; const INVERTED_SOURCE = 'invertedSource'; const EXTRA_CONVERSION_PARAMS = 'extraConversionParams'; const TEMP_ENTRY = 'tempEntry'; const SOURCE_ENTRY = 'sourceEntry'; + const OPERATION_ATTRIBUTES_ARRAY = 'operationAttributesArray'; const MIN_FRAME_RATE = 10; const MAX_FRAME_RATE = 30; const DEFAULT_SAMPLE_RATE = 44100; @@ -413,11 +416,11 @@ protected function addClipTrackEntry($entryId, $description) * @throws kCoreException * @throws KalturaAPIException */ - protected function cloneFlavorParam($singleAttribute, $originalConversionEnginesExtraParams, $encryptionKey = null, $isAudio = false, $conversionData = null) + protected function cloneFlavorParam($singleAttribute, $singleAttributeIndex, $originalConversionEnginesExtraParams, $encryptionKey = null, $isAudio = false, $conversionData = null) { $flavorParamsObj = assetParamsPeer::getTempAssetParamByPk(kClipAttributes::SYSTEM_DEFAULT_FLAVOR_PARAMS_ID); $flavorParamsObj->setFormat(flavorParams::CONTAINER_FORMAT_MPEGTS); - $this->fixConversionParam($flavorParamsObj, $singleAttribute, $originalConversionEnginesExtraParams, $isAudio, $conversionData); + $this->fixConversionParam($flavorParamsObj, $singleAttribute, $singleAttributeIndex, $originalConversionEnginesExtraParams, $isAudio, $conversionData); if ($encryptionKey) { $flavorParamsObj->setIsEncrypted(true); @@ -638,21 +641,26 @@ protected function allClipConcatJobsFinished($rootJob) /** * @throws KalturaAPIException */ - public function calculateAndEditConversionParams(&$resourcesData, $decidedAspectRatio, $conversionProfileId) + public function calculateAndEditConversionParams(&$resourcesData, $resources, $conversionProfileId) { // choose min height and min width of input dimensions and conversion profile max dimensions - // choose the most common of aspect ratio and audio channels + // if aspect ratio is not passed, choose the most common of aspect ratio and audio channels // choose sampling rate of 44.1 kHz // scale chosen height and width by chosen aspect ratio // choose max frame rate of all input frame rates, limit 10<=frameRate<=30 - $height = 0; - $width = 0; + // if cropping, base the above dimensions calculation on the cropped output + + $targetHeight = 0; + $targetWidth = 0; $frameRate = self::MIN_FRAME_RATE; $aspectRatios = array(); $allAudioChannels = array(); $allAudioSampleRates = array(); + $cropAspectRatio = $resources->getCropAspectRatio(); + $crop = $cropAspectRatio ? $cropAspectRatio->getCrop() : false; + $aspectRatio = $cropAspectRatio ? $cropAspectRatio->getAspectRatio() : null; - foreach ($resourcesData as $resourceData) + foreach ($resourcesData as $key => $resourceData) { $entryId = $resourceData[self::SOURCE_ENTRY] ? $resourceData[self::SOURCE_ENTRY]->getId() : null; @@ -662,16 +670,41 @@ public function calculateAndEditConversionParams(&$resourcesData, $decidedAspect { throw new KalturaAPIException(KalturaErrors::INVALID_MEDIA_INFO, $entryId); } + $currentWidth = $mediaInfoObj->getVideoWidth(); $currentHeight = $mediaInfoObj->getVideoHeight(); if($currentWidth * $currentHeight == 0) { throw new KalturaAPIException(KalturaErrors::INVALID_MEDIA_INFO, $entryId); } - $width = $width == 0 ? $currentWidth : min($currentWidth, $width); - $height = $height == 0 ? $currentHeight : min($currentHeight, $height); - $duration = $resourceData[self::VIDEO_DURATION]; - $this->updateKeyFrequency($aspectRatios, $currentWidth/$currentHeight, $duration); + + if($crop && $aspectRatio) + { + $resourcesData[$key][self::CROP_DATA_ARRAY] = $this->getCropDataArray($aspectRatio, $currentWidth, $currentHeight, $resourceData[self::OPERATION_ATTRIBUTES_ARRAY]); + if(count($resourcesData[$key][self::CROP_DATA_ARRAY]) > 0) + { + // consider the dimensions after cropping to calculate target dimensions + $currentWidth = $resourcesData[$key][self::CROP_DATA_ARRAY][0]["outWidth"]; + $currentHeight = $resourcesData[$key][self::CROP_DATA_ARRAY][0]["outHeight"]; + } + } + + if(!$aspectRatio) + { + // calculate aspect ratio by frequency + $duration = $resourceData[self::CLIPS_DURATION]; + $this->updateKeyFrequency($aspectRatios, $currentWidth/$currentHeight, $duration); + } + + $targetWidth = $targetWidth == 0 ? $currentWidth : min($currentWidth, $targetWidth); + $targetHeight = $targetHeight == 0 ? $currentHeight : min($currentHeight, $targetHeight); + + $subtitlesArray = $this->getSubtitlesDataArray($resourceData[self::OPERATION_ATTRIBUTES_ARRAY]); + if(count($subtitlesArray) > 0) + { + $resourcesData[$key][self::SUBTITLES_DATA_ARRAY] = $subtitlesArray; + } + if($mediaInfoObj->getAudioChannels()) { $allAudioChannels[] = $mediaInfoObj->getAudioChannels(); @@ -685,31 +718,134 @@ public function calculateAndEditConversionParams(&$resourcesData, $decidedAspect $frameRate = max($frameRate, $mediaInfoObj->getVideoFrameRate()); } } - $audioChannels = $this->decideAudioChannels($allAudioChannels); $audioSampleRate = $this->decideAudioSamplingRate($allAudioSampleRates); - $aspectRatio = $this->decideAspectRatio($aspectRatios, $decidedAspectRatio); - $this->decideResolution($conversionProfileId, $aspectRatio, $width, $height); + $targetAspectRatio = $aspectRatio ? $aspectRatio : $this->decideAspectRatio($aspectRatios); + $this->decideResolution($conversionProfileId, $targetAspectRatio, $targetWidth, $targetHeight); - KalturaLog::debug("Multi Clip dimensions: width [$width], height [$height]"); + KalturaLog::debug("Multi Clip target dimensions: width [$targetWidth], height [$targetHeight], aspect ratio [$targetAspectRatio]"); - $conversionParams = array( - self::WIDTH => $width, - self::HEIGHT => $height, + $targetConversionParams = array( + self::CROP => $crop, + self::WIDTH => $targetWidth, + self::HEIGHT => $targetHeight, self::AUDIO_CHANNELS => $audioChannels, self::AUDIO_SAMPLE_RATE => $audioSampleRate, self::FRAME_RATE => min($frameRate, self::MAX_FRAME_RATE) ); - $this->setConversionParamsForResources($resourcesData, $conversionParams); + $this->setConversionParamsOnResourcesData($resourcesData, $targetConversionParams); } - protected function setConversionParamsForResources(&$resourcesData, $conversionParams) + protected function getCropData($targetAspectRatio, $inWidth, $inHeight, $cropAlignmentPercent = null) { - $width = $conversionParams[self::WIDTH]; - $height = $conversionParams[self::HEIGHT]; + // no cropping + if($inWidth / $inHeight == $targetAspectRatio) + { + return array(); + } + + $inHeight -= 1; + $inWidth -= 1; + + $outWidth = $inWidth; + $outHeight = $inHeight; + $widthPosition = 0; + $heightPosition = 0; + + // $alignment (0 - 1) which is (top - bottom) or (left - right), default is 0.5 (middle) + $alignment = $cropAlignmentPercent !== null ? $cropAlignmentPercent / 100 : 0.5; + + // crop height + if($inWidth / $inHeight < $targetAspectRatio) + { + $outHeight = min($outWidth / $targetAspectRatio, $inHeight); + $cropLength = $inHeight - $outHeight; + $heightPosition = $alignment * $cropLength; + } + + // crop width + else if($inWidth / $inHeight > $targetAspectRatio) + { + $outWidth = min($targetAspectRatio * $outHeight, $inWidth); + $cropLength = $inWidth - $outWidth; + $widthPosition = $alignment * $cropLength; + } + + return array( + "outWidth" => floor($outWidth), + "outHeight" => floor($outHeight), + "widthPosition" => floor($widthPosition), + "heightPosition" => floor($heightPosition) + ); + } + + protected function getCropDataArray($targetAspectRatio, $inWidth, $inHeight, $operationAttributes) + { + $cropDataArray = array(); + foreach ($operationAttributes as $operationAttribute) + { + $cropDataArray[] = $this->getCropData($targetAspectRatio, $inWidth, $inHeight, $operationAttribute->getCropAlignment()); + } + return $cropDataArray; + } + + protected function getSubtitlesDataArray($operationAttributes) + { + $subtitlesDataArray = array(); + foreach ($operationAttributes as $operationAttribute) + { + $subtitlesDataArray[] = $this->getSubtitlesData($operationAttribute->getCaptionsOptions()); + } + return $subtitlesDataArray; + } + + protected function getSubtitlesData($captionsOptions) + { + $subtitlesData = array(); + if(!($captionsOptions instanceOf kCaptionsOptions) || !$captionsOptions->getCaptionFileUrl()) + { + return $subtitlesData; + } + + $forceStyle = array(); + $forceStyle["FontName"] = $captionsOptions->getFontName(); + $forceStyle["Fontsize"] = $captionsOptions->getFontSize(); + $forceStyle["Bold"] = $captionsOptions->getBold() ? 1 : null; + $forceStyle["Italic"] = $captionsOptions->getItalic() ? 1 : null; + $forceStyle["Underline"] = $captionsOptions->getUnderline() ? 1 : null; + $forceStyle["PrimaryColour"] = $captionsOptions->getPrimaryColour(); + $forceStyle["Alignment"] = $captionsOptions->getAlignment(); + $forceStyle["BorderStyle"] = $captionsOptions->getBorderStyle(); + $forceStyle["BackColour"] = $captionsOptions->getBackColour(); + $forceStyle["OutlineColour"] = $captionsOptions->getOutlineColour(); + + foreach ($forceStyle as $key => $value) + { + if($value === null) + { + unset($forceStyle[$key]); + } + } + + // set subtitles data + $subtitlesData["action"] = $captionsOptions->getAction(); + $subtitlesData["captionFileUrl"] = $captionsOptions->getCaptionFileUrl(); + if(count($forceStyle) > 0) + { + $subtitlesData["force_style"] = $forceStyle; + } + + return $subtitlesData; + } + + protected function setConversionParamsOnResourcesData(&$resourcesData, $conversionParams) + { + $targetWidth = $conversionParams[self::WIDTH]; + $targetHeight = $conversionParams[self::HEIGHT]; $audioChannels = $conversionParams[self::AUDIO_CHANNELS]; $audioSampleRate = $conversionParams[self::AUDIO_SAMPLE_RATE]; + $crop = $conversionParams[self::CROP]; foreach ($resourcesData as $key => $resourceData) { @@ -717,54 +853,86 @@ protected function setConversionParamsForResources(&$resourcesData, $conversionP $mediaInfoObj = $resourceData[self::MEDIA_INFO_OBJECT]; $currentConversionParams = array(); - $currentConversionParams[self::HEIGHT] = $height; + $currentConversionParams[self::HEIGHT] = $targetHeight; $currentConversionParams[self::AUDIO_CHANNELS] = $audioChannels; $currentConversionParams[self::AUDIO_SAMPLE_RATE] = $audioSampleRate; - $currentConversionParams[self::VIDEO_DURATION] = $mediaInfoObj->getVideoDuration(); $currentConversionParams[self::AUDIO_DURATION] = $mediaInfoObj->getAudioDuration(); - $shouldResize = $this->shouldResize($mediaInfoObj, $width, $height); - if($shouldResize) + if($mediaInfoObj->getVideoWidth() < $mediaInfoObj->getVideoHeight()) { - $currentConversionParams[self::WIDTH] = $width; // trigger resize - if($mediaInfoObj->getVideoWidth() < $mediaInfoObj->getVideoHeight()) - { - $currentConversionParams[self::INVERTED_SOURCE] = true; - } - } - if($imageToVideo) - { - $currentConversionParams[self::IMAGE_TO_VIDEO] = $imageToVideo; + $currentConversionParams[self::INVERTED_SOURCE] = true; + $currentConversionParams[self::WIDTH] = $targetWidth; } - else if($mediaInfoObj->getAudioDuration() && abs($mediaInfoObj->getAudioDuration() - $mediaInfoObj->getVideoDuration()) > self::AUDIO_VIDEO_DIFF_MS) + + $croppingMode = $crop && isset($resourceData[self::CROP_DATA_ARRAY]) && count($resourceData[self::CROP_DATA_ARRAY]) > 0; + if($croppingMode) { + $currentConversionParams[self::WIDTH] = $targetWidth; + $currentConversionParams[self::CROP_DATA_ARRAY] = $resourceData[self::CROP_DATA_ARRAY]; + $outHeight = $resourceData[self::CROP_DATA_ARRAY][0]["outHeight"]; + $outWidth = $resourceData[self::CROP_DATA_ARRAY][0]["outWidth"]; + $shouldResize = $outHeight != $targetHeight || $outWidth != $targetWidth; if($shouldResize) { - $currentConversionParams[self::EXTRA_CONVERSION_PARAMS] = " -filter_complex 'aresample=async=1:min_hard_comp=0.100000:first_pts=0' "; + // resize after cropping + $currentConversionParams[self::EXTRA_CONVERSION_PARAMS] = $this->getPaddedResizeCommand($outHeight, $targetHeight, $outWidth, $targetWidth); } - else + } + else + { + if($this->shouldResizeNoCropping($mediaInfoObj, $targetWidth, $targetHeight)) { - // if we do not scale the clipped asset, then add stream mapping, because applying only audio filter_complex, changes the streams order and concat fails - $currentConversionParams[self::EXTRA_CONVERSION_PARAMS] = " -filter_complex 'aresample=async=1:min_hard_comp=0.100000:first_pts=0[a]' -map v -map [\"a\"] "; + $currentConversionParams[self::WIDTH] = $targetWidth; // trigger resize } } + + $audioVideoDurationDiff = $mediaInfoObj->getAudioDuration() ? abs($mediaInfoObj->getAudioDuration() - $mediaInfoObj->getVideoDuration()) : 0; + if($audioVideoDurationDiff > self::AUDIO_VIDEO_DIFF_MS) + { + $prevParams = $currentConversionParams[self::EXTRA_CONVERSION_PARAMS] ? $currentConversionParams[self::EXTRA_CONVERSION_PARAMS] : ""; + $currentConversionParams[self::EXTRA_CONVERSION_PARAMS] = $prevParams . $this->getSilentAudioPaddingCommand($shouldResize); + } + if(isset($resourceData[self::SUBTITLES_DATA_ARRAY])) + { + $currentConversionParams[self::SUBTITLES_DATA_ARRAY] = $resourceData[self::SUBTITLES_DATA_ARRAY]; + } + if($imageToVideo) + { + $currentConversionParams[self::IMAGE_TO_VIDEO] = $imageToVideo; + } $resourcesData[$key][self::CONVERSION_PARAMS] = json_encode($currentConversionParams, true); + $entryId = $resourceData[self::SOURCE_ENTRY] ? $resourceData[self::SOURCE_ENTRY]->getId() : null; + KalturaLog::log("[$targetWidth X $targetHeight] conversion params for resource entry Id $entryId: " . $resourcesData[$key][self::CONVERSION_PARAMS]); + } + } + + protected function getSilentAudioPaddingCommand($shouldResize) + { + if($shouldResize) + { + return " -filter_complex 'aresample=async=1:min_hard_comp=0.100000:first_pts=0' "; + } + else + { + // if we do not scale the clipped asset, then add stream mapping, because applying only audio filter_complex, changes the streams order and concat fails + return " -filter_complex 'aresample=async=1:min_hard_comp=0.100000:first_pts=0[a]' -map v -map [\"a\"] "; } } - protected function shouldResize($inputMediaInfo, $outputWidth, $outputHeight) + protected function getPaddedResizeCommand($ih, $oh, $iw, $ow) { - $inputWidth = $inputMediaInfo->getVideoWidth(); - $inputHeight = $inputMediaInfo->getVideoHeight(); + return " -filter_complex '[0:v]scale=$iw*sar*min($ow/($iw*sar)\,$oh/$ih):$ih*min($ow/($iw*sar)\,$oh/$ih)[vflt0];[vflt0]pad=$ow:$oh:($ow-$iw)/2:($oh-$ih)/2' "; + } - $inputRatio = $inputWidth / $inputHeight; - $outputRatio = $outputWidth / $outputHeight; + protected function shouldResizeNoCropping($inputMediaInfo, $outputWidth, $outputHeight) + { + $inputWidth = $inputMediaInfo->getVideoWidth(); + $inputHeight = $inputMediaInfo->getVideoHeight(); - if($inputRatio != $outputRatio || $inputWidth < $inputHeight) - { - return true; - } - return false; + $inputRatio = $inputWidth / $inputHeight; + $outputRatio = $outputWidth / $outputHeight; + + return $inputRatio != $outputRatio; } protected function decideResolution($conversionProfileId, $aspectRatio, &$width, &$height) @@ -833,18 +1001,12 @@ protected function adjustResolutionByAspectRatios($aspectRatio, &$width, &$heigh } } - protected function decideAspectRatio($inputARs, $decidedAspectRatio) + protected function decideAspectRatio($inputARs) { if(count($inputARs) == 0) { throw new KalturaAPIException(KalturaErrors::INCOMPATIBLE_RESOURCES_DIMENSIONS); } - - // TODO should be int ? - if($decidedAspectRatio != ClipAspectRatio::AUTO) - { - return $decidedAspectRatio; - } $maxDurationAspectRatio = max($inputARs); return array_search($maxDurationAspectRatio, $inputARs); } @@ -907,7 +1069,7 @@ protected function addClipJobs($parentJob , $entryId, &$errDescription, $partner $conversionData = $this->getJobDataConversionParams($parentJob->getData()); /* @var $singleAttribute kClipAttributes */ - foreach($operationAttributes as $singleAttribute) + foreach($operationAttributes as $index => $singleAttribute) { KalturaLog::info("Going To create Flavor for entry Id [$entryId] for clip: " . print_r($singleAttribute, true)); if($singleAttribute->getDuration() <= 0) @@ -916,7 +1078,7 @@ protected function addClipJobs($parentJob , $entryId, &$errDescription, $partner continue; } - $clonedID = $this->cloneFlavorParam($singleAttribute, $originalConversionEnginesExtraParams, $encryptionKey, $isAudio, $conversionData); + $clonedID = $this->cloneFlavorParam($singleAttribute, $index, $originalConversionEnginesExtraParams, $encryptionKey, $isAudio, $conversionData); $flavorAsset = $this->createTempClipFlavorAsset($partnerId, $entryId, $clonedID, $order); $flavorAsset->setActualSourceAssetParamsIds($asset->getId()); @@ -1460,7 +1622,7 @@ protected function editConversionEngineExtraParam($conversionEngines, $singleAtt * @param array $conversionData * @throws KalturaAPIException */ - protected function fixConversionParam($flavorParamsObj, $singleAttribute, $originalConversionEnginesExtraParams, $isAudio, $conversionData = null) + protected function fixConversionParam($flavorParamsObj, $singleAttribute, $singleAttributeIndex, $originalConversionEnginesExtraParams, $isAudio, $conversionData = null) { $extraParams = ''; if($conversionData) @@ -1479,39 +1641,69 @@ protected function fixConversionParam($flavorParamsObj, $singleAttribute, $origi $allowEffects = !$conversionData || (!isset($conversionData[self::IMAGE_TO_VIDEO]) && !isset($conversionData[self::WIDTH])); $newExtraConversionParams = $this->editConversionEngineExtraParam($conversionEngines, $singleAttribute, $conversionExtraParams, $isAudio, $extraParams, $allowEffects); $flavorParamsObj->setConversionEnginesExtraParams($newExtraConversionParams); - $flavorParamsObj->setSubtitlesData(json_encode(array("action" => "render", "filename" => "/opt/kaltura/app/example.srt", "force_style" => array("Alignment" => 1, "FontSize" => 20,"MarginL" => 65), "language" => "English"))); - $flavorParamsObj->setSubtitlesData(json_encode(array("action" => "render", "force_style" => array("Alignment" => 1, "FontSize" => 20,"MarginL" => 65), "language" => "English", "filename" => "/opt/kaltura/app/example.srt"))); if($conversionData && $flavorParamsObj instanceof flavorParams) { - $this->editConversionParams($flavorParamsObj, $conversionData); + $this->editConversionParams($flavorParamsObj, $conversionData, $singleAttributeIndex); } } /** * @throws KalturaAPIException */ - protected function editConversionParams(&$flavorParamsObj, $conversionParams) + protected function editConversionParams(&$flavorParamsObj, $conversionParams, $index) { if($conversionParams) { $flavorParamsObj->setForceFrameToMultiplication16(0); - $flavorParamsObj->setSubtitlesData(json_encode('{"action": "render", "force_style": {"Alignment":1,"FontSize":20,"MarginL":65}}')); + $flavorParamsObj->setIsAvoidVideoShrinkFramesizeToSource(1); $flavorParamsObj->setHeight($conversionParams[self::HEIGHT]); - if(isset($conversionParams[self::FRAME_RATE])) + + $invertedResource = isset($conversionParams[self::INVERTED_SOURCE]) && $conversionParams[self::INVERTED_SOURCE]; + $cropped = false; + $croppingMode = isset($conversionParams[self::CROP_DATA_ARRAY]) && isset($conversionParams[self::CROP_DATA_ARRAY][$index]); + if($croppingMode) { - $flavorParamsObj->setFrameRate($conversionParams[self::FRAME_RATE]); + $cropData = $conversionParams[self::CROP_DATA_ARRAY][$index]; + $cropped = is_array($cropData) && count($cropData) > 0; + } + + if($cropped) + { + // crop + $processingMode = $invertedResource ? 8 : 7; + $flavorParamsObj->setAspectRatioProcessingMode($processingMode); + $flavorParamsObj->setCropData(json_encode($cropData)); + } + else + { + if($invertedResource) + { + // for inverted source calculation, the output flavor is inverted + // _arProcessingMode = 6, inverts back the output flavor + $flavorParamsObj->setAspectRatioProcessingMode(6); + } + else if(isset($conversionParams[self::WIDTH])) + { + // resize + $flavorParamsObj->setAspectRatioProcessingMode(2); + } } if(isset($conversionParams[self::WIDTH])) { $flavorParamsObj->setWidth($conversionParams[self::WIDTH]); - $flavorParamsObj->setAspectRatioProcessingMode(2); - $flavorParamsObj->setIsAvoidVideoShrinkFramesizeToSource(1); } - if(isset($conversionParams[self::INVERTED_SOURCE]) && $conversionParams[self::INVERTED_SOURCE]) + + if(isset($conversionParams[self::FRAME_RATE])) { - // for inverted source calculation, the output flavor is inverted - // _arProcessingMode = 6, inverts back the output flavor - $flavorParamsObj->setAspectRatioProcessingMode(6); + $flavorParamsObj->setFrameRate($conversionParams[self::FRAME_RATE]); + } + if(isset($conversionParams[self::SUBTITLES_DATA_ARRAY]) && isset($conversionParams[self::SUBTITLES_DATA_ARRAY][$index])) + { + $subtitlesData = $conversionParams[self::SUBTITLES_DATA_ARRAY][$index]; + if(is_array($subtitlesData) && count($subtitlesData) > 0) + { + $flavorParamsObj->setSubtitlesData(json_encode($subtitlesData)); + } } if(isset($conversionParams[self::AUDIO_CHANNELS])) { @@ -1531,6 +1723,8 @@ protected function resetFlavorParamsObject(&$flavorParamsObj) { $flavorParamsObj->setAspectRatioProcessingMode(0); $flavorParamsObj->setIsAvoidVideoShrinkFramesizeToSource(0); + $flavorParamsObj->setSubtitlesData(null); + $flavorParamsObj->setCropData(null); /** @var flavorParams $flavorParamsObj*/ if($flavorParamsObj->getColumnsOldValue(assetParamsPeer::FRAME_RATE)) diff --git a/alpha/apps/kaltura/modules/system/actions/flavorParamsAction.class.php b/alpha/apps/kaltura/modules/system/actions/flavorParamsAction.class.php index 4918ee0d384..41631600b84 100644 --- a/alpha/apps/kaltura/modules/system/actions/flavorParamsAction.class.php +++ b/alpha/apps/kaltura/modules/system/actions/flavorParamsAction.class.php @@ -50,6 +50,7 @@ public function execute() $newFalvorParams->setMaxFrameRate($this->editFlavorParam->getMaxFrameRate()); $newFalvorParams->setWatermarkData($this->editFlavorParam->getWatermarkData()); $newFalvorParams->setSubtitlesData($this->editFlavorParam->getSubtitlesData()); + $newFalvorParams->setCropData($this->editFlavorParam->getCropData()); $newFalvorParams->setIsDefault(false); $newFalvorParams->setPartnerId(-1); $newFalvorParams->save(); diff --git a/alpha/lib/data/resource/kOperationResources.php b/alpha/lib/data/resource/kOperationResources.php index 4aa41d54657..80d6824d9f8 100644 --- a/alpha/lib/data/resource/kOperationResources.php +++ b/alpha/lib/data/resource/kOperationResources.php @@ -17,16 +17,16 @@ class kOperationResources extends kContentResource private $chapterNamePolicy; /** - * @var KalturaClipAspectRatio + * @var KalturaCropAspectRatio */ - private $aspectRatio; + private $cropAspectRatio; /** - * @return KalturaClipAspectRatio + * @return KalturaCropAspectRatio */ - public function getAspectRatio() + public function getCropAspectRatio() { - return $this->aspectRatio; + return $this->cropAspectRatio; } /** @@ -62,10 +62,10 @@ public function setChapterNamePolicy($chapterNamePolicy) } /** - * @param KalturaClipAspectRatio $aspectRatio + * @param KalturaCropAspectRatio $cropAspectRatio */ - public function setAspectRatio($aspectRatio) + public function setCropAspectRatio($cropAspectRatio) { - $this->aspectRatio = $aspectRatio; + $this->cropAspectRatio = $cropAspectRatio; } } diff --git a/alpha/lib/data/resource/operations/kBorderStyle.php b/alpha/lib/data/resource/operations/kBorderStyle.php new file mode 100644 index 00000000000..23ff947c19a --- /dev/null +++ b/alpha/lib/data/resource/operations/kBorderStyle.php @@ -0,0 +1,10 @@ +fontSize; - } - - /** - * @param $fontSize int - */ - public function setFontSize($fontSize) - { - $this->fontSize = $fontSize; - } - - /** - * @return int - */ - public function getAlignment() - { - return $this->alignment; - } - - /** - * @param int $alignment - */ - public function setAlignment($alignment) - { - $this->alignment = $alignment; - } -} diff --git a/alpha/lib/data/resource/operations/kCaptionsAlignment.php b/alpha/lib/data/resource/operations/kCaptionsAlignment.php new file mode 100644 index 00000000000..1849ed1742a --- /dev/null +++ b/alpha/lib/data/resource/operations/kCaptionsAlignment.php @@ -0,0 +1,17 @@ +action; + } + + /** + * @param string $action + */ + public function setAction($action) + { + $this->action = $action; + } + + /** + * @return string + */ + public function getFontName() + { + return $this->fontName; + } + + /** + * @param $fontName string + */ + public function setFontName($fontName) + { + $this->fontName = $fontName; + } + + /** + * @return int + */ + public function getFontSize() + { + return $this->fontSize; + } + + /** + * @param $fontSize int + */ + public function setFontSize($fontSize) + { + $this->fontSize = $fontSize; + } + + /** + * @return string + */ + public function getFontStyle() + { + return $this->fontStyle; + } + + /** + * @param $fontStyle string + */ + public function setFontStyle($fontStyle) + { + $this->fontStyle = $fontStyle; + } + + /** + * @return string + */ + public function getPrimaryColour() + { + return $this->primaryColour; + } + + /** + * @param $primaryColour string + */ + public function setPrimaryColour($primaryColour) + { + $this->primaryColour = $primaryColour; + } + + /** + * @return kBorderStyle + */ + public function getBorderStyle() + { + return $this->borderStyle; + } + + /** + * @param $borderStyle kBorderStyle + */ + public function setBorderStyle($borderStyle) + { + $this->borderStyle = $borderStyle; + } + + /** + * @return string + */ + public function getBackColour() + { + return $this->backColour; + } + + /** + * @param $backColour string + */ + public function setBackColour($backColour) + { + $this->backColour = $backColour; + } + + /** + * @return string + */ + public function getOutlineColour() + { + return $this->outlineColour; + } + + /** + * @param $outlineColour string + */ + public function setOutlineColour($outlineColour) + { + $this->outlineColour = $outlineColour; + } + + /** + * @return int + */ + public function getShadow() + { + return $this->shadow; + } + + /** + * @param $shadow string + */ + public function setShadow($shadow) + { + $this->shadow = $shadow; + } + + /** + * @return boolean + */ + public function getBold() + { + return $this->bold; + } + + /** + * @param $bold boolean + */ + public function setBold($bold) + { + $this->bold = $bold; + } + + /** + * @return boolean + */ + public function getItalic() + { + return $this->italic; + } + + /** + * @param $italic boolean + */ + public function setItalic($italic) + { + $this->italic = $italic; + } + + /** + * @return boolean + */ + public function getUnderline() + { + return $this->underline; + } + + /** + * @param $underline boolean + */ + public function setUnderline($underline) + { + $this->underline = $underline; + } + + /** + * @return kCaptionsAlignment + */ + public function getAlignment() + { + return $this->alignment; + } + + /** + * @param kCaptionsAlignment $alignment + */ + public function setAlignment($alignment) + { + $this->alignment = $alignment; + } + + /** + * @return string + */ + public function getCaptionAssetId() + { + return $this->captionAssetId; + } + + /** + * @param string $captionAssetId + */ + public function setCaptionAssetId($captionAssetId) + { + $this->captionAssetId = $captionAssetId; + } + + /** + * @return string + */ + public function getCaptionFileUrl() + { + return $this->captionFileUrl; + } + + /** + * @param string $captionFileUrl + */ + public function setCaptionFileUrl($captionFileUrl) + { + $this->captionFileUrl = $captionFileUrl; + } +} diff --git a/alpha/lib/data/resource/operations/kClipAttributes.php b/alpha/lib/data/resource/operations/kClipAttributes.php index a83a4c54eb4..878f4e1072c 100644 --- a/alpha/lib/data/resource/operations/kClipAttributes.php +++ b/alpha/lib/data/resource/operations/kClipAttributes.php @@ -33,11 +33,10 @@ class kClipAttributes extends kOperationAttributes */ private $effectArray; - /** - * @var kBurnCaptions + * @var kCaptionsOptions */ - private $burnCaptions; + private $captionsOptions; /** * @var int @@ -56,7 +55,7 @@ public function toArray() 'globalOffsetInDestination' => $this->globalOffsetInDestination, 'effectArray' => $this->effectArray, 'cropAlignment' => $this->cropAlignment, - 'burnCaptions' => $this->burnCaptions + 'captionsOptions' => $this->captionsOptions ); } @@ -165,18 +164,18 @@ public function setCropAlignment($cropAlignment) } /** - * @return kBurnCaptions + * @return kCaptionsOptions */ - public function getBurnCaptions() + public function getCaptionsOptions() { - return $this->burnCaptions; + return $this->captionsOptions; } /** - * @param kBurnCaptions $burnCaptions + * @param kCaptionsOptions $captionsOptions */ - public function setBurnCaptions($burnCaptions) + public function setCaptionsOptions($captionsOptions) { - return $this->burnCaptions = $burnCaptions; + return $this->captionsOptions = $captionsOptions; } } diff --git a/alpha/lib/data/resource/operations/kCropAspectRatio.php b/alpha/lib/data/resource/operations/kCropAspectRatio.php new file mode 100644 index 00000000000..d415d0b43f0 --- /dev/null +++ b/alpha/lib/data/resource/operations/kCropAspectRatio.php @@ -0,0 +1,49 @@ +crop; + } + + /** + * @param bool $crop + */ + public function setCrop($crop) + { + $this->crop = $crop; + } + + /** + * @return float + */ + public function getAspectRatio() + { + return $this->aspectRatio; + } + + /** + * @param float $aspectRatio + */ + public function setAspectRatio($aspectRatio) + { + $this->aspectRatio = $aspectRatio; + } +} diff --git a/alpha/lib/enums/ClipAspectRatio.php b/alpha/lib/enums/ClipAspectRatio.php deleted file mode 100644 index be2071e18f8..00000000000 --- a/alpha/lib/enums/ClipAspectRatio.php +++ /dev/null @@ -1,9 +0,0 @@ -getFromCustomData('WatermarkDat public function setSubtitlesData($v){ $this->putInCustomData('SubtitlesData', $v);} public function getSubtitlesData(){return $this->getFromCustomData('SubtitlesData', null, null);} + public function setCropData($v){ $this->putInCustomData('CropData', $v);} + public function getCropData(){return $this->getFromCustomData('CropData', null, null);} + public function setIsEncrypted($v){ $this->putInCustomData('IsEncrypted', $v);} public function getIsEncrypted(){return $this->getFromCustomData('IsEncrypted', null, 0);} diff --git a/alpha/lib/model/flavorParamsOutput.php b/alpha/lib/model/flavorParamsOutput.php index 236696b4a45..d5a4f58d39f 100644 --- a/alpha/lib/model/flavorParamsOutput.php +++ b/alpha/lib/model/flavorParamsOutput.php @@ -81,6 +81,9 @@ public function getWatermarkData(){return $this->getFromCustomData('WatermarkDat public function setSubtitlesData($v){ $this->putInCustomData('SubtitlesData', $v);} public function getSubtitlesData(){return $this->getFromCustomData('SubtitlesData', null, null);} + public function setCropData($v){ $this->putInCustomData('CropData', $v);} + public function getCropData(){return $this->getFromCustomData('CropData', null, null);} + public function setContentAwareness($v){ $this->putInCustomData('ContentAwareness', $v);} public function getContentAwareness(){return $this->getFromCustomData('ContentAwareness', null, null);} diff --git a/api_v3/lib/KalturaEntryService.php b/api_v3/lib/KalturaEntryService.php index ecd96a729b3..fcc4f45fbf6 100644 --- a/api_v3/lib/KalturaEntryService.php +++ b/api_v3/lib/KalturaEntryService.php @@ -1868,7 +1868,7 @@ protected function listFlagsForEntry($entryId, KalturaFilterPager $pager = null) return $response; } - protected function anonymousRankEntry($entryId, $entryType = null, $rank) + protected function anonymousRankEntry($entryId, $entryType, $rank) { $dbEntry = entryPeer::retrieveByPK($entryId); if (!$dbEntry || ($entryType !== null && $dbEntry->getType() != $entryType)) @@ -1930,7 +1930,7 @@ protected function handleMultiResourceMultiClipRequest($resources, entry $destEn $sourceEntryIds = array(); $tempEntryIds = array(); - $resourcesData = array(); + $entryResourcesData = array(); // for each resource: 1.set sourceEntryId on resource 2.create temp entry for clip 3. retrieve media info object foreach ($resources->getResources() as $ind => $resource) @@ -1945,10 +1945,13 @@ protected function handleMultiResourceMultiClipRequest($resources, entry $destEn $tempEntryIds[] = $tempEntry->getId(); $duration = 0; + $operationAttributesArray = array(); foreach ($resource->getOperationAttributes() as $operationAttribute) { /* @var $operationAttribute kClipAttributes **/ $duration += $operationAttribute->getDuration(); + $this->setCaptionAssetsUrls($operationAttribute); + $operationAttributesArray[] = $operationAttribute; } if($sourceEntry->getMediaType() == KalturaMediaType::IMAGE) @@ -1981,25 +1984,24 @@ protected function handleMultiResourceMultiClipRequest($resources, entry $destEn throw new APIException(KalturaErrors::MEDIA_INFO_NOT_FOUND, $objectId); } - $resourcesData[] = array( -// kClipManager::ASPECT_RATIO => $resources->getAspectRatio(), + $entryResourcesData[] = array( + kClipManager::OPERATION_ATTRIBUTES_ARRAY => $operationAttributesArray, kClipManager::SOURCE_ENTRY => $sourceEntry, kClipManager::TEMP_ENTRY => $tempEntry, kClipManager::MEDIA_INFO_OBJECT => $mediaInfoObj, - kClipManager::VIDEO_DURATION => $duration, + kClipManager::CLIPS_DURATION => $duration, kClipManager::IMAGE_TO_VIDEO => $imageToVideo ); - } - $clipManager->calculateAndEditConversionParams($resourcesData, $resources->getAspectRatio(), $destEntry->getConversionProfileId()); + $clipManager->calculateAndEditConversionParams($entryResourcesData, $resources, $destEntry->getConversionProfileId()); $multiTempEntry = $clipManager->createTempEntryForClip($this->getPartnerId(), 'MULTI_TEMP_'); $clipManager->addMultiClipTrackEntries($sourceEntryIds, $tempEntryIds, $multiTempEntry->getId(), $destEntry->getId()); $rootJob = $clipManager->startMultiClipConcatBatchJob($resources, $destEntry, $multiTempEntry); foreach ($resources->getResources() as $key => $resource) { - $tempEntry = $resourcesData[$key][kClipManager::TEMP_ENTRY]; - $conversionParams = $resourcesData[$key][kClipManager::CONVERSION_PARAMS]; + $tempEntry = $entryResourcesData[$key][kClipManager::TEMP_ENTRY]; + $conversionParams = $entryResourcesData[$key][kClipManager::CONVERSION_PARAMS]; $this->handleMultiClipRequest($resource, $destEntry, $clipManager, $tempEntry, $rootJob->getId(), $key, $conversionParams); } $destEntry->setStatus(entryStatus::PENDING); @@ -2007,6 +2009,28 @@ protected function handleMultiResourceMultiClipRequest($resources, entry $destEn kJobsManager::updateBatchJob($rootJob, BatchJob::BATCHJOB_STATUS_ALMOST_DONE); } + protected function setCaptionAssetsUrls(&$operationAttribute) + { + $captionsOptions = $operationAttribute->getCaptionsOptions(); + if(!$captionsOptions || !$captionsOptions->getCaptionAssetId()) + { + return; + } + + $captionAssetId = $captionsOptions->getCaptionAssetId(); + $captionAsset = assetPeer::retrieveById($captionAssetId); + if (!($captionAsset instanceof CaptionAsset)) + { + throw new KalturaAPIException(KalturaCaptionErrors::CAPTION_ASSET_ID_NOT_FOUND, $captionAssetId); + } + if ($captionAsset->getStatus() != asset::ASSET_STATUS_READY) + { + throw new KalturaAPIException(KalturaCaptionErrors::CAPTION_ASSET_IS_NOT_READY); + } + $captionsOptions->setCaptionFileUrl($captionAsset->getDownloadUrl(true)); + $operationAttribute->setCaptionsOptions($captionsOptions); + } + /*** * @param kContentResource $resourceObj * @throws APIException diff --git a/api_v3/lib/KalturaErrors.php b/api_v3/lib/KalturaErrors.php index f1ef59ef12f..2b1a238b814 100644 --- a/api_v3/lib/KalturaErrors.php +++ b/api_v3/lib/KalturaErrors.php @@ -51,6 +51,8 @@ class KalturaErrors extends APIErrors // PARAM_NAME - parameter name const MISSING_MANDATORY_PARAMETER = "MISSING_MANDATORY_PARAMETER;PARAM_NAME;Missing parameter \"@PARAM_NAME@\""; + const INVALID_PARAMETER_VALUE = "INVALID_PARAMETER_VALUE;PARAM_NAME;invalid value for parameter \"@PARAM_NAME@\""; + const PARAMETER_OUT_OF_RANGE = "PARAMETER_OUT_OF_RANGE;PARAM_NAME,MIN,MAX;Parameter \"@PARAM_NAME@\" if out of range (@MIN@ - @MAX@)"; // INVALID_OBJ_TYPE - invalid object type const INVALID_OBJECT_TYPE = "INVALID_OBJECT_TYPE;INVALID_OBJ_TYPE;Invalid object type \"@INVALID_OBJ_TYPE@\""; diff --git a/api_v3/lib/types/batch/KalturaMultiClipConcatJobData.php b/api_v3/lib/types/batch/KalturaMultiClipConcatJobData.php index c84f6625c4a..9a4ec34424b 100644 --- a/api_v3/lib/types/batch/KalturaMultiClipConcatJobData.php +++ b/api_v3/lib/types/batch/KalturaMultiClipConcatJobData.php @@ -32,7 +32,7 @@ class KalturaMultiClipConcatJobData extends KalturaJobData public $chapterNamePolicy; /** - * @var KalturaClipAspectRatio + * @var KalturaCropAspectRatio */ public $aspectRatio; diff --git a/api_v3/lib/types/enums/KalturaClipAspectRatio.php b/api_v3/lib/types/enums/KalturaClipAspectRatio.php deleted file mode 100644 index 08b46f01187..00000000000 --- a/api_v3/lib/types/enums/KalturaClipAspectRatio.php +++ /dev/null @@ -1,8 +0,0 @@ -validateCropAspectRatio(); + $overallDuration = 0; foreach ($this->resources as $resource) { if(!($resource instanceof KalturaOperationResource)) @@ -98,6 +97,22 @@ public function validateForUsage($sourceObject, $propertiesToSkip = array()) } } + protected function validateCropAspectRatio() + { + $cropAspectRatio = $this->cropAspectRatio; + if($cropAspectRatio) + { + if(!$cropAspectRatio->aspectRatio) + { + throw new KalturaAPIException(KalturaErrors::MISSING_MANDATORY_PARAMETER, "aspectRatio"); + } + if($cropAspectRatio->aspectRatio <= 0) + { + throw new KalturaAPIException(KalturaErrors::INVALID_PARAMETER_VALUE, "aspectRatio"); + } + } + } + /* (non-PHPdoc) * @see KalturaResource::entryHandled() */ diff --git a/api_v3/lib/types/resource/operations/KalturaBorderStyle.php b/api_v3/lib/types/resource/operations/KalturaBorderStyle.php new file mode 100644 index 00000000000..5a7ed37dbdb --- /dev/null +++ b/api_v3/lib/types/resource/operations/KalturaBorderStyle.php @@ -0,0 +1,9 @@ +cropAlignment; + if ($cropAlignment && ($cropAlignment > $maxCropAlignment || $cropAlignment < $minCropAlignment)) + { + throw new KalturaAPIException(KalturaErrors::PARAMETER_OUT_OF_RANGE, 'cropAlignment', $minCropAlignment, $maxCropAlignment); + } + + $captionsOptions = $this->captionsOptions; + if($captionsOptions instanceof KalturaCaptionsOptions) + { + if(is_null($captionsOptions->action)) + { + throw new KalturaAPIException(KalturaErrors::MISSING_MANDATORY_PARAMETER, "action"); + } + if(!$captionsOptions->captionAssetId) + { + throw new KalturaAPIException(KalturaErrors::MISSING_MANDATORY_PARAMETER, "captionAssetId"); + } + $this->validateColorFormat($captionsOptions->primaryColour, "primaryColour"); + $this->validateColorFormat($captionsOptions->outlineColour, "outlineColour"); + $this->validateColorFormat($captionsOptions->backColour, "backColour"); + } + } + + protected function validateColorFormat($color, $paramName) + { + if($color && !preg_match('/^\&[H|h]([0-9]|[A-F]|[a-f]){6}\&$/', $color)) + { + throw new KalturaAPIException(KalturaErrors::INVALID_PARAMETER_VALUE, $paramName); + } + } + public function toObject ( $object_to_fill = null , $props_to_skip = array() ) { if(is_null($object_to_fill)) diff --git a/api_v3/lib/types/resource/operations/KalturaCropAspectRatio.php b/api_v3/lib/types/resource/operations/KalturaCropAspectRatio.php new file mode 100644 index 00000000000..702ca6f2365 --- /dev/null +++ b/api_v3/lib/types/resource/operations/KalturaCropAspectRatio.php @@ -0,0 +1,35 @@ +language ? $subtitlesData->language : "default"; + $tmpCaptionFilePath = $data->destFileSyncLocalPath.".temp.$language.srt"; + if(isset(KBatchBase::$taskConfig->params->sharedTempPath)) + { + $tmpCaptionFilePath = KBatchBase::$taskConfig->params->sharedTempPath . "/" . basename($tmpCaptionFilePath); } + $captionFilePath = null; - foreach($captionsArr as $lang=>$captionFileUrl){ - if($subtitlesData->language==$lang){ - KalturaLog::log("Found required language($lang)"); - $tmpCaptionFilePath = $data->destFileSyncLocalPath.".temp.$lang.srt"; - if(isset(KBatchBase::$taskConfig->params->sharedTempPath)){ - $tmpCaptionFilePath = KBatchBase::$taskConfig->params->sharedTempPath . "/" . basename($tmpCaptionFilePath); + if($subtitlesData->captionFileUrl) + { + $captionFilePath = self::fetchCaptionFile($subtitlesData->captionFileUrl, $tmpCaptionFilePath); + } + else + { + $captionsArr = self::fetchEntryCaptionList($data, $jobMsg); + if(!isset($captionsArr) || count($captionsArr)==0) + { + KalturaLog::log("No captions for that entry!!!"); + $cmdLine = KDLOperatorFfmpeg::RemoveFilter($cmdLine, 'subtitles'); + return $cmdLine; + } + foreach($captionsArr as $lang=>$captionFileUrl) + { + if($subtitlesData->language==$lang) + { + KalturaLog::log("Found required language ($lang)"); + $captionFilePath = self::fetchCaptionFile($captionFileUrl, $tmpCaptionFilePath); + break; } - - $captionFilePath = self::fetchCaptionFile($captionFileUrl, $tmpCaptionFilePath); - break; } } - if(!isset($captionFilePath)){ - KalturaLog::notice("No captions for ($subtitlesData->language)"); - $cmdLine=KDLOperatorFfmpeg::RemoveFilter($cmdLine, 'subtitles'); + + if(!$captionFilePath) + { + KalturaLog::notice("No captions for subtitlesData: ".json_encode($subtitlesData)); + $cmdLine = KDLOperatorFfmpeg::RemoveFilter($cmdLine, 'subtitles'); return $cmdLine; } $cmdLine = str_replace(KDLCmdlinePlaceholders::SubTitlesFileName, $captionFilePath, $cmdLine); diff --git a/infra/cdl/kdl/KDLMediaObjectData.php b/infra/cdl/kdl/KDLMediaObjectData.php index ee03f41ebb9..b22c99bfc5d 100644 --- a/infra/cdl/kdl/KDLMediaObjectData.php +++ b/infra/cdl/kdl/KDLMediaObjectData.php @@ -213,6 +213,8 @@ class KDLVideoData extends KDLBaseMediaData { * 3: force 16/9 for everything that is not 16:9 * 4: force '-aspect' option * 5: force perciese source AR + * 6: force perciese source AR + * 7: cropping */ public $_forceMult16 = 1; public $_cbr=0; // Constant bit rate, when set - -b 50M -minrate 50M -maxrate 50M -bt 5M -bufsize 10M @@ -228,6 +230,7 @@ class KDLVideoData extends KDLBaseMediaData { public $_maxFrameRate=0; public $_watermarkData; public $_subtitlesData = null; + public $_cropData = null; public $_complexityValue = null; public $_contentAwareness = null; diff --git a/infra/cdl/kdl/KDLOperatorFfmpeg0_10.php b/infra/cdl/kdl/KDLOperatorFfmpeg0_10.php index e4c396e03dc..1919c54d34d 100644 --- a/infra/cdl/kdl/KDLOperatorFfmpeg0_10.php +++ b/infra/cdl/kdl/KDLOperatorFfmpeg0_10.php @@ -14,7 +14,7 @@ public function GenerateCommandLine(KDLFlavor $design, KDLFlavor $target, $extra $cmdStr = $this->processTwoPass($target, $cmdStr); return $cmdStr; } - + /* --------------------------- * generateSinglePassCommandLine */ @@ -130,6 +130,20 @@ protected static function generateVideoFilters($vid) break; } } + + // cropping + if(isset($vid->_arProcessingMode) && ($vid->_arProcessingMode==7 || $vid->_arProcessingMode==8)) + { + if(isset($vid->_cropData) && $vid->_cropData->outWidth && $vid->_cropData->outHeight) + { + $outWidth = $vid->_cropData->outWidth; + $outHeight = $vid->_cropData->outHeight; + $widthPosition = isset($vid->_cropData->widthPosition) ? $vid->_cropData->widthPosition : 0; + $heightPosition = isset($vid->_cropData->heightPosition) ? $vid->_cropData->heightPosition : 0; + $filters[] = "crop=$outWidth:$outHeight:$widthPosition:$heightPosition"; + } + } + // Letterboxing if(isset($vid->_arProcessingMode) && $vid->_arProcessingMode==2){ $str ='scale=iw*sar*min('.$vid->_width.'/(iw*sar)\,'; diff --git a/infra/cdl/kdl/KDLOperatorFfmpeg2_2.php b/infra/cdl/kdl/KDLOperatorFfmpeg2_2.php index ccb9f17030c..dd585321803 100644 --- a/infra/cdl/kdl/KDLOperatorFfmpeg2_2.php +++ b/infra/cdl/kdl/KDLOperatorFfmpeg2_2.php @@ -41,7 +41,7 @@ protected function generateVideoParams(KDLFlavor $design, KDLFlavor $target) } } // 9:16 to 16:9 - if($vid->_arProcessingMode==6){ + if($vid->_arProcessingMode==6 || $vid->_arProcessingMode==8){ $cmdValsArr = explode(' ', $cmdStr); if(($key=array_search('-s', $cmdValsArr))!==false) { $dims = explode('x', $cmdValsArr[$key+1]); From d4f445c538ecc050b8f0ef25a0a5f7af68d28592 Mon Sep 17 00:00:00 2001 From: Salma Date: Sun, 4 Aug 2024 08:22:03 +0300 Subject: [PATCH 28/96] multi clip burn captions --- api_v3/lib/KalturaErrors.php | 2 +- api_v3/lib/types/resource/operations/KalturaClipAttributes.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api_v3/lib/KalturaErrors.php b/api_v3/lib/KalturaErrors.php index 2b1a238b814..f49272333b0 100644 --- a/api_v3/lib/KalturaErrors.php +++ b/api_v3/lib/KalturaErrors.php @@ -52,7 +52,7 @@ class KalturaErrors extends APIErrors // PARAM_NAME - parameter name const MISSING_MANDATORY_PARAMETER = "MISSING_MANDATORY_PARAMETER;PARAM_NAME;Missing parameter \"@PARAM_NAME@\""; const INVALID_PARAMETER_VALUE = "INVALID_PARAMETER_VALUE;PARAM_NAME;invalid value for parameter \"@PARAM_NAME@\""; - const PARAMETER_OUT_OF_RANGE = "PARAMETER_OUT_OF_RANGE;PARAM_NAME,MIN,MAX;Parameter \"@PARAM_NAME@\" if out of range (@MIN@ - @MAX@)"; + const PARAMETER_VALUE_OUT_OF_RANGE = "PARAMETER_VALUE_OUT_OF_RANGE;PARAM_NAME,MIN,MAX;Parameter \"@PARAM_NAME@\" value is out of range (@MIN@ - @MAX@)"; // INVALID_OBJ_TYPE - invalid object type const INVALID_OBJECT_TYPE = "INVALID_OBJECT_TYPE;INVALID_OBJ_TYPE;Invalid object type \"@INVALID_OBJ_TYPE@\""; diff --git a/api_v3/lib/types/resource/operations/KalturaClipAttributes.php b/api_v3/lib/types/resource/operations/KalturaClipAttributes.php index bff6e8ed182..2b2a94af930 100644 --- a/api_v3/lib/types/resource/operations/KalturaClipAttributes.php +++ b/api_v3/lib/types/resource/operations/KalturaClipAttributes.php @@ -68,7 +68,7 @@ public function validateForUsage($sourceObject, $propertiesToSkip = array()) $cropAlignment = $this->cropAlignment; if ($cropAlignment && ($cropAlignment > $maxCropAlignment || $cropAlignment < $minCropAlignment)) { - throw new KalturaAPIException(KalturaErrors::PARAMETER_OUT_OF_RANGE, 'cropAlignment', $minCropAlignment, $maxCropAlignment); + throw new KalturaAPIException(KalturaErrors::PARAMETER_VALUE_OUT_OF_RANGE, 'cropAlignment', $minCropAlignment, $maxCropAlignment); } $captionsOptions = $this->captionsOptions; From 90a5ed55bb1e37706ddb84870ab163fbd14767db Mon Sep 17 00:00:00 2001 From: Salma Date: Sun, 4 Aug 2024 08:27:50 +0300 Subject: [PATCH 29/96] multi clip burn captions --- .../types/resource/operations/KalturaCaptionsAction.php | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 api_v3/lib/types/resource/operations/KalturaCaptionsAction.php diff --git a/api_v3/lib/types/resource/operations/KalturaCaptionsAction.php b/api_v3/lib/types/resource/operations/KalturaCaptionsAction.php deleted file mode 100644 index a84bfdf0ba2..00000000000 --- a/api_v3/lib/types/resource/operations/KalturaCaptionsAction.php +++ /dev/null @@ -1,9 +0,0 @@ - Date: Sun, 4 Aug 2024 08:31:11 +0300 Subject: [PATCH 30/96] multi clip burn captions --- infra/cdl/kdl/KDLMediaObjectData.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infra/cdl/kdl/KDLMediaObjectData.php b/infra/cdl/kdl/KDLMediaObjectData.php index b22c99bfc5d..1b81e13b68a 100644 --- a/infra/cdl/kdl/KDLMediaObjectData.php +++ b/infra/cdl/kdl/KDLMediaObjectData.php @@ -213,8 +213,8 @@ class KDLVideoData extends KDLBaseMediaData { * 3: force 16/9 for everything that is not 16:9 * 4: force '-aspect' option * 5: force perciese source AR - * 6: force perciese source AR * 7: cropping + * 8: inverted cropping */ public $_forceMult16 = 1; public $_cbr=0; // Constant bit rate, when set - -b 50M -minrate 50M -maxrate 50M -bt 5M -bufsize 10M From 113c90f92b2256255208006f8f2b7a0807cb773a Mon Sep 17 00:00:00 2001 From: Salma Date: Tue, 6 Aug 2024 07:58:50 +0300 Subject: [PATCH 31/96] multi clip refactor --- .../kaltura/lib/clipconcat/kClipManager.php | 424 +++++++++++++----- infra/cdl/kdl/KDLMediaObjectData.php | 2 +- 2 files changed, 302 insertions(+), 124 deletions(-) diff --git a/alpha/apps/kaltura/lib/clipconcat/kClipManager.php b/alpha/apps/kaltura/lib/clipconcat/kClipManager.php index 0e0950075c9..2ca44452402 100644 --- a/alpha/apps/kaltura/lib/clipconcat/kClipManager.php +++ b/alpha/apps/kaltura/lib/clipconcat/kClipManager.php @@ -7,8 +7,10 @@ class kClipManager implements kBatchJobStatusEventConsumer { const CLIP_NUMBER = 'clipNumber'; - const HEIGHT = 'height'; - const WIDTH = 'width'; + const CROP_HEIGHT = 'cropHeight'; + const CROP_WIDTH = 'cropWidth'; + const TARGET_HEIGHT = 'targetHeight'; + const TARGET_WIDTH = 'targetWidth'; const FRAME_RATE = 'frameRate'; const AUDIO_CHANNELS = 'audioChannels'; const AUDIO_SAMPLE_RATE = 'audioSamplingRate'; @@ -725,16 +727,16 @@ public function calculateAndEditConversionParams(&$resourcesData, $resources, $c KalturaLog::debug("Multi Clip target dimensions: width [$targetWidth], height [$targetHeight], aspect ratio [$targetAspectRatio]"); - $targetConversionParams = array( + $generalConversionParams = array( self::CROP => $crop, - self::WIDTH => $targetWidth, - self::HEIGHT => $targetHeight, + self::TARGET_WIDTH => $targetWidth, + self::TARGET_HEIGHT => $targetHeight, self::AUDIO_CHANNELS => $audioChannels, self::AUDIO_SAMPLE_RATE => $audioSampleRate, self::FRAME_RATE => min($frameRate, self::MAX_FRAME_RATE) ); - $this->setConversionParamsOnResourcesData($resourcesData, $targetConversionParams); + $this->setConversionParamsOnResourcesData($resourcesData, $generalConversionParams); } protected function getCropData($targetAspectRatio, $inWidth, $inHeight, $cropAlignmentPercent = null) @@ -841,8 +843,8 @@ protected function getSubtitlesData($captionsOptions) protected function setConversionParamsOnResourcesData(&$resourcesData, $conversionParams) { - $targetWidth = $conversionParams[self::WIDTH]; - $targetHeight = $conversionParams[self::HEIGHT]; + $targetWidth = $conversionParams[self::TARGET_WIDTH]; + $targetHeight = $conversionParams[self::TARGET_HEIGHT]; $audioChannels = $conversionParams[self::AUDIO_CHANNELS]; $audioSampleRate = $conversionParams[self::AUDIO_SAMPLE_RATE]; $crop = $conversionParams[self::CROP]; @@ -853,62 +855,68 @@ protected function setConversionParamsOnResourcesData(&$resourcesData, $conversi $mediaInfoObj = $resourceData[self::MEDIA_INFO_OBJECT]; $currentConversionParams = array(); - $currentConversionParams[self::HEIGHT] = $targetHeight; + $currentConversionParams[self::TARGET_HEIGHT] = $targetHeight; $currentConversionParams[self::AUDIO_CHANNELS] = $audioChannels; $currentConversionParams[self::AUDIO_SAMPLE_RATE] = $audioSampleRate; $currentConversionParams[self::AUDIO_DURATION] = $mediaInfoObj->getAudioDuration(); - if($mediaInfoObj->getVideoWidth() < $mediaInfoObj->getVideoHeight()) + if(isset($resourceData[self::SUBTITLES_DATA_ARRAY])) { - $currentConversionParams[self::INVERTED_SOURCE] = true; - $currentConversionParams[self::WIDTH] = $targetWidth; + $currentConversionParams[self::SUBTITLES_DATA_ARRAY] = $resourceData[self::SUBTITLES_DATA_ARRAY]; } $croppingMode = $crop && isset($resourceData[self::CROP_DATA_ARRAY]) && count($resourceData[self::CROP_DATA_ARRAY]) > 0; + $currentConversionParams[self::CROP] = $croppingMode; if($croppingMode) { - $currentConversionParams[self::WIDTH] = $targetWidth; $currentConversionParams[self::CROP_DATA_ARRAY] = $resourceData[self::CROP_DATA_ARRAY]; $outHeight = $resourceData[self::CROP_DATA_ARRAY][0]["outHeight"]; $outWidth = $resourceData[self::CROP_DATA_ARRAY][0]["outWidth"]; - $shouldResize = $outHeight != $targetHeight || $outWidth != $targetWidth; - if($shouldResize) + $currentConversionParams[self::CROP_HEIGHT] = $outHeight; + $currentConversionParams[self::CROP_WIDTH] = $outWidth; + + $shouldScale = $outHeight != $targetHeight || $outWidth != $targetWidth; + if($shouldScale) { - // resize after cropping - $currentConversionParams[self::EXTRA_CONVERSION_PARAMS] = $this->getPaddedResizeCommand($outHeight, $targetHeight, $outWidth, $targetWidth); + $currentConversionParams[self::TARGET_WIDTH] = $targetWidth; } } else { - if($this->shouldResizeNoCropping($mediaInfoObj, $targetWidth, $targetHeight)) + if($this->shouldScaleNoCropping($mediaInfoObj, $targetWidth, $targetHeight)) { - $currentConversionParams[self::WIDTH] = $targetWidth; // trigger resize + $currentConversionParams[self::TARGET_WIDTH] = $targetWidth; // trigger scale } } - $audioVideoDurationDiff = $mediaInfoObj->getAudioDuration() ? abs($mediaInfoObj->getAudioDuration() - $mediaInfoObj->getVideoDuration()) : 0; - if($audioVideoDurationDiff > self::AUDIO_VIDEO_DIFF_MS) + if($mediaInfoObj->getVideoWidth() < $mediaInfoObj->getVideoHeight()) { - $prevParams = $currentConversionParams[self::EXTRA_CONVERSION_PARAMS] ? $currentConversionParams[self::EXTRA_CONVERSION_PARAMS] : ""; - $currentConversionParams[self::EXTRA_CONVERSION_PARAMS] = $prevParams . $this->getSilentAudioPaddingCommand($shouldResize); + $currentConversionParams[self::INVERTED_SOURCE] = true; + $currentConversionParams[self::TARGET_WIDTH] = $targetWidth; } - if(isset($resourceData[self::SUBTITLES_DATA_ARRAY])) + + $audioVideoDurationDiff = $mediaInfoObj->getAudioDuration() ? abs($mediaInfoObj->getAudioDuration() - $mediaInfoObj->getVideoDuration()) : 0; + if($audioVideoDurationDiff > self::AUDIO_VIDEO_DIFF_MS) { - $currentConversionParams[self::SUBTITLES_DATA_ARRAY] = $resourceData[self::SUBTITLES_DATA_ARRAY]; + $usingFilterComplex = $currentConversionParams[self::TARGET_WIDTH] || $croppingMode || $currentConversionParams[self::SUBTITLES_DATA_ARRAY]; + $currentConversionParams[self::EXTRA_CONVERSION_PARAMS] = $this->getSilentAudioPaddingCommand($usingFilterComplex); } if($imageToVideo) { $currentConversionParams[self::IMAGE_TO_VIDEO] = $imageToVideo; + if($this->shouldScaleNoCropping($mediaInfoObj, $targetWidth, $targetHeight)) + { + $currentConversionParams[self::TARGET_WIDTH] = $targetWidth; // trigger scale + } } + $resourcesData[$key][self::CONVERSION_PARAMS] = json_encode($currentConversionParams, true); - $entryId = $resourceData[self::SOURCE_ENTRY] ? $resourceData[self::SOURCE_ENTRY]->getId() : null; - KalturaLog::log("[$targetWidth X $targetHeight] conversion params for resource entry Id $entryId: " . $resourcesData[$key][self::CONVERSION_PARAMS]); } } - protected function getSilentAudioPaddingCommand($shouldResize) + protected function getSilentAudioPaddingCommand($usingFilterComplex) { - if($shouldResize) + if($usingFilterComplex) { return " -filter_complex 'aresample=async=1:min_hard_comp=0.100000:first_pts=0' "; } @@ -919,12 +927,7 @@ protected function getSilentAudioPaddingCommand($shouldResize) } } - protected function getPaddedResizeCommand($ih, $oh, $iw, $ow) - { - return " -filter_complex '[0:v]scale=$iw*sar*min($ow/($iw*sar)\,$oh/$ih):$ih*min($ow/($iw*sar)\,$oh/$ih)[vflt0];[vflt0]pad=$ow:$oh:($ow-$iw)/2:($oh-$ih)/2' "; - } - - protected function shouldResizeNoCropping($inputMediaInfo, $outputWidth, $outputHeight) + protected function shouldScaleNoCropping($inputMediaInfo, $outputWidth, $outputHeight) { $inputWidth = $inputMediaInfo->getVideoWidth(); $inputHeight = $inputMediaInfo->getVideoHeight(); @@ -1223,7 +1226,6 @@ public function createTempEntryForClip($partnerId, $namePrefix = 'TEMP_') protected function addDestinationEntryAsset($entryId, $concatAsset) { $concatSyncKey = $concatAsset->getSyncKey(flavorAsset::FILE_SYNC_ASSET_SUB_TYPE_ASSET); - $dbAsset = assetPeer::retrieveOriginalByEntryId($entryId); $dbEntry = entryPeer::retrieveByPK($entryId); $isNewAsset = false; if(!$dbEntry) @@ -1330,7 +1332,7 @@ protected function startMultiResourceConcat(BatchJob $multiClipConcatJob) foreach ($relatedFiles as $key => $relatedFile) { $allRelatedFiles[] = $relatedFile; - $convertCommands[] = $this->getConvertCommandForFile($jobData, $operationAttributesSorted[$key]); + $convertCommands[] = $this->getConvertCommandForFile($jobData, $operationAttributesSorted, $key); } KalturaLog::debug("Asset Id: [$flavorAssetId], Related file : " . print_r($relatedFiles, true)); // assume concatenated assets have the same actualFlavorParamsId and take the last @@ -1349,46 +1351,62 @@ protected function startMultiResourceConcat(BatchJob $multiClipConcatJob) } } - protected function getConvertCommandForFile($jobData, $operationAttribute) + protected function getConvertCommandForFile($jobData, $operationAttributesSorted, $clipIndex) { /** @var kClipConcatJobData $jobData */ - $effectsFilter = $this->getEffectsFilter($jobData, $operationAttribute); + $operationAttribute = $operationAttributesSorted[$clipIndex]; + $sortedFilters = $this->getSortedFiltersComplexForConcat($jobData, $operationAttributesSorted, $clipIndex); $imageToVideo = $this->getJobDataConversionParams($jobData, self::IMAGE_TO_VIDEO); if($imageToVideo) { - return $this->getConvertImageToVideoCommand($jobData, $operationAttribute, $effectsFilter); + return $this->getConvertImageToVideoCommand($jobData, $operationAttribute, $sortedFilters); } $audioDuration = $this->getJobDataConversionParams($jobData, self::AUDIO_DURATION); if(!$audioDuration) { - return $this->getAddSilentAudioCommand($jobData, $operationAttribute, $effectsFilter); + return $this->getAddSilentAudioCommand($jobData, $operationAttribute, $sortedFilters); } - if($effectsFilter) + return $this->getGeneralCommand($jobData, $sortedFilters); + } + + protected function getAspectCommand($conversionParams, $sortedFilters) + { + $cmdStr = ""; + if(isset($sortedFilters["scale"])) { - return $this->getEffectsOnlyCommand($jobData, $effectsFilter); + $width = $conversionParams[self::TARGET_WIDTH]; + $height = $conversionParams[self::TARGET_HEIGHT]; + $frameSize = "$width:$height"; + $cmdStr .= " -s " . str_replace(':', 'x', $frameSize); + $cmdStr .= " -aspect $frameSize"; } - - return "-"; + return $cmdStr; } - protected function getEffectsOnlyCommand($jobData, $effectsFilter) + protected function getGeneralCommand($jobData, $sortedFilters) { + $filterComplex = $this->getMappedSortedFiltersComplex($sortedFilters); $flavorParamsObj = assetParamsPeer::getTempAssetParamByPk(kClipAttributes::SYSTEM_DEFAULT_FLAVOR_PARAMS_ID); - if(!$flavorParamsObj) + + if(!$flavorParamsObj || $filterComplex == "") { return "-"; } - $bitrate = $flavorParamsObj->getVideoBitRate(); + + $conversionParams = $this->getJobDataConversionParams($jobData); + $cmdStr = " -i __inFileName__"; - $cmdStr .= " -filter_complex '$effectsFilter'"; + $cmdStr .= $this->getAspectCommand($conversionParams, $sortedFilters); + $cmdStr .= " -filter_complex '$filterComplex'"; $cmdStr .= " -c:v libx264 -subq 5 -qcomp 0.6 -qmin 10 -qmax 50 -qdiff 4"; $cmdStr .= " -coder 1 -refs 2 -x264opts stitchable -vprofile main -force_key_frames expr:'gte(t,n_forced*2)'"; + + $bitrate = $flavorParamsObj->getVideoBitRate(); $cmdStr .= " -pix_fmt yuv420p -b:v $bitrate" . "k"; $cmdStr .= " -c:a libfdk_aac -b:a 192k"; - $conversionParams = $this->getJobDataConversionParams($jobData); $cmdStr .= " -ac " . $conversionParams[self::AUDIO_CHANNELS]; $cmdStr .= " -ar " . $conversionParams[self::AUDIO_SAMPLE_RATE]; @@ -1400,25 +1418,7 @@ protected function getEffectsOnlyCommand($jobData, $effectsFilter) return $cmdStr; } - protected function getEffectsFilter($jobData, $operationAttribute) - { - /** @var kClipConcatJobData $jobData */ - if($this->shouldApplyEffectsOnConcat($jobData)) - { - $effectsManager = new kEffectsManager(); - return $effectsManager->addVideoEffects($operationAttribute); - } - return ""; - } - - protected function shouldApplyEffectsOnConcat($jobData) - { - $width = $this->getJobDataConversionParams($jobData, self::WIDTH); - $imageToVideo = $this->getJobDataConversionParams($jobData, self::IMAGE_TO_VIDEO); - return $width || $imageToVideo; - } - - protected function getAddSilentAudioCommand($jobData, $operationAttribute, $effectsFilter) + protected function getAddSilentAudioCommand($jobData, $operationAttribute, $sortedFilters) { /** @var kClipConcatJobData $jobData */ $cmdStr = " -i __inFileName__"; @@ -1426,9 +1426,12 @@ protected function getAddSilentAudioCommand($jobData, $operationAttribute, $effe $cmdStr .= " -ac " . $conversionParams[self::AUDIO_CHANNELS]; $cmdStr .= " -ar " . $conversionParams[self::AUDIO_SAMPLE_RATE]; $cmdStr .= " -f s16le -i /dev/zero"; - if($effectsFilter != "") + + $filterComplex = $this->getMappedSortedFiltersComplex($sortedFilters); + if($filterComplex != "") { - $cmdStr .= " -filter_complex '[0:v]$effectsFilter'"; + $cmdStr .= $this->getAspectCommand($conversionParams, $sortedFilters); + $cmdStr .= " -filter_complex '$filterComplex'"; $cmdStr .= " -c:v libx264 -pix_fmt yuv420p"; } else @@ -1440,7 +1443,7 @@ protected function getAddSilentAudioCommand($jobData, $operationAttribute, $effe return $cmdStr; } - protected function getConvertImageToVideoCommand($jobData, $operationAttribute, $effectsFilter) + protected function getConvertImageToVideoCommand($jobData, $operationAttribute, $sortedFilters) { /** @var kClipConcatJobData $jobData */ $cmdStr = " -loop 1 -i __inFileName__"; @@ -1455,36 +1458,10 @@ protected function getConvertImageToVideoCommand($jobData, $operationAttribute, $cmdStr.= " -r " . $conversionParams[self::FRAME_RATE]; } $cmdStr .= " -c:v libx264 -pix_fmt yuv420p"; - // add white background to the video to handle transparency, transparent pixels shows the background color - $whiteBackgroundFilter = "split=2[bg][fg];[bg]drawbox=c=white@1:replace=1:t=fill[bg];[bg][fg]overlay=format=auto"; - if(isset($conversionParams[self::WIDTH]) && isset($conversionParams[self::HEIGHT])) - { - $width = $conversionParams[self::WIDTH]; - $height = $conversionParams[self::HEIGHT]; - $frameSize = "$width:$height"; - $cmdStr .= " -s " . str_replace(':', 'x', $frameSize); - $scalingFilter = "scale=iw*min($width/iw\,$height/ih):ih*min($width/iw\,$height/ih)"; - $paddingFilter = "pad=$width:$height:(ow-iw)/2:(oh-ih)/2"; - if($effectsFilter != "") - { - $filter = "[0:v]" . $effectsFilter . "[vflt0];[vflt0]" . $scalingFilter . "[vflt1];[vflt1]" . $paddingFilter; - } - else - { - $filter = "[0:v]" . $scalingFilter . "[vflt1];[vflt1]" . $paddingFilter . "[out];[out]" . $whiteBackgroundFilter; - } - $cmdStr .= " -aspect $frameSize"; - } - else if($effectsFilter != "") - { - $filter = "[0:v]$effectsFilter"; - } - else - { - $filter ="[0]$whiteBackgroundFilter"; - } - $cmdStr .= " -filter_complex '$filter'"; + $filterComplex = $this->getMappedSortedFiltersComplex($sortedFilters); + $cmdStr .= $this->getAspectCommand($conversionParams, $sortedFilters); + $cmdStr .= " -filter_complex '$filterComplex'"; // image should have only one clipAttribute $duration = $operationAttribute->getDuration()/1000; @@ -1637,8 +1614,8 @@ protected function fixConversionParam($flavorParamsObj, $singleAttribute, $singl } $conversionEngines = explode(',', $flavorParamsObj->getConversionEngines()); $conversionExtraParams = $originalConversionEnginesExtraParams ? explode('|', $originalConversionEnginesExtraParams) : null; - // do not apply effects if: 1.image to video conversion, 2.resizing (already using filter complex) - $allowEffects = !$conversionData || (!isset($conversionData[self::IMAGE_TO_VIDEO]) && !isset($conversionData[self::WIDTH])); + // do not apply effects if: 1.image to video conversion, 2.resizing (already using filter complex), 3. cropping + $allowEffects = $this->allowEffectsOnConvert($conversionData, $singleAttributeIndex); $newExtraConversionParams = $this->editConversionEngineExtraParam($conversionEngines, $singleAttribute, $conversionExtraParams, $isAudio, $extraParams, $allowEffects); $flavorParamsObj->setConversionEnginesExtraParams($newExtraConversionParams); if($conversionData && $flavorParamsObj instanceof flavorParams) @@ -1656,41 +1633,39 @@ protected function editConversionParams(&$flavorParamsObj, $conversionParams, $i { $flavorParamsObj->setForceFrameToMultiplication16(0); $flavorParamsObj->setIsAvoidVideoShrinkFramesizeToSource(1); - $flavorParamsObj->setHeight($conversionParams[self::HEIGHT]); + $flavorParamsObj->setHeight($conversionParams[self::TARGET_HEIGHT]); $invertedResource = isset($conversionParams[self::INVERTED_SOURCE]) && $conversionParams[self::INVERTED_SOURCE]; - $cropped = false; - $croppingMode = isset($conversionParams[self::CROP_DATA_ARRAY]) && isset($conversionParams[self::CROP_DATA_ARRAY][$index]); - if($croppingMode) + + $croppingMode = false; + if(isset($conversionParams[self::CROP_DATA_ARRAY]) && isset($conversionParams[self::CROP_DATA_ARRAY][$index])) { $cropData = $conversionParams[self::CROP_DATA_ARRAY][$index]; - $cropped = is_array($cropData) && count($cropData) > 0; + $croppingMode = is_array($cropData) && count($cropData) > 0; } - if($cropped) + if($croppingMode) { // crop $processingMode = $invertedResource ? 8 : 7; $flavorParamsObj->setAspectRatioProcessingMode($processingMode); $flavorParamsObj->setCropData(json_encode($cropData)); } - else + else if($invertedResource) { - if($invertedResource) - { - // for inverted source calculation, the output flavor is inverted - // _arProcessingMode = 6, inverts back the output flavor - $flavorParamsObj->setAspectRatioProcessingMode(6); - } - else if(isset($conversionParams[self::WIDTH])) - { - // resize - $flavorParamsObj->setAspectRatioProcessingMode(2); - } + // for inverted source calculation, the output flavor is inverted + // _arProcessingMode = 6, inverts back the output flavor + $flavorParamsObj->setAspectRatioProcessingMode(6); } - if(isset($conversionParams[self::WIDTH])) + else if(isset($conversionParams[self::TARGET_WIDTH])) + { + // scale + $flavorParamsObj->setAspectRatioProcessingMode(2); + } + + if(isset($conversionParams[self::TARGET_WIDTH])) { - $flavorParamsObj->setWidth($conversionParams[self::WIDTH]); + $flavorParamsObj->setWidth($conversionParams[self::TARGET_WIDTH]); } if(isset($conversionParams[self::FRAME_RATE])) @@ -1794,4 +1769,207 @@ protected function getJobDataConversionParams($jobData, $field = null) } return null; } + + protected function getSortedFiltersComplexForConcat($jobData, $operationAttributesSorted, $clipIndex) + { + /** @var kClipConcatJobData $jobData */ + + $filters = array(); + $filters["crop"] = $this->getCropFilterForConcat($jobData, $clipIndex); + $filters["effects"] = $this->getEffectsFilterForConcat($jobData, $operationAttributesSorted, $clipIndex); + $filters["scale"] = $this->getPaddedScaleFiltersForConcat($jobData, $clipIndex); + + if(!$filters["effects"] || $filters["effects"] == "") + { + $filters["whiteBackground"] = $this->getWhiteBackgroundForConcat($jobData); + } + + foreach ($filters as $ind => $value) + { + if(!$value || $value == "") + { + unset($filters[$ind]); + } + } + + return $filters; + } + + protected function getMappedSortedFiltersComplex($sortedFilters) + { + $mappedFilters = ""; + if(count($sortedFilters) == 1 && isset($sortedFilters["whiteBackground"])) + { + return "[0]" . $sortedFilters[0]; + } + if(count($sortedFilters) > 0) + { + $sortedFilterTypes = array_keys($sortedFilters); + $filterType = $sortedFilterTypes[0]; + $mappedFilters .= "[0:v]" . $sortedFilters[$filterType]; + + for ($i = 0; $i < count($sortedFilterTypes) - 1; $i++) + { + $filterType = $sortedFilterTypes[$i+1]; + $mappedFilters .= "[vflt$i];[vflt$i]" . $sortedFilters[$filterType]; + } + } + return $mappedFilters; + } + + protected function getPaddedScaleFiltersForConcat($jobData, $clipIndex) + { + $filter = ""; + if($this->shouldScaleOnConcat($jobData, $clipIndex)) + { + $imageToVideo = $this->getJobDataConversionParams($jobData, self::IMAGE_TO_VIDEO); + $cropped = $this->getJobDataConversionParams($jobData, self::CROP); + + $oh = $this->getJobDataConversionParams($jobData, self::TARGET_HEIGHT); + $ow = $this->getJobDataConversionParams($jobData, self::TARGET_WIDTH); + $ih = $imageToVideo || !$cropped ? "ih" : $this->getJobDataConversionParams($jobData, self::CROP_HEIGHT); + $iw = $imageToVideo || !$cropped ? "iw" : $this->getJobDataConversionParams($jobData, self::CROP_WIDTH); + + $scaleFilter = $this->getScaleFilter($ow, $oh, $iw, $ih); + $padFilter = $this->getPadFilter($ow, $oh, $iw, $ih); + $filter = $scaleFilter. "[vscale];[vscale]" . $padFilter; + } + return $filter; + } + + protected function getCropFilterForConcat($jobData, $clipIndex) + { + $filter = ""; + $conversionParams = $this->getJobDataConversionParams($jobData); + $cropData = $this->getCropDataFromConversionParams($conversionParams, $clipIndex); + + if($this->shouldCropOnConcat($jobData, $clipIndex)) + { + $widthPosition = $cropData["widthPosition"]; + $heightPosition = $cropData["heightPosition"]; + $outWidth = $cropData["outWidth"]; + $outHeight = $cropData["outHeight"]; + $filter = $this->getCropFilter($outWidth, $outHeight, $widthPosition, $heightPosition); + } + + return $filter; + } + + protected function getWhiteBackgroundForConcat($jobData) + { + /** @var kClipConcatJobData $jobData */ + + $whiteBackgroundFilter = null; + $imageToVideo = $this->getJobDataConversionParams($jobData, self::IMAGE_TO_VIDEO); + if($imageToVideo) + { + // add white background to the video to handle transparency, transparent pixels shows the background color + $whiteBackgroundFilter = $this->getWhiteBackgroundFilter(); + } + return $whiteBackgroundFilter; + } + + protected function getEffectsFilterForConcat($jobData, $operationAttributes, $clipIndex) + { + /** @var kClipConcatJobData $jobData */ + + $effectsFilter = null; + if($this->shouldApplyEffectsOnConcat($jobData, $clipIndex)) + { + $effectsManager = new kEffectsManager(); + $effectsFilter = $effectsManager->addVideoEffects($operationAttributes[$clipIndex]); + } + return $effectsFilter; + } + + protected function shouldApplyEffectsOnConcat($jobData, $clipIndex) + { + /** @var kClipConcatJobData $jobData */ + + // check if we already used filter_complex on clipping + $conversionParams = $this->getJobDataConversionParams($jobData); + $cropped = $this->isCroppedClip($conversionParams, $clipIndex); + $scaled = $this->getJobDataConversionParams($jobData, self::TARGET_WIDTH); + $subtitles = $this->isSubtitledClip($conversionParams, $clipIndex); + $imageToVideo = $this->getJobDataConversionParams($jobData, self::IMAGE_TO_VIDEO); + return $scaled || $cropped || $imageToVideo || $subtitles; + } + + protected function shouldScaleOnConcat($jobData, $clipIndex) + { + /** @var kClipConcatJobData $jobData */ + + $conversionParams = $this->getJobDataConversionParams($jobData); + $cropped = $this->isCroppedClip($conversionParams, $clipIndex); + $scaled = $this->getJobDataConversionParams($jobData, self::TARGET_WIDTH); + $subtitles = $this->isSubtitledClip($conversionParams, $clipIndex); + $imageToVideo = $this->getJobDataConversionParams($jobData, self::IMAGE_TO_VIDEO); + return $scaled && ($cropped || $imageToVideo || $subtitles); + } + + protected function shouldCropOnConcat($jobData, $clipIndex) + { + /** @var kClipConcatJobData $jobData */ + + $conversionParams = $this->getJobDataConversionParams($jobData); + $cropped = $this->isCroppedClip($conversionParams, $clipIndex); + $imageToVideo = $this->getJobDataConversionParams($jobData, self::IMAGE_TO_VIDEO); + return $imageToVideo && $cropped; + } + + protected function isCroppedClip($conversionParams, $clipIndex) + { + $cropData = $this->getCropDataFromConversionParams($conversionParams, $clipIndex); + return count($cropData) > 0; + } + + protected function isSubtitledClip($conversionParams, $clipIndex) + { + $subtitleData = $this->getSubtitlesDataFromConversionParams($conversionParams, $clipIndex); + return count($subtitleData) > 0; + } + + protected function allowEffectsOnConvert($conversionData, $singleAttributeIndex) + { + if(!$conversionData) + { + return true; + } + $cropped = $this->isCroppedClip($conversionData, $singleAttributeIndex); + $subtitles = $this->isSubtitledClip($conversionData, $singleAttributeIndex); + $imageToVideo = isset($conversionData[self::IMAGE_TO_VIDEO]); + $scale = isset($conversionData[self::TARGET_WIDTH]); + return !$imageToVideo && !$scale && !$cropped && !$subtitles; + } + + protected function getCropDataFromConversionParams($conversionParams, $clipIndex) + { + $cropDataArray = isset($conversionParams[self::CROP_DATA_ARRAY]) ? $conversionParams[self::CROP_DATA_ARRAY] : array(); + return isset($cropDataArray[$clipIndex]) ? $cropDataArray[$clipIndex] : array(); + } + + protected function getSubtitlesDataFromConversionParams($conversionParams, $clipIndex) + { + $subtitleDataArray = isset($conversionParams[self::SUBTITLES_DATA_ARRAY]) ? $conversionParams[self::SUBTITLES_DATA_ARRAY] : array(); + return isset($subtitleDataArray[$clipIndex]) ? $subtitleDataArray[$clipIndex] : array(); + } + + protected function getScaleFilter($ow, $oh, $iw = "iw", $ih = "ih") + { + return "scale=$iw*min($ow/$iw\,$oh/$ih):$ih*min($ow/$iw\,$oh/$ih)"; + } + protected function getPadFilter($ow, $oh, $iw = "iw", $ih = "ih") + { + return "pad=$ow:$oh:($ow-$iw)/2:($oh-$ih)/2"; + } + + protected function getCropFilter($ow, $oh, $wp, $hp) + { + return "crop=$ow:$oh:$wp:$hp"; + } + + protected function getWhiteBackgroundFilter() + { + return "split=2[bg][fg];[bg]drawbox=c=white@1:replace=1:t=fill[bg];[bg][fg]overlay=format=auto"; + } } diff --git a/infra/cdl/kdl/KDLMediaObjectData.php b/infra/cdl/kdl/KDLMediaObjectData.php index 1b81e13b68a..5b61831a16b 100644 --- a/infra/cdl/kdl/KDLMediaObjectData.php +++ b/infra/cdl/kdl/KDLMediaObjectData.php @@ -212,7 +212,7 @@ class KDLVideoData extends KDLBaseMediaData { * 2: letterbox mode * 3: force 16/9 for everything that is not 16:9 * 4: force '-aspect' option - * 5: force perciese source AR + * 5: force precise source AR * 7: cropping * 8: inverted cropping */ From 85a162ecf07c90ef6dc32ccd83a7547ecec233d8 Mon Sep 17 00:00:00 2001 From: Salma Date: Tue, 6 Aug 2024 08:00:03 +0300 Subject: [PATCH 32/96] multi clip refactor --- alpha/apps/kaltura/lib/clipconcat/kClipManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alpha/apps/kaltura/lib/clipconcat/kClipManager.php b/alpha/apps/kaltura/lib/clipconcat/kClipManager.php index 2ca44452402..baf4d711df5 100644 --- a/alpha/apps/kaltura/lib/clipconcat/kClipManager.php +++ b/alpha/apps/kaltura/lib/clipconcat/kClipManager.php @@ -1614,7 +1614,6 @@ protected function fixConversionParam($flavorParamsObj, $singleAttribute, $singl } $conversionEngines = explode(',', $flavorParamsObj->getConversionEngines()); $conversionExtraParams = $originalConversionEnginesExtraParams ? explode('|', $originalConversionEnginesExtraParams) : null; - // do not apply effects if: 1.image to video conversion, 2.resizing (already using filter complex), 3. cropping $allowEffects = $this->allowEffectsOnConvert($conversionData, $singleAttributeIndex); $newExtraConversionParams = $this->editConversionEngineExtraParam($conversionEngines, $singleAttribute, $conversionExtraParams, $isAudio, $extraParams, $allowEffects); $flavorParamsObj->setConversionEnginesExtraParams($newExtraConversionParams); @@ -1931,6 +1930,7 @@ protected function isSubtitledClip($conversionParams, $clipIndex) protected function allowEffectsOnConvert($conversionData, $singleAttributeIndex) { + // do not apply effects if already using filter complex if(!$conversionData) { return true; From e3902704611d4574e1f13e910b12c9f8fd2dad03 Mon Sep 17 00:00:00 2001 From: Salma Date: Tue, 6 Aug 2024 11:46:36 +0300 Subject: [PATCH 33/96] caption attributes --- .../kaltura/lib/clipconcat/kClipManager.php | 72 +++++++++++-------- .../operations/kCaptionAttributes.php | 11 +++ .../resource/operations/kClipAttributes.php | 18 ++--- ...tions.php => kRenderCaptionAttributes.php} | 47 ++++++------ api_v3/lib/KalturaEntryService.php | 36 ++++++---- api_v3/lib/KalturaErrors.php | 1 + .../operations/KalturaCaptionAttributes.php | 9 +++ .../KalturaCaptionAttributesArray.php | 31 ++++++++ .../operations/KalturaClipAttributes.php | 44 ++++++------ ...php => KalturaRenderCaptionAttributes.php} | 32 ++++++--- 10 files changed, 194 insertions(+), 107 deletions(-) create mode 100644 alpha/lib/data/resource/operations/kCaptionAttributes.php rename alpha/lib/data/resource/operations/{kCaptionsOptions.php => kRenderCaptionAttributes.php} (85%) create mode 100644 api_v3/lib/types/resource/operations/KalturaCaptionAttributes.php create mode 100644 api_v3/lib/types/resource/operations/KalturaCaptionAttributesArray.php rename api_v3/lib/types/resource/operations/{KalturaCaptionsOptions.php => KalturaRenderCaptionAttributes.php} (59%) diff --git a/alpha/apps/kaltura/lib/clipconcat/kClipManager.php b/alpha/apps/kaltura/lib/clipconcat/kClipManager.php index baf4d711df5..9bff3e1e952 100644 --- a/alpha/apps/kaltura/lib/clipconcat/kClipManager.php +++ b/alpha/apps/kaltura/lib/clipconcat/kClipManager.php @@ -797,47 +797,59 @@ protected function getSubtitlesDataArray($operationAttributes) $subtitlesDataArray = array(); foreach ($operationAttributes as $operationAttribute) { - $subtitlesDataArray[] = $this->getSubtitlesData($operationAttribute->getCaptionsOptions()); + $subtitlesDataArray[] = $this->getSubtitlesData($operationAttribute->getCaptionAttributes()); } return $subtitlesDataArray; } - protected function getSubtitlesData($captionsOptions) + protected function getRenderCaptionAttribute($captionAttributes) { - $subtitlesData = array(); - if(!($captionsOptions instanceOf kCaptionsOptions) || !$captionsOptions->getCaptionFileUrl()) + $renderCaptionAttribute = null; + foreach ($captionAttributes as $captionAttribute) { - return $subtitlesData; + if($captionAttribute instanceOf kRenderCaptionAttributes && $captionAttribute->getCaptionFileUrl()) + { + $renderCaptionAttribute = $captionAttribute; + break; + } } + return $renderCaptionAttribute; + } - $forceStyle = array(); - $forceStyle["FontName"] = $captionsOptions->getFontName(); - $forceStyle["Fontsize"] = $captionsOptions->getFontSize(); - $forceStyle["Bold"] = $captionsOptions->getBold() ? 1 : null; - $forceStyle["Italic"] = $captionsOptions->getItalic() ? 1 : null; - $forceStyle["Underline"] = $captionsOptions->getUnderline() ? 1 : null; - $forceStyle["PrimaryColour"] = $captionsOptions->getPrimaryColour(); - $forceStyle["Alignment"] = $captionsOptions->getAlignment(); - $forceStyle["BorderStyle"] = $captionsOptions->getBorderStyle(); - $forceStyle["BackColour"] = $captionsOptions->getBackColour(); - $forceStyle["OutlineColour"] = $captionsOptions->getOutlineColour(); - - foreach ($forceStyle as $key => $value) - { - if($value === null) + protected function getSubtitlesData($captionAttributes) + { + $subtitlesData = array(); + $renderCaptionAttribute = $this->getRenderCaptionAttribute($captionAttributes); + if($renderCaptionAttribute) + { + $forceStyle = array(); + $forceStyle["FontName"] = $renderCaptionAttribute->getFontName(); + $forceStyle["Fontsize"] = $renderCaptionAttribute->getFontSize(); + $forceStyle["Bold"] = $renderCaptionAttribute->getBold() ? 1 : null; + $forceStyle["Italic"] = $renderCaptionAttribute->getItalic() ? 1 : null; + $forceStyle["Underline"] = $renderCaptionAttribute->getUnderline() ? 1 : null; + $forceStyle["PrimaryColour"] = $renderCaptionAttribute->getPrimaryColour(); + $forceStyle["Alignment"] = $renderCaptionAttribute->getAlignment(); + $forceStyle["BorderStyle"] = $renderCaptionAttribute->getBorderStyle(); + $forceStyle["BackColour"] = $renderCaptionAttribute->getBackColour(); + $forceStyle["OutlineColour"] = $renderCaptionAttribute->getOutlineColour(); + + foreach ($forceStyle as $key => $value) { - unset($forceStyle[$key]); + if($value === null) + { + unset($forceStyle[$key]); + } } - } - // set subtitles data - $subtitlesData["action"] = $captionsOptions->getAction(); - $subtitlesData["captionFileUrl"] = $captionsOptions->getCaptionFileUrl(); - if(count($forceStyle) > 0) - { - $subtitlesData["force_style"] = $forceStyle; + // set subtitles data + $subtitlesData["action"] = "render"; + $subtitlesData["captionFileUrl"] = $renderCaptionAttribute->getCaptionFileUrl(); + if(count($forceStyle) > 0) + { + $subtitlesData["force_style"] = $forceStyle; + } } - return $subtitlesData; } @@ -922,7 +934,7 @@ protected function getSilentAudioPaddingCommand($usingFilterComplex) } else { - // if we do not scale the clipped asset, then add stream mapping, because applying only audio filter_complex, changes the streams order and concat fails + // if we do not use video filter complex, then add stream mapping, because applying only audio filter_complex, changes the streams order and concat fails return " -filter_complex 'aresample=async=1:min_hard_comp=0.100000:first_pts=0[a]' -map v -map [\"a\"] "; } } diff --git a/alpha/lib/data/resource/operations/kCaptionAttributes.php b/alpha/lib/data/resource/operations/kCaptionAttributes.php new file mode 100644 index 00000000000..ea42a5061b1 --- /dev/null +++ b/alpha/lib/data/resource/operations/kCaptionAttributes.php @@ -0,0 +1,11 @@ + */ - private $captionsOptions; + private $captionAttributes; /** * @var int @@ -55,7 +55,7 @@ public function toArray() 'globalOffsetInDestination' => $this->globalOffsetInDestination, 'effectArray' => $this->effectArray, 'cropAlignment' => $this->cropAlignment, - 'captionsOptions' => $this->captionsOptions + 'captionAttributes' => $this->captionAttributes ); } @@ -164,18 +164,18 @@ public function setCropAlignment($cropAlignment) } /** - * @return kCaptionsOptions + * @return array */ - public function getCaptionsOptions() + public function getCaptionAttributes() { - return $this->captionsOptions; + return $this->captionAttributes; } /** - * @param kCaptionsOptions $captionsOptions + * @param array $captionAttributes */ - public function setCaptionsOptions($captionsOptions) + public function setCaptionAttributes($captionAttributes) { - return $this->captionsOptions = $captionsOptions; + return $this->captionAttributes = $captionAttributes; } } diff --git a/alpha/lib/data/resource/operations/kCaptionsOptions.php b/alpha/lib/data/resource/operations/kRenderCaptionAttributes.php similarity index 85% rename from alpha/lib/data/resource/operations/kCaptionsOptions.php rename to alpha/lib/data/resource/operations/kRenderCaptionAttributes.php index 678dc605faa..4e60a223a72 100644 --- a/alpha/lib/data/resource/operations/kCaptionsOptions.php +++ b/alpha/lib/data/resource/operations/kRenderCaptionAttributes.php @@ -3,13 +3,8 @@ * @package Core * @subpackage model.data */ -class kCaptionsOptions +class kRenderCaptionAttributes extends kCaptionAttributes { - /** - * @var string - */ - private $action; - /** * @var string */ @@ -80,22 +75,6 @@ class kCaptionsOptions */ private $captionAssetId; - /** - * @return string - */ - public function getAction() - { - return $this->action; - } - - /** - * @param string $action - */ - public function setAction($action) - { - $this->action = $action; - } - /** * @return string */ @@ -319,4 +298,28 @@ public function setCaptionFileUrl($captionFileUrl) { $this->captionFileUrl = $captionFileUrl; } + + public function toArray() + { + return array( + 'fontName' => $this->fontName, + 'fontSize' => $this->fontSize, + 'fontStyle' => $this->fontStyle, + 'primaryColour' => $this->primaryColour, + 'borderStyle' => $this->borderStyle, + 'backColour' => $this->backColour, + 'outlineColour' => $this->outlineColour, + 'shadow' => $this->shadow, + 'bold' => $this->bold, + 'italic' => $this->italic, + 'underline' => $this->underline, + 'alignment' => $this->alignment, + 'captionAssetId' => $this->captionAssetId + ); + } + + public function getApiType() + { + return 'KalturaRenderCaptionAttributes'; + } } diff --git a/api_v3/lib/KalturaEntryService.php b/api_v3/lib/KalturaEntryService.php index fcc4f45fbf6..d84db7b3b9d 100644 --- a/api_v3/lib/KalturaEntryService.php +++ b/api_v3/lib/KalturaEntryService.php @@ -2011,24 +2011,30 @@ protected function handleMultiResourceMultiClipRequest($resources, entry $destEn protected function setCaptionAssetsUrls(&$operationAttribute) { - $captionsOptions = $operationAttribute->getCaptionsOptions(); - if(!$captionsOptions || !$captionsOptions->getCaptionAssetId()) + $editedCaptionAttributes = array(); + $captionAttributes = $operationAttribute->getCaptionAttributes(); + foreach ($captionAttributes as $captionAttribute) { - return; - } + if(!($captionAttribute instanceof kRenderCaptionAttributes) || !$captionAttribute->getCaptionAssetId()) + { + continue; + } - $captionAssetId = $captionsOptions->getCaptionAssetId(); - $captionAsset = assetPeer::retrieveById($captionAssetId); - if (!($captionAsset instanceof CaptionAsset)) - { - throw new KalturaAPIException(KalturaCaptionErrors::CAPTION_ASSET_ID_NOT_FOUND, $captionAssetId); - } - if ($captionAsset->getStatus() != asset::ASSET_STATUS_READY) - { - throw new KalturaAPIException(KalturaCaptionErrors::CAPTION_ASSET_IS_NOT_READY); + $captionAssetId = $captionAttribute->getCaptionAssetId(); + $captionAsset = assetPeer::retrieveById($captionAssetId); + if (!($captionAsset instanceof CaptionAsset)) + { + throw new KalturaAPIException(KalturaCaptionErrors::CAPTION_ASSET_ID_NOT_FOUND, $captionAssetId); + } + if ($captionAsset->getStatus() != asset::ASSET_STATUS_READY) + { + throw new KalturaAPIException(KalturaCaptionErrors::CAPTION_ASSET_IS_NOT_READY); + } + $captionAttribute->setCaptionFileUrl($captionAsset->getDownloadUrl(true)); + $editedCaptionAttributes[] = $captionAttribute; } - $captionsOptions->setCaptionFileUrl($captionAsset->getDownloadUrl(true)); - $operationAttribute->setCaptionsOptions($captionsOptions); + $operationAttribute->setCaptionAttributes($editedCaptionAttributes); + } /*** diff --git a/api_v3/lib/KalturaErrors.php b/api_v3/lib/KalturaErrors.php index f49272333b0..963ee9a99d7 100644 --- a/api_v3/lib/KalturaErrors.php +++ b/api_v3/lib/KalturaErrors.php @@ -53,6 +53,7 @@ class KalturaErrors extends APIErrors const MISSING_MANDATORY_PARAMETER = "MISSING_MANDATORY_PARAMETER;PARAM_NAME;Missing parameter \"@PARAM_NAME@\""; const INVALID_PARAMETER_VALUE = "INVALID_PARAMETER_VALUE;PARAM_NAME;invalid value for parameter \"@PARAM_NAME@\""; const PARAMETER_VALUE_OUT_OF_RANGE = "PARAMETER_VALUE_OUT_OF_RANGE;PARAM_NAME,MIN,MAX;Parameter \"@PARAM_NAME@\" value is out of range (@MIN@ - @MAX@)"; + const MULTIPLE_PARAMETER_NOT_SUPPORTED = "MULTIPLE_PARAMETER_NOT_SUPPORTED;PARAM_NAME;Multiple parameters \"@PARAM_NAME@\" is not supported"; // INVALID_OBJ_TYPE - invalid object type const INVALID_OBJECT_TYPE = "INVALID_OBJECT_TYPE;INVALID_OBJ_TYPE;Invalid object type \"@INVALID_OBJ_TYPE@\""; diff --git a/api_v3/lib/types/resource/operations/KalturaCaptionAttributes.php b/api_v3/lib/types/resource/operations/KalturaCaptionAttributes.php new file mode 100644 index 00000000000..e63c3951739 --- /dev/null +++ b/api_v3/lib/types/resource/operations/KalturaCaptionAttributes.php @@ -0,0 +1,9 @@ +getApiType(); + $nObj = new $class(); + $nObj->fromObject($obj, $responseProfile); + $newArr[] = $nObj; + } + + return $newArr; + } + + public function __construct() + { + parent::__construct("KalturaCaptionAttributes"); + } +} diff --git a/api_v3/lib/types/resource/operations/KalturaClipAttributes.php b/api_v3/lib/types/resource/operations/KalturaClipAttributes.php index 2b2a94af930..a7dd489aac3 100644 --- a/api_v3/lib/types/resource/operations/KalturaClipAttributes.php +++ b/api_v3/lib/types/resource/operations/KalturaClipAttributes.php @@ -39,9 +39,9 @@ class KalturaClipAttributes extends KalturaOperationAttributes public $cropAlignment; /** - * @var KalturaCaptionsOptions + * @var KalturaCaptionAttributesArray */ - public $captionsOptions; + public $captionAttributes; private static $map_between_objects = array @@ -50,7 +50,7 @@ class KalturaClipAttributes extends KalturaOperationAttributes "duration", "globalOffsetInDestination", "effectArray", - "captionsOptions", + "captionAttributes", "cropAlignment" ); @@ -71,36 +71,34 @@ public function validateForUsage($sourceObject, $propertiesToSkip = array()) throw new KalturaAPIException(KalturaErrors::PARAMETER_VALUE_OUT_OF_RANGE, 'cropAlignment', $minCropAlignment, $maxCropAlignment); } - $captionsOptions = $this->captionsOptions; - if($captionsOptions instanceof KalturaCaptionsOptions) + $renderCaptionAttribute = null; + foreach ($this->captionAttributes as $captionAttribute) { - if(is_null($captionsOptions->action)) + if($captionAttribute instanceOf kRenderCaptionAttributes) { - throw new KalturaAPIException(KalturaErrors::MISSING_MANDATORY_PARAMETER, "action"); + if($renderCaptionAttribute) + { + throw new KalturaAPIException(KalturaErrors::MULTIPLE_PARAMETER_NOT_SUPPORTED, 'renderCaptionAttributes'); + } + $renderCaptionAttribute = $captionAttribute; } - if(!$captionsOptions->captionAssetId) - { - throw new KalturaAPIException(KalturaErrors::MISSING_MANDATORY_PARAMETER, "captionAssetId"); - } - $this->validateColorFormat($captionsOptions->primaryColour, "primaryColour"); - $this->validateColorFormat($captionsOptions->outlineColour, "outlineColour"); - $this->validateColorFormat($captionsOptions->backColour, "backColour"); } } - protected function validateColorFormat($color, $paramName) + public function toObject ($object_to_fill = null, $props_to_skip = array()) { - if($color && !preg_match('/^\&[H|h]([0-9]|[A-F]|[a-f]){6}\&$/', $color)) + if(is_null($object_to_fill)) { - throw new KalturaAPIException(KalturaErrors::INVALID_PARAMETER_VALUE, $paramName); + $object_to_fill = new kClipAttributes(); } - } - public function toObject ( $object_to_fill = null , $props_to_skip = array() ) - { - if(is_null($object_to_fill)) - $object_to_fill = new kClipAttributes(); - + $captionAttributes = array(); + foreach($this->captionAttributes as $captionAttribute) + { + $captionAttributes[] = $captionAttribute->toObject(); + } + $object_to_fill->setCaptionAttributes($captionAttributes); + return parent::toObject($object_to_fill, $props_to_skip); } } diff --git a/api_v3/lib/types/resource/operations/KalturaCaptionsOptions.php b/api_v3/lib/types/resource/operations/KalturaRenderCaptionAttributes.php similarity index 59% rename from api_v3/lib/types/resource/operations/KalturaCaptionsOptions.php rename to api_v3/lib/types/resource/operations/KalturaRenderCaptionAttributes.php index 4e32b65b23d..8b0575bd88c 100644 --- a/api_v3/lib/types/resource/operations/KalturaCaptionsOptions.php +++ b/api_v3/lib/types/resource/operations/KalturaRenderCaptionAttributes.php @@ -3,13 +3,8 @@ * @package api * @subpackage objects */ -class KalturaCaptionsOptions extends KalturaObject +class KalturaRenderCaptionAttributes extends KalturaCaptionAttributes { - /** - * @var string - */ - public $action; - /** * @var string */ @@ -78,7 +73,6 @@ class KalturaCaptionsOptions extends KalturaObject private static $map_between_objects = array ( - "action", "fontName", "fontSize" , "fontStyle", @@ -99,11 +93,33 @@ public function getMapBetweenObjects() return array_merge(parent::getMapBetweenObjects(), self::$map_between_objects); } + public function validateForUsage($sourceObject, $propertiesToSkip = array()) + { + parent::validateForUsage($sourceObject, $propertiesToSkip); + + if(!$this->captionAssetId) + { + throw new KalturaAPIException(KalturaErrors::MISSING_MANDATORY_PARAMETER, "captionAssetId"); + } + $this->validateColorFormat($this->primaryColour, "primaryColour"); + $this->validateColorFormat($this->outlineColour, "outlineColour"); + $this->validateColorFormat($this->backColour, "backColour"); + } + + protected function validateColorFormat($color, $paramName) + { + if($color && !preg_match('/^\&[H|h]([0-9]|[A-F]|[a-f]){6}\&$/', $color)) + { + throw new KalturaAPIException(KalturaErrors::INVALID_PARAMETER_VALUE, $paramName); + } + } + + public function toObject($object_to_fill = null, $props_to_skip = array()) { if(is_null($object_to_fill)) { - $object_to_fill = new kCaptionsOptions(); + $object_to_fill = new kRenderCaptionAttributes(); } return parent::toObject($object_to_fill, $props_to_skip); } From 828e634cf9129c77065f0d2ea75c9a71faf22029 Mon Sep 17 00:00:00 2001 From: Salma Date: Tue, 6 Aug 2024 11:47:55 +0300 Subject: [PATCH 34/96] multi clip refactor --- api_v3/lib/types/resource/operations/KalturaClipAttributes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api_v3/lib/types/resource/operations/KalturaClipAttributes.php b/api_v3/lib/types/resource/operations/KalturaClipAttributes.php index a7dd489aac3..48c1b48a324 100644 --- a/api_v3/lib/types/resource/operations/KalturaClipAttributes.php +++ b/api_v3/lib/types/resource/operations/KalturaClipAttributes.php @@ -85,7 +85,7 @@ public function validateForUsage($sourceObject, $propertiesToSkip = array()) } } - public function toObject ($object_to_fill = null, $props_to_skip = array()) + public function toObject($object_to_fill = null, $props_to_skip = array()) { if(is_null($object_to_fill)) { From cf2b07420e583a3c872f32a7e0eabace30b62f16 Mon Sep 17 00:00:00 2001 From: Salma Date: Tue, 6 Aug 2024 14:59:10 +0300 Subject: [PATCH 35/96] remove font style , should be font name --- .../operations/kRenderCaptionAttributes.php | 22 ------------------- .../KalturaRenderCaptionAttributes.php | 6 ----- 2 files changed, 28 deletions(-) diff --git a/alpha/lib/data/resource/operations/kRenderCaptionAttributes.php b/alpha/lib/data/resource/operations/kRenderCaptionAttributes.php index 4e60a223a72..8b37594fa2f 100644 --- a/alpha/lib/data/resource/operations/kRenderCaptionAttributes.php +++ b/alpha/lib/data/resource/operations/kRenderCaptionAttributes.php @@ -20,11 +20,6 @@ class kRenderCaptionAttributes extends kCaptionAttributes */ private $fontSize; - /** - * @var string - */ - private $fontStyle; - /** * @var string */ @@ -107,22 +102,6 @@ public function setFontSize($fontSize) $this->fontSize = $fontSize; } - /** - * @return string - */ - public function getFontStyle() - { - return $this->fontStyle; - } - - /** - * @param $fontStyle string - */ - public function setFontStyle($fontStyle) - { - $this->fontStyle = $fontStyle; - } - /** * @return string */ @@ -304,7 +283,6 @@ public function toArray() return array( 'fontName' => $this->fontName, 'fontSize' => $this->fontSize, - 'fontStyle' => $this->fontStyle, 'primaryColour' => $this->primaryColour, 'borderStyle' => $this->borderStyle, 'backColour' => $this->backColour, diff --git a/api_v3/lib/types/resource/operations/KalturaRenderCaptionAttributes.php b/api_v3/lib/types/resource/operations/KalturaRenderCaptionAttributes.php index 8b0575bd88c..b73bd562191 100644 --- a/api_v3/lib/types/resource/operations/KalturaRenderCaptionAttributes.php +++ b/api_v3/lib/types/resource/operations/KalturaRenderCaptionAttributes.php @@ -15,11 +15,6 @@ class KalturaRenderCaptionAttributes extends KalturaCaptionAttributes */ public $fontSize; - /** - * @var string - */ - public $fontStyle; - /** * @var string */ @@ -75,7 +70,6 @@ class KalturaRenderCaptionAttributes extends KalturaCaptionAttributes ( "fontName", "fontSize" , - "fontStyle", "primaryColour", "borderStyle", "backColour", From 970183465d2c58ba1fdbefdf888cd7e93864ef16 Mon Sep 17 00:00:00 2001 From: Salma Date: Tue, 6 Aug 2024 16:38:21 +0300 Subject: [PATCH 36/96] edge case fix and crop optimization --- .../kaltura/lib/clipconcat/kClipManager.php | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/alpha/apps/kaltura/lib/clipconcat/kClipManager.php b/alpha/apps/kaltura/lib/clipconcat/kClipManager.php index 9bff3e1e952..c98477be436 100644 --- a/alpha/apps/kaltura/lib/clipconcat/kClipManager.php +++ b/alpha/apps/kaltura/lib/clipconcat/kClipManager.php @@ -747,9 +747,6 @@ protected function getCropData($targetAspectRatio, $inWidth, $inHeight, $cropAli return array(); } - $inHeight -= 1; - $inWidth -= 1; - $outWidth = $inWidth; $outHeight = $inHeight; $widthPosition = 0; @@ -761,25 +758,22 @@ protected function getCropData($targetAspectRatio, $inWidth, $inHeight, $cropAli // crop height if($inWidth / $inHeight < $targetAspectRatio) { - $outHeight = min($outWidth / $targetAspectRatio, $inHeight); - $cropLength = $inHeight - $outHeight; - $heightPosition = $alignment * $cropLength; + $outHeight = min(floor($outWidth / $targetAspectRatio), $inHeight); + $this->adjustResolutionDivisionByValue($outWidth, $outHeight); + $croppedLength = $inHeight - $outHeight; + $heightPosition = floor($alignment * $croppedLength); } // crop width else if($inWidth / $inHeight > $targetAspectRatio) { - $outWidth = min($targetAspectRatio * $outHeight, $inWidth); - $cropLength = $inWidth - $outWidth; - $widthPosition = $alignment * $cropLength; + $outWidth = min(floor($targetAspectRatio * $outHeight), $inWidth); + $this->adjustResolutionDivisionByValue($outWidth, $outHeight); + $croppedLength = $inWidth - $outWidth; + $widthPosition = floor($alignment * $croppedLength); } - return array( - "outWidth" => floor($outWidth), - "outHeight" => floor($outHeight), - "widthPosition" => floor($widthPosition), - "heightPosition" => floor($heightPosition) - ); + return array("outWidth" => $outWidth, "outHeight" => $outHeight, "widthPosition" => $widthPosition, "heightPosition" => $heightPosition); } protected function getCropDataArray($targetAspectRatio, $inWidth, $inHeight, $operationAttributes) @@ -1661,6 +1655,8 @@ protected function editConversionParams(&$flavorParamsObj, $conversionParams, $i $processingMode = $invertedResource ? 8 : 7; $flavorParamsObj->setAspectRatioProcessingMode($processingMode); $flavorParamsObj->setCropData(json_encode($cropData)); + $flavorParamsObj->setHeight($conversionParams[self::CROP_HEIGHT]); + $flavorParamsObj->setWidth($conversionParams[self::CROP_WIDTH]); } else if($invertedResource) { From 10b8ed060ab4e6246ba6aed5388c730761cec78f Mon Sep 17 00:00:00 2001 From: Salma Date: Sat, 10 Aug 2024 14:26:24 +0300 Subject: [PATCH 37/96] multi clip comments --- .../kaltura/lib/clipconcat/kClipManager.php | 90 ++++++++++++++++--- .../lib/data/resource/kOperationResources.php | 16 ++-- .../operations/kAspectRatioCropAttributes.php | 38 ++++++++ .../kAspectRatioScaleAttributes.php | 38 ++++++++ .../operations/kDimensionsAttributes.php | 11 +++ .../resource/KalturaOperationResources.php | 29 ++---- .../KalturaAspectRatioCropAttributes.php | 28 ++++++ .../KalturaAspectRatioScaleAttributes.php | 28 ++++++ .../operations/KalturaClipAttributes.php | 8 -- .../KalturaDimensionsAttributes.php | 9 ++ .../KalturaDimensionsAttributesArray.php | 29 ++++++ infra/cdl/kdl/KDLMediaObjectData.php | 1 + 12 files changed, 279 insertions(+), 46 deletions(-) create mode 100644 alpha/lib/data/resource/operations/kAspectRatioCropAttributes.php create mode 100644 alpha/lib/data/resource/operations/kAspectRatioScaleAttributes.php create mode 100644 alpha/lib/data/resource/operations/kDimensionsAttributes.php create mode 100644 api_v3/lib/types/resource/operations/KalturaAspectRatioCropAttributes.php create mode 100644 api_v3/lib/types/resource/operations/KalturaAspectRatioScaleAttributes.php create mode 100644 api_v3/lib/types/resource/operations/KalturaDimensionsAttributes.php create mode 100644 api_v3/lib/types/resource/operations/KalturaDimensionsAttributesArray.php diff --git a/alpha/apps/kaltura/lib/clipconcat/kClipManager.php b/alpha/apps/kaltura/lib/clipconcat/kClipManager.php index c98477be436..155a340b1f0 100644 --- a/alpha/apps/kaltura/lib/clipconcat/kClipManager.php +++ b/alpha/apps/kaltura/lib/clipconcat/kClipManager.php @@ -658,9 +658,9 @@ public function calculateAndEditConversionParams(&$resourcesData, $resources, $c $aspectRatios = array(); $allAudioChannels = array(); $allAudioSampleRates = array(); - $cropAspectRatio = $resources->getCropAspectRatio(); - $crop = $cropAspectRatio ? $cropAspectRatio->getCrop() : false; - $aspectRatio = $cropAspectRatio ? $cropAspectRatio->getAspectRatio() : null; + $dimensionsAttributes = $resources->getDimensionsAttributes(); + $crop = $this->getResourcesCropMode($dimensionsAttributes); + $aspectRatio = $this->getResourcesAspectRatio($dimensionsAttributes); foreach ($resourcesData as $key => $resourceData) { @@ -685,9 +685,18 @@ public function calculateAndEditConversionParams(&$resourcesData, $resources, $c $resourcesData[$key][self::CROP_DATA_ARRAY] = $this->getCropDataArray($aspectRatio, $currentWidth, $currentHeight, $resourceData[self::OPERATION_ATTRIBUTES_ARRAY]); if(count($resourcesData[$key][self::CROP_DATA_ARRAY]) > 0) { - // consider the dimensions after cropping to calculate target dimensions - $currentWidth = $resourcesData[$key][self::CROP_DATA_ARRAY][0]["outWidth"]; - $currentHeight = $resourcesData[$key][self::CROP_DATA_ARRAY][0]["outHeight"]; + foreach ($resourcesData[$key][self::CROP_DATA_ARRAY] as $cropDataArray) + { + // consider the dimensions after cropping to calculate target dimensions + $outWidth = isset($cropDataArray["outWidth"]) ? $cropDataArray["outWidth"] : null; + $outHeight = isset($cropDataArray["outHeight"]) ? $cropDataArray["outHeight"] : null; + if($outWidth && $outHeight) + { + $currentWidth = $outWidth; + $currentHeight = $outHeight; + break; + } + } } } @@ -739,8 +748,38 @@ public function calculateAndEditConversionParams(&$resourcesData, $resources, $c $this->setConversionParamsOnResourcesData($resourcesData, $generalConversionParams); } + protected function getResourcesCropMode($dimensionsAttributes) + { + foreach ($dimensionsAttributes as $dimensionsAttribute) + { + if($dimensionsAttribute instanceof kAspectRatioCropAttributes) + { + return true; + } + } + return false; + } + + protected function getResourcesAspectRatio($dimensionsAttributes) + { + foreach ($dimensionsAttributes as $dimensionsAttribute) + { + if($dimensionsAttribute instanceof kAspectRatioCropAttributes || $dimensionsAttribute instanceof kAspectRatioScaleAttributes) + { + return $dimensionsAttribute->getAspectRatio(); + } + } + return null; + } + protected function getCropData($targetAspectRatio, $inWidth, $inHeight, $cropAlignmentPercent = null) { + // missing dimensions + if(!$targetAspectRatio || !$inWidth || !$inHeight) + { + return array(); + } + // no cropping if($inWidth / $inHeight == $targetAspectRatio) { @@ -876,10 +915,20 @@ protected function setConversionParamsOnResourcesData(&$resourcesData, $conversi if($croppingMode) { $currentConversionParams[self::CROP_DATA_ARRAY] = $resourceData[self::CROP_DATA_ARRAY]; - $outHeight = $resourceData[self::CROP_DATA_ARRAY][0]["outHeight"]; - $outWidth = $resourceData[self::CROP_DATA_ARRAY][0]["outWidth"]; - $currentConversionParams[self::CROP_HEIGHT] = $outHeight; - $currentConversionParams[self::CROP_WIDTH] = $outWidth; + $outWidth = null; + $outHeight = null; + foreach ($resourceData[self::CROP_DATA_ARRAY] as $cropDataArray) + { + // consider the dimensions after cropping to calculate target dimensions + $outWidth = isset($cropDataArray["outWidth"]) ? $cropDataArray["outWidth"] : null; + $outHeight = isset($cropDataArray["outHeight"]) ? $cropDataArray["outHeight"] : null; + if($outWidth && $outHeight) + { + $currentConversionParams[self::CROP_HEIGHT] = $outHeight; + $currentConversionParams[self::CROP_WIDTH] = $outWidth; + break; + } + } $shouldScale = $outHeight != $targetHeight || $outWidth != $targetWidth; if($shouldScale) @@ -938,6 +987,12 @@ protected function shouldScaleNoCropping($inputMediaInfo, $outputWidth, $outputH $inputWidth = $inputMediaInfo->getVideoWidth(); $inputHeight = $inputMediaInfo->getVideoHeight(); + // missing dimensions + if(!$inputHeight || !$outputHeight) + { + return false; + } + $inputRatio = $inputWidth / $inputHeight; $outputRatio = $outputWidth / $outputHeight; @@ -1964,15 +2019,30 @@ protected function getSubtitlesDataFromConversionParams($conversionParams, $clip protected function getScaleFilter($ow, $oh, $iw = "iw", $ih = "ih") { + // missing dimensions + if(!$ow || !$oh || !$iw || !$ih) + { + return null; + } return "scale=$iw*min($ow/$iw\,$oh/$ih):$ih*min($ow/$iw\,$oh/$ih)"; } protected function getPadFilter($ow, $oh, $iw = "iw", $ih = "ih") { + // missing dimensions + if(!$ow || !$oh || !$iw || !$ih) + { + return null; + } return "pad=$ow:$oh:($ow-$iw)/2:($oh-$ih)/2"; } protected function getCropFilter($ow, $oh, $wp, $hp) { + // missing dimensions + if(!$ow || !$oh) + { + return null; + } return "crop=$ow:$oh:$wp:$hp"; } diff --git a/alpha/lib/data/resource/kOperationResources.php b/alpha/lib/data/resource/kOperationResources.php index 80d6824d9f8..335f1f0964f 100644 --- a/alpha/lib/data/resource/kOperationResources.php +++ b/alpha/lib/data/resource/kOperationResources.php @@ -17,16 +17,16 @@ class kOperationResources extends kContentResource private $chapterNamePolicy; /** - * @var KalturaCropAspectRatio + * @var array */ - private $cropAspectRatio; + private $dimensionsAttributes; /** - * @return KalturaCropAspectRatio + * @return array */ - public function getCropAspectRatio() + public function getDimensionsAttributes() { - return $this->cropAspectRatio; + return $this->dimensionsAttributes; } /** @@ -62,10 +62,10 @@ public function setChapterNamePolicy($chapterNamePolicy) } /** - * @param KalturaCropAspectRatio $cropAspectRatio + * @param array $dimensionsAttributes */ - public function setCropAspectRatio($cropAspectRatio) + public function setDimensionsAttributes($dimensionsAttributes) { - $this->cropAspectRatio = $cropAspectRatio; + $this->dimensionsAttributes = $dimensionsAttributes; } } diff --git a/alpha/lib/data/resource/operations/kAspectRatioCropAttributes.php b/alpha/lib/data/resource/operations/kAspectRatioCropAttributes.php new file mode 100644 index 00000000000..88d4f0e8bcb --- /dev/null +++ b/alpha/lib/data/resource/operations/kAspectRatioCropAttributes.php @@ -0,0 +1,38 @@ +aspectRatio; + } + + /** + * @param $aspectRatio float + */ + public function setAspectRatio($aspectRatio) + { + $this->aspectRatio = $aspectRatio; + } + + public function toArray() + { + return array('aspectRatio' => $this->aspectRatio); + } + + public function getApiType() + { + return 'KalturaAspectRatioCropAttributes'; + } +} diff --git a/alpha/lib/data/resource/operations/kAspectRatioScaleAttributes.php b/alpha/lib/data/resource/operations/kAspectRatioScaleAttributes.php new file mode 100644 index 00000000000..fe2363320b5 --- /dev/null +++ b/alpha/lib/data/resource/operations/kAspectRatioScaleAttributes.php @@ -0,0 +1,38 @@ +aspectRatio; + } + + /** + * @param $aspectRatio float + */ + public function setAspectRatio($aspectRatio) + { + $this->aspectRatio = $aspectRatio; + } + + public function toArray() + { + return array('aspectRatio' => $this->aspectRatio); + } + + public function getApiType() + { + return 'KalturaAspectRatioScaleAttributes'; + } +} diff --git a/alpha/lib/data/resource/operations/kDimensionsAttributes.php b/alpha/lib/data/resource/operations/kDimensionsAttributes.php new file mode 100644 index 00000000000..c4ae73748bd --- /dev/null +++ b/alpha/lib/data/resource/operations/kDimensionsAttributes.php @@ -0,0 +1,11 @@ +validatePropertyNotNull('resources'); + if($this->dimensionsAttributes && count($this->dimensionsAttributes) > 1) + { + throw new KalturaAPIException(KalturaErrors::MULTIPLE_PARAMETER_NOT_SUPPORTED, "dimensionsAttributes"); + } + $maxResourcesCount = kConf::get("maxOperationResourcesCount", kConfMapNames::RUNTIME_CONFIG, 5); if (count($this->resources) > $maxResourcesCount) { throw new KalturaAPIException(KalturaErrors::RESOURCES_COUNT_EXCEEDED_MAX_ALLOWED_COUNT, $maxResourcesCount); } - $this->validateCropAspectRatio(); $overallDuration = 0; foreach ($this->resources as $resource) { @@ -90,6 +94,7 @@ public function validateForUsage($sourceObject, $propertiesToSkip = array()) $overallDuration += $operationAttribute->duration; } } + $maxDurationSeconds = kConf::get("maxMultiClipsDurationSeconds", kConfMapNames::RUNTIME_CONFIG, 5 * 60 * 60); if ($overallDuration / 1000 > $maxDurationSeconds) { @@ -97,22 +102,6 @@ public function validateForUsage($sourceObject, $propertiesToSkip = array()) } } - protected function validateCropAspectRatio() - { - $cropAspectRatio = $this->cropAspectRatio; - if($cropAspectRatio) - { - if(!$cropAspectRatio->aspectRatio) - { - throw new KalturaAPIException(KalturaErrors::MISSING_MANDATORY_PARAMETER, "aspectRatio"); - } - if($cropAspectRatio->aspectRatio <= 0) - { - throw new KalturaAPIException(KalturaErrors::INVALID_PARAMETER_VALUE, "aspectRatio"); - } - } - } - /* (non-PHPdoc) * @see KalturaResource::entryHandled() */ diff --git a/api_v3/lib/types/resource/operations/KalturaAspectRatioCropAttributes.php b/api_v3/lib/types/resource/operations/KalturaAspectRatioCropAttributes.php new file mode 100644 index 00000000000..1a770f9b297 --- /dev/null +++ b/api_v3/lib/types/resource/operations/KalturaAspectRatioCropAttributes.php @@ -0,0 +1,28 @@ +captionAttributes as $captionAttribute) - { - $captionAttributes[] = $captionAttribute->toObject(); - } - $object_to_fill->setCaptionAttributes($captionAttributes); - return parent::toObject($object_to_fill, $props_to_skip); } } diff --git a/api_v3/lib/types/resource/operations/KalturaDimensionsAttributes.php b/api_v3/lib/types/resource/operations/KalturaDimensionsAttributes.php new file mode 100644 index 00000000000..0a2913c85e4 --- /dev/null +++ b/api_v3/lib/types/resource/operations/KalturaDimensionsAttributes.php @@ -0,0 +1,9 @@ +getApiType(); + $nObj = new $class(); + $nObj->fromObject($obj, $responseProfile); + $newArr[] = $nObj; + } + + return $newArr; + } + + public function __construct() + { + parent::__construct("KalturaDimensionsAttributes"); + } +} diff --git a/infra/cdl/kdl/KDLMediaObjectData.php b/infra/cdl/kdl/KDLMediaObjectData.php index 5b61831a16b..cc48909d0f7 100644 --- a/infra/cdl/kdl/KDLMediaObjectData.php +++ b/infra/cdl/kdl/KDLMediaObjectData.php @@ -213,6 +213,7 @@ class KDLVideoData extends KDLBaseMediaData { * 3: force 16/9 for everything that is not 16:9 * 4: force '-aspect' option * 5: force precise source AR + * 6: inverted source * 7: cropping * 8: inverted cropping */ From ea8a81125f2d560a68f44b6bac554c50bd2ffed3 Mon Sep 17 00:00:00 2001 From: Salma Date: Sun, 11 Aug 2024 08:57:16 +0300 Subject: [PATCH 38/96] sync subtitles --- alpha/apps/kaltura/lib/clipconcat/kClipManager.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/alpha/apps/kaltura/lib/clipconcat/kClipManager.php b/alpha/apps/kaltura/lib/clipconcat/kClipManager.php index 155a340b1f0..8a2575f92c9 100644 --- a/alpha/apps/kaltura/lib/clipconcat/kClipManager.php +++ b/alpha/apps/kaltura/lib/clipconcat/kClipManager.php @@ -898,6 +898,7 @@ protected function setConversionParamsOnResourcesData(&$resourcesData, $conversi { $imageToVideo = $resourceData[self::IMAGE_TO_VIDEO]; $mediaInfoObj = $resourceData[self::MEDIA_INFO_OBJECT]; + $subtitles = isset($resourceData[self::SUBTITLES_DATA_ARRAY]) && count($resourceData[self::SUBTITLES_DATA_ARRAY]) > 0; $currentConversionParams = array(); $currentConversionParams[self::TARGET_HEIGHT] = $targetHeight; @@ -964,6 +965,11 @@ protected function setConversionParamsOnResourcesData(&$resourcesData, $conversi $currentConversionParams[self::TARGET_WIDTH] = $targetWidth; // trigger scale } } + if($subtitles) + { + $prevParams = isset($currentConversionParams[self::EXTRA_CONVERSION_PARAMS]) ? $currentConversionParams[self::EXTRA_CONVERSION_PARAMS] : ""; + $currentConversionParams[self::EXTRA_CONVERSION_PARAMS] = $prevParams . " -copyts"; + } $resourcesData[$key][self::CONVERSION_PARAMS] = json_encode($currentConversionParams, true); } @@ -1399,7 +1405,7 @@ protected function startMultiResourceConcat(BatchJob $multiClipConcatJob) // assume concatenated assets have the same actualFlavorParamsId and take the last $lastAssetId = $flavorAssetId ? $flavorAssetId : $lastAssetId; } - $this->deleteEntry($jobData->getTempEntryId()); +// $this->deleteEntry($jobData->getTempEntryId()); } // use no filter because we delete the entry From 9f531f3a723a5aac7a8b2efb4a6f832cd63ce46f Mon Sep 17 00:00:00 2001 From: Salma Date: Sun, 11 Aug 2024 08:58:35 +0300 Subject: [PATCH 39/96] multi clip refactor --- alpha/apps/kaltura/lib/clipconcat/kClipManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alpha/apps/kaltura/lib/clipconcat/kClipManager.php b/alpha/apps/kaltura/lib/clipconcat/kClipManager.php index 8a2575f92c9..3e535a8ca2f 100644 --- a/alpha/apps/kaltura/lib/clipconcat/kClipManager.php +++ b/alpha/apps/kaltura/lib/clipconcat/kClipManager.php @@ -1405,7 +1405,7 @@ protected function startMultiResourceConcat(BatchJob $multiClipConcatJob) // assume concatenated assets have the same actualFlavorParamsId and take the last $lastAssetId = $flavorAssetId ? $flavorAssetId : $lastAssetId; } -// $this->deleteEntry($jobData->getTempEntryId()); + $this->deleteEntry($jobData->getTempEntryId()); } // use no filter because we delete the entry From 0e2dd0c64b38bdd25b85d58109b6667155d1fb3b Mon Sep 17 00:00:00 2001 From: Salma Date: Sun, 11 Aug 2024 09:02:11 +0300 Subject: [PATCH 40/96] indent --- infra/cdl/kdl/KDLMediaObjectData.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infra/cdl/kdl/KDLMediaObjectData.php b/infra/cdl/kdl/KDLMediaObjectData.php index cc48909d0f7..95eada24695 100644 --- a/infra/cdl/kdl/KDLMediaObjectData.php +++ b/infra/cdl/kdl/KDLMediaObjectData.php @@ -213,7 +213,7 @@ class KDLVideoData extends KDLBaseMediaData { * 3: force 16/9 for everything that is not 16:9 * 4: force '-aspect' option * 5: force precise source AR - * 6: inverted source + * 6: inverted source * 7: cropping * 8: inverted cropping */ From 2f714031ddadcd8cc1462beda9bcada7a45cf175 Mon Sep 17 00:00:00 2001 From: Salma Date: Tue, 13 Aug 2024 08:36:27 +0300 Subject: [PATCH 41/96] expose setting crop data --- .../modules/system/actions/flavorParamsAction.class.php | 1 + api_v3/generator/generate_xml.php | 2 ++ api_v3/lib/types/conversionProfile/KalturaFlavorParams.php | 6 ++++++ infra/content/kXsd.php | 6 ++++-- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/alpha/apps/kaltura/modules/system/actions/flavorParamsAction.class.php b/alpha/apps/kaltura/modules/system/actions/flavorParamsAction.class.php index 41631600b84..803bedaa556 100644 --- a/alpha/apps/kaltura/modules/system/actions/flavorParamsAction.class.php +++ b/alpha/apps/kaltura/modules/system/actions/flavorParamsAction.class.php @@ -110,6 +110,7 @@ public function execute() $this->editFlavorParam->setVideoBitrate($this->getRequestParameter("video-bitrate")); $this->editFlavorParam->setWatermarkData($this->getRequestParameter("watermarkData",0)); $this->editFlavorParam->setSubtitlesData($this->getRequestParameter("subtitlesData",0)); + $this->editFlavorParam->setCropData($this->getRequestParameter("cropData",0)); $this->editFlavorParam->setFrameRate($this->getRequestParameter("frame-rate")); $this->editFlavorParam->setMaxFrameRate($this->getRequestParameter("max-frame-rate")); $this->editFlavorParam->setGopSize($this->getRequestParameter("gop-size")); diff --git a/api_v3/generator/generate_xml.php b/api_v3/generator/generate_xml.php index 0135482e047..7a61210f838 100644 --- a/api_v3/generator/generate_xml.php +++ b/api_v3/generator/generate_xml.php @@ -53,6 +53,8 @@ function showHelpAndExit() $xmlGenerator->generate(); $files = $xmlGenerator->getOutputFiles(); +KalturaLog::log(print_r($files["KalturaClient.xml"], true)); + file_put_contents($xmlFileName, $files["KalturaClient.xml"]); KalturaLog::info("XML generated: $xmlFileName"); diff --git a/api_v3/lib/types/conversionProfile/KalturaFlavorParams.php b/api_v3/lib/types/conversionProfile/KalturaFlavorParams.php index 016377f8f08..29b6659d325 100644 --- a/api_v3/lib/types/conversionProfile/KalturaFlavorParams.php +++ b/api_v3/lib/types/conversionProfile/KalturaFlavorParams.php @@ -216,6 +216,11 @@ class KalturaFlavorParams extends KalturaAssetParams */ public $subtitlesData; + /** + * @var string + */ + public $cropData; + /** * @var int */ @@ -278,6 +283,7 @@ class KalturaFlavorParams extends KalturaAssetParams "videoBitrateTolerance", "watermarkData", "subtitlesData", + "cropData", "isEncrypted", "contentAwareness", "chunkedEncodeMode", diff --git a/infra/content/kXsd.php b/infra/content/kXsd.php index 7a252a1a2b8..3fe8a9a0fa1 100644 --- a/infra/content/kXsd.php +++ b/infra/content/kXsd.php @@ -465,10 +465,12 @@ public static function transformXmlData($xml, $xsdFile, $xslStr) { $from = new KDOMDocument(); $from->loadXML($xml); - + KalturaLog::log("========== here it is1: $xslStr"); + KalturaLog::log("========== here it is2: $xml"); + $xsl = new KDOMDocument(); $xsl->loadXML($xslStr); - + $proc = new XSLTProcessor(); $importStyleSheetResult = $proc->importStyleSheet($xsl); if(!$importStyleSheetResult) From 8c3e5546b75d3ea703dd0ddd773dbbc47076e5a1 Mon Sep 17 00:00:00 2001 From: Salma Date: Tue, 13 Aug 2024 08:46:37 +0300 Subject: [PATCH 42/96] remove log lines --- api_v3/generator/generate_xml.php | 2 -- infra/content/kXsd.php | 4 ---- 2 files changed, 6 deletions(-) diff --git a/api_v3/generator/generate_xml.php b/api_v3/generator/generate_xml.php index 7a61210f838..0135482e047 100644 --- a/api_v3/generator/generate_xml.php +++ b/api_v3/generator/generate_xml.php @@ -53,8 +53,6 @@ function showHelpAndExit() $xmlGenerator->generate(); $files = $xmlGenerator->getOutputFiles(); -KalturaLog::log(print_r($files["KalturaClient.xml"], true)); - file_put_contents($xmlFileName, $files["KalturaClient.xml"]); KalturaLog::info("XML generated: $xmlFileName"); diff --git a/infra/content/kXsd.php b/infra/content/kXsd.php index 3fe8a9a0fa1..4559afb1cb1 100644 --- a/infra/content/kXsd.php +++ b/infra/content/kXsd.php @@ -465,12 +465,8 @@ public static function transformXmlData($xml, $xsdFile, $xslStr) { $from = new KDOMDocument(); $from->loadXML($xml); - KalturaLog::log("========== here it is1: $xslStr"); - KalturaLog::log("========== here it is2: $xml"); - $xsl = new KDOMDocument(); $xsl->loadXML($xslStr); - $proc = new XSLTProcessor(); $importStyleSheetResult = $proc->importStyleSheet($xsl); if(!$importStyleSheetResult) From 8e3ba571cf23420bb6c50a60b69e784a5744a35a Mon Sep 17 00:00:00 2001 From: Salma Date: Tue, 13 Aug 2024 08:58:11 +0300 Subject: [PATCH 43/96] check fields subtitlesData --- .../batches/Convert/Engines/KConversionEngineFfmpeg.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/batch/batches/Convert/Engines/KConversionEngineFfmpeg.class.php b/batch/batches/Convert/Engines/KConversionEngineFfmpeg.class.php index 5bf87c42561..e20288e34b2 100644 --- a/batch/batches/Convert/Engines/KConversionEngineFfmpeg.class.php +++ b/batch/batches/Convert/Engines/KConversionEngineFfmpeg.class.php @@ -461,7 +461,7 @@ public static function buildSubtitlesCommandLine($subtitlesData, $data, $cmdLine * (this option is irrelevant for rendering) */ KalturaLog::log("subtitlesData:".json_encode($subtitlesData)); - $language = $subtitlesData->language ? $subtitlesData->language : "default"; + $language = isset($subtitlesData->language) && $subtitlesData->language ? $subtitlesData->language : "default"; $tmpCaptionFilePath = $data->destFileSyncLocalPath.".temp.$language.srt"; if(isset(KBatchBase::$taskConfig->params->sharedTempPath)) { @@ -469,7 +469,7 @@ public static function buildSubtitlesCommandLine($subtitlesData, $data, $cmdLine } $captionFilePath = null; - if($subtitlesData->captionFileUrl) + if(isset($subtitlesData->captionFileUrl) && $subtitlesData->captionFileUrl) { $captionFilePath = self::fetchCaptionFile($subtitlesData->captionFileUrl, $tmpCaptionFilePath); } From c8163d3f984948d0c728b02eea99045f79853a14 Mon Sep 17 00:00:00 2001 From: Anatol Date: Tue, 13 Aug 2024 10:55:40 +0300 Subject: [PATCH 44/96] Update chunk timeout logic Update chunk timeout logic to handle crashing pods cases --- .../KChunkedEncodeSessionManager.php | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/infra/chunkedEncode/KChunkedEncodeSessionManager.php b/infra/chunkedEncode/KChunkedEncodeSessionManager.php index c466a3d6cf6..2c79f0a571f 100644 --- a/infra/chunkedEncode/KChunkedEncodeSessionManager.php +++ b/infra/chunkedEncode/KChunkedEncodeSessionManager.php @@ -256,7 +256,7 @@ public function detectErrors($manager, $chunkedEncodeReadIdx, $chunker) // if(!array_key_exists($job->id, $this->failed)) { $job->timeout=1; - KalturaLog::log("($job->id, atm:$job->attempt)doubled the maxExecutionTime,$job->maxExecTime,elapsed:$elapsed"); + KalturaLog::log("($job->id, attm:$job->attempt) increase the maxExecutionTime,$job->maxExecTime,elapsed:$elapsed"); $this->failed[$job->id] = $job->keyIdx; } } @@ -677,9 +677,23 @@ protected function processFailedJob($job) $job->maxExecTime=round($job->maxExecTime*1.15); $job->timeout=0; $this->storeManager->SaveJob($job); - KalturaLog::log("Extend execution timeout, chunk ($job->id, maxExecTime:$job->maxExecTime, attempt:$job->attempt"); + // After 1/2 of the timeout retries (w/out retrying the chunk job), + // retry the chunk job afterall. + // It's needed to handle dying/crashing pods cases. + if($job->attempt<$this->maxRetries/2 + || (isset($job->changedJobOnTimeout) && $job->changedJobOnTimeout==1)) { + $this->storeManager->SaveJob($job); + KalturaLog::log("Extend execution timeout: chunk ($job->id, maxExecTime:$job->maxExecTime, attempt:$job->attempt)"); + return true; + } + else { + $job->changedJobOnTimeout=1; + KalturaLog::log("On timeout half attempts count - start new chunk job: chunk ($job->id, maxExecTime:$job->maxExecTime, attempt:$job->attempt)"); + KalturaLog::log("Extend execution timeout: chunk ($job->id, maxExecTime:$job->maxExecTime, attempt:$job->attempt)"); + } } - else { + + { $failedIdx = $job->keyIdx; $job->state = $job::STATE_RETRY; $this->storeManager->SaveJob($job); From 57ae9c3a7fad99cec8648d4d334c3f8a6bd44882 Mon Sep 17 00:00:00 2001 From: drorsouhami Date: Tue, 13 Aug 2024 15:20:25 +0300 Subject: [PATCH 45/96] PLAT-24923: Add fields to exported catalog items CSV --- .../csv/batch/BulkUploadVendorCatalogItemEngineCsv.php | 5 +++++ plugins/reach/admin/forms/CatalogItemConfigure.php | 3 --- plugins/reach/lib/kReachUtils.php | 7 ++++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/plugins/bulk_upload/csv/batch/BulkUploadVendorCatalogItemEngineCsv.php b/plugins/bulk_upload/csv/batch/BulkUploadVendorCatalogItemEngineCsv.php index 909da72bd89..aa2e4baa166 100644 --- a/plugins/bulk_upload/csv/batch/BulkUploadVendorCatalogItemEngineCsv.php +++ b/plugins/bulk_upload/csv/batch/BulkUploadVendorCatalogItemEngineCsv.php @@ -251,6 +251,11 @@ protected function createObjects() KBatchBase::$kClient->vendorCatalogItem->update($bulkUploadResult->vendorCatalogItemId, $vendorCatalogItem); break; + case KalturaBulkUploadAction::DELETE: + $bulkUploadResultChunk[] = $bulkUploadResult; + KBatchBase::$kClient->vendorCatalogItem->delete($bulkUploadResult->vendorCatalogItemId); + break; + case KalturaBulkUploadAction::UPDATE_STATUS: $bulkUploadResultChunk[] = $bulkUploadResult; KBatchBase::$kClient->vendorCatalogItem->updateStatus($bulkUploadResult->vendorCatalogItemId, KalturaVendorCatalogItemStatus::DEPRECATED); diff --git a/plugins/reach/admin/forms/CatalogItemConfigure.php b/plugins/reach/admin/forms/CatalogItemConfigure.php index 81077b0be57..5beece43c2a 100644 --- a/plugins/reach/admin/forms/CatalogItemConfigure.php +++ b/plugins/reach/admin/forms/CatalogItemConfigure.php @@ -63,7 +63,6 @@ public function init() $this->addElement('text', 'createdBy', array( 'label' => 'Created By:', - 'required' => true, 'filters' => array('StringTrim'), 'placement' => 'prepend', )); @@ -182,14 +181,12 @@ public function init() $this->addElement('text', 'contract', array( 'label' => 'Contract:', - 'required' => true, 'filters' => array('StringTrim'), 'placement' => 'prepend', )); $this->addElement('text', 'notes', array( 'label' => 'Notes:', - 'required' => true, 'filters' => array('StringTrim'), 'placement' => 'prepend', )); diff --git a/plugins/reach/lib/kReachUtils.php b/plugins/reach/lib/kReachUtils.php index 27d19880d6f..4cc0ef9b8cd 100644 --- a/plugins/reach/lib/kReachUtils.php +++ b/plugins/reach/lib/kReachUtils.php @@ -5,7 +5,7 @@ class kReachUtils { static private $catalogItemDateFields = array('createdAt', 'updatedAt'); - static private $catalogItemTranslateableFields = array('status','serviceType','serviceFeature','turnAroundTime','outputFormat'); + static private $catalogItemTranslateableFields = array('status','serviceType','serviceFeature','turnAroundTime','outputFormat','stage'); static private $entryVendorTaskDateFields = array('createdAt', 'expectedFinishTime'); static private $entryVendorTaskTranslateableFields = array('status','serviceType','serviceFeature','turnAroundTime'); @@ -16,7 +16,8 @@ class kReachUtils 'outputFormatEnumTranslate' => 'VendorCatalogItemOutputFormat', 'turnAroundTimeEnumTranslate' => 'VendorServiceTurnAroundTime', 'serviceFeatureEnumTranslate' => 'VendorServiceFeature', - 'serviceTypeEnumTranslate' => 'VendorServiceType' + 'serviceTypeEnumTranslate' => 'VendorServiceType', + 'stageEnumTranslate' => 'VendorCatalogItemStage', ); /** @@ -224,7 +225,7 @@ public static function getEntryVendorTaskCsvHeaders() */ public static function getVendorCatalogItemsCsvHeaders() { - return array('id','status','vendorPartnerId','name','systemName','serviceFeature','serviceType','turnAroundTime','sourceLanguage','targetLanguage','outputFormat','createdAt','updatedAt','enableSpeakerId','fixedPriceAddons','pricing:pricePerUnit','pricing:priceFunction', 'flavorParamsId', 'clearAudioFlavorParamsId','allowResubmission'); + return array('id','status','vendorPartnerId','name','systemName','serviceFeature','serviceType','turnAroundTime','sourceLanguage','targetLanguage','outputFormat','createdAt','updatedAt','enableSpeakerId','fixedPriceAddons','pricing:pricePerUnit','pricing:priceFunction', 'flavorParamsId', 'clearAudioFlavorParamsId','allowResubmission','requireSource','stage','contract','notes','createdBy'); } From dece8da44f2c488f0b50c3e709c042f578c3f215 Mon Sep 17 00:00:00 2001 From: Guy Elkayam Date: Wed, 14 Aug 2024 13:05:30 +0300 Subject: [PATCH 46/96] ONPREM-911 block running scripts in parallel (#12835) * Use same lock for both scripts, to avoid overriding temp file while other script is running. --- .../kava/copyRecordingPlaysviewsToLive.php | 15 +++++++++++++++ alpha/scripts/kava/updateEntryPlaysViews.php | 14 ++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/alpha/scripts/kava/copyRecordingPlaysviewsToLive.php b/alpha/scripts/kava/copyRecordingPlaysviewsToLive.php index 1f30536f75b..ad973342cc4 100644 --- a/alpha/scripts/kava/copyRecordingPlaysviewsToLive.php +++ b/alpha/scripts/kava/copyRecordingPlaysviewsToLive.php @@ -4,6 +4,16 @@ ini_set("memory_limit", "1024M"); define('ENTRIES_CHUNK', 500); +$lockTimeout = 5; +$lockDuration = 1 * 60 * 60; // one hour +$lockName = 'kava_plays_views_sync'; +$lock = kLock::create($lockName); +if ($lock && !$lock->lock($lockTimeout, $lockDuration)) +{ + KalturaLog::err('Failed to acquire script lock, aborting script.'); + die('Failed to acquire script lock, aborting script.' . PHP_EOL); +} + function handleChunk($currIdsMap) { global $fp, $map; @@ -118,3 +128,8 @@ function handleChunk($currIdsMap) fwrite($fp, implode("\t", $entryValues) . "\n"); } fclose($fp); + +if ($lock) +{ + $lock->unlock(); +} diff --git a/alpha/scripts/kava/updateEntryPlaysViews.php b/alpha/scripts/kava/updateEntryPlaysViews.php index 8c1b12fb07d..4a1ff16339a 100644 --- a/alpha/scripts/kava/updateEntryPlaysViews.php +++ b/alpha/scripts/kava/updateEntryPlaysViews.php @@ -2,6 +2,16 @@ require_once (dirname(__FILE__).'/../bootstrap.php'); +$lockTimeout = 5; +$lockDuration = 24 * 60 * 60 - 10; // a bit under 24 Hours +$lockName = 'kava_plays_views_sync'; +$lock = kLock::create($lockName); +if ($lock && !$lock->lock($lockTimeout, $lockDuration)) +{ + KalturaLog::err('Failed to acquire script lock, aborting script.'); + die('Failed to acquire script lock, aborting script.' . PHP_EOL); +} + $f = fopen("php://stdin", "r"); $count = 0; KalturaLog::log('Script Started'); @@ -191,4 +201,8 @@ entryPeer::clearInstancePool(); } } +if ($lock) +{ + $lock->unlock(); +} KalturaLog::log('Script Finished, Handled ' . $count . ' entries'); From 57a82262afb616f530bc371ecc0779f478f6aa85 Mon Sep 17 00:00:00 2001 From: rkreich Date: Tue, 6 Aug 2024 17:01:48 +0300 Subject: [PATCH 47/96] CR-19: Clips vendor task --- .../admin/CatalogItemConfigureAction.php | 3 + plugins/reach/admin/CatalogItemListAction.php | 2 + .../admin/PartnerCatalogItemListAction.php | 4 +- .../KExportEntryVendorTaskEngine.php | 1 + plugins/reach/config/lang/en.php | 1 + .../KalturaClipsVendorTaskData.php | 59 +++++++++++++++++++ .../entryVendorTaks/KalturaVendorTaskData.php | 4 ++ .../KalturaVendorCatalogItem.php | 4 ++ .../KalturaVendorClipsCatalogItem.php | 30 ++++++++++ .../KalturaVendorClipsCatalogItemFilter.php | 17 ++++++ plugins/reach/lib/model/VendorCatalogItem.php | 4 ++ .../reach/lib/model/VendorCatalogItemPeer.php | 6 +- .../lib/model/data/VendorClipsCatalogItem.php | 23 ++++++++ .../lib/model/data/kClipsVendorTaskData.php | 44 ++++++++++++++ .../lib/model/enums/VendorServiceFeature.php | 3 +- 15 files changed, 201 insertions(+), 4 deletions(-) create mode 100644 plugins/reach/lib/api/data/entryVendorTaks/KalturaClipsVendorTaskData.php create mode 100644 plugins/reach/lib/api/data/vendorCatalogItem/KalturaVendorClipsCatalogItem.php create mode 100644 plugins/reach/lib/api/data/vendorCatalogItem/filters/KalturaVendorClipsCatalogItemFilter.php create mode 100644 plugins/reach/lib/model/data/VendorClipsCatalogItem.php create mode 100644 plugins/reach/lib/model/data/kClipsVendorTaskData.php diff --git a/plugins/reach/admin/CatalogItemConfigureAction.php b/plugins/reach/admin/CatalogItemConfigureAction.php index 8ef733204e2..fd8901282f5 100644 --- a/plugins/reach/admin/CatalogItemConfigureAction.php +++ b/plugins/reach/admin/CatalogItemConfigureAction.php @@ -178,6 +178,9 @@ protected function handlePost($action, ConfigureForm $form, $catalogItemId = nul case Kaltura_Client_Reach_Enum_VendorServiceFeature::LIVE_CAPTION: $catalogItem = $form->getObject('Kaltura_Client_Reach_Type_VendorLiveCaptionCatalogItem', $formData, false, true); break; + case Kaltura_Client_Reach_Enum_VendorServiceFeature::CLIPS: + $catalogItem = $form->getObject('Kaltura_Client_Reach_Type_VendorClipsCatalogItem', $formData, false, true); + break; } $form->resetUnUpdatebleAttributes($catalogItem); diff --git a/plugins/reach/admin/CatalogItemListAction.php b/plugins/reach/admin/CatalogItemListAction.php index f2692772569..cbd0b3ef145 100644 --- a/plugins/reach/admin/CatalogItemListAction.php +++ b/plugins/reach/admin/CatalogItemListAction.php @@ -97,6 +97,8 @@ protected function getCatalogItemFilter($serviceFeature) return new Kaltura_Client_Reach_Type_VendorDubbingCatalogItemFilter(); elseif ($serviceFeature == Kaltura_Client_Reach_Enum_VendorServiceFeature::LIVE_CAPTION) return new Kaltura_Client_Reach_Type_VendorLiveCaptionCatalogItemFilter(); + elseif ($serviceFeature == Kaltura_Client_Reach_Enum_VendorServiceFeature::CLIPS) + return new Kaltura_Client_Reach_Type_VendorClipsCatalogItemFilter(); else return new Kaltura_Client_Reach_Type_VendorCatalogItemFilter(); } diff --git a/plugins/reach/admin/PartnerCatalogItemListAction.php b/plugins/reach/admin/PartnerCatalogItemListAction.php index 089d7e6956d..c84bf28245b 100644 --- a/plugins/reach/admin/PartnerCatalogItemListAction.php +++ b/plugins/reach/admin/PartnerCatalogItemListAction.php @@ -45,7 +45,7 @@ public function doAction(Zend_Controller_Action $action) $vendorCatalogItemFilter->partnerIdEqual = $partnerId; $vendorCatalogItemFilter->sourceLanguageEqual = $sourceLanguage; $vendorCatalogItemFilter->vendorPartnerIdEqual = $vendorPartnerId; - + if(in_array($serviceFeature, array(Kaltura_Client_Reach_Enum_VendorServiceFeature::TRANSLATION, Kaltura_Client_Reach_Enum_VendorServiceFeature::DUBBING))) { $vendorCatalogItemFilter->targetLanguageEqual = $targetLanguage; @@ -105,6 +105,8 @@ protected function getCatalogItemFilter($serviceFeature) return new Kaltura_Client_Reach_Type_VendorDubbingCatalogItemFilter(); elseif ($serviceFeature == Kaltura_Client_Reach_Enum_VendorServiceFeature::LIVE_CAPTION) return new Kaltura_Client_Reach_Type_VendorLiveCaptionCatalogItemFilter(); + elseif ($serviceFeature == Kaltura_Client_Reach_Enum_VendorServiceFeature::CLIPS) + return new Kaltura_Client_Reach_Type_VendorClipsCatalogItemFilter(); else return new Kaltura_Client_Reach_Type_VendorCatalogItemFilter(); } diff --git a/plugins/reach/batch/EntryVendorTasksCsv/KExportEntryVendorTaskEngine.php b/plugins/reach/batch/EntryVendorTasksCsv/KExportEntryVendorTaskEngine.php index 1773bc6b137..e06708027dd 100644 --- a/plugins/reach/batch/EntryVendorTasksCsv/KExportEntryVendorTaskEngine.php +++ b/plugins/reach/batch/EntryVendorTasksCsv/KExportEntryVendorTaskEngine.php @@ -28,6 +28,7 @@ class KExportEntryVendorTaskEngine extends KObjectExportEngine 5 => "CHAPTERING", 7 => "DUBBING", 9 => "EXTENDED_AUDIO_DESCRIPTION", + 10 => "CLIPS", "N/A" => "N/A", ); diff --git a/plugins/reach/config/lang/en.php b/plugins/reach/config/lang/en.php index 29c6dc99e81..dcdd218776b 100644 --- a/plugins/reach/config/lang/en.php +++ b/plugins/reach/config/lang/en.php @@ -6,6 +6,7 @@ 'Kaltura_Client_Reach_Enum_VendorServiceFeature::ALIGNMENT' => 'ALIGNMENT', 'Kaltura_Client_Reach_Enum_VendorServiceFeature::AUDIO_DESCRIPTION' => 'AUDIO_DESCRIPTION', 'Kaltura_Client_Reach_Enum_VendorServiceFeature::EXTENDED_AUDIO_DESCRIPTION' => 'EXTENDED_AUDIO_DESCRIPTION', + 'Kaltura_Client_Reach_Enum_VendorServiceFeature::CLIPS' => 'CLIPS', 'Kaltura_Client_Reach_Enum_VendorServiceFeature::CHAPTERING' => 'CHAPTERING', 'Kaltura_Client_Reach_Enum_VendorServiceFeature::DUBBING' => 'DUBBING', 'Kaltura_Client_Reach_Enum_VendorServiceFeature::INTELLIGENT_TAGGING' => 'INTELLIGENT_TAGGING', diff --git a/plugins/reach/lib/api/data/entryVendorTaks/KalturaClipsVendorTaskData.php b/plugins/reach/lib/api/data/entryVendorTaks/KalturaClipsVendorTaskData.php new file mode 100644 index 00000000000..55851e92e10 --- /dev/null +++ b/plugins/reach/lib/api/data/entryVendorTaks/KalturaClipsVendorTaskData.php @@ -0,0 +1,59 @@ +validatePropertyNotNull("clipsDuration"); + } +} diff --git a/plugins/reach/lib/api/data/entryVendorTaks/KalturaVendorTaskData.php b/plugins/reach/lib/api/data/entryVendorTaks/KalturaVendorTaskData.php index bcdf02a4772..97995c31513 100644 --- a/plugins/reach/lib/api/data/entryVendorTaks/KalturaVendorTaskData.php +++ b/plugins/reach/lib/api/data/entryVendorTaks/KalturaVendorTaskData.php @@ -64,6 +64,10 @@ public static function getInstance($sourceObject, KalturaDetachedResponseProfile case 'kScheduledVendorTaskData': $taskData = new KalturaScheduledVendorTaskData(); break; + + case 'kClipsVendorTaskData': + $taskData = new KalturaClipsVendorTaskData(); + break; } if ($taskData) diff --git a/plugins/reach/lib/api/data/vendorCatalogItem/KalturaVendorCatalogItem.php b/plugins/reach/lib/api/data/vendorCatalogItem/KalturaVendorCatalogItem.php index f92cafd44ab..15730ccc327 100644 --- a/plugins/reach/lib/api/data/vendorCatalogItem/KalturaVendorCatalogItem.php +++ b/plugins/reach/lib/api/data/vendorCatalogItem/KalturaVendorCatalogItem.php @@ -279,6 +279,10 @@ public static function getInstance($sourceObject, KalturaDetachedResponseProfile $object = new KalturaVendorLiveCaptionCatalogItem(); break; + case VendorServiceFeature::CLIPS: + $object = new KalturaVendorClipsCatalogItem(); + break; + default: $object = new KalturaVendorCaptionsCatalogItem(); break; diff --git a/plugins/reach/lib/api/data/vendorCatalogItem/KalturaVendorClipsCatalogItem.php b/plugins/reach/lib/api/data/vendorCatalogItem/KalturaVendorClipsCatalogItem.php new file mode 100644 index 00000000000..c6c563fc900 --- /dev/null +++ b/plugins/reach/lib/api/data/vendorCatalogItem/KalturaVendorClipsCatalogItem.php @@ -0,0 +1,30 @@ + self::TRANSLATION_OM_CLASS, @@ -35,7 +36,8 @@ class VendorCatalogItemPeer extends BaseVendorCatalogItemPeer VendorServiceFeature::CHAPTERING => self::CHAPTERING_OM_CLASS, VendorServiceFeature::DUBBING => self::DUBBING_OM_CLASS, VendorServiceFeature::INTELLIGENT_TAGGING => self::INTELLIGENT_TAGGING_OM_CLASS, - VendorServiceFeature::LIVE_CAPTION => self::LIVE_CAPTION_OM_CLASS + VendorServiceFeature::LIVE_CAPTION => self::LIVE_CAPTION_OM_CLASS, + VendorServiceFeature::CLIPS => self::CLIPS_OM_CLASS, ); public static function setDefaultCriteriaFilter () diff --git a/plugins/reach/lib/model/data/VendorClipsCatalogItem.php b/plugins/reach/lib/model/data/VendorClipsCatalogItem.php new file mode 100644 index 00000000000..41ed1328342 --- /dev/null +++ b/plugins/reach/lib/model/data/VendorClipsCatalogItem.php @@ -0,0 +1,23 @@ +setServiceFeature(VendorServiceFeature::CLIPS); + } + + public function isDuplicateTask(entry $entry): bool + { + return false; + } + + public function isEntryTypeSupported($type, $mediaType = null): bool + { + $supportedMediaTypes = [entry::ENTRY_MEDIA_TYPE_VIDEO, entry::ENTRY_MEDIA_TYPE_AUDIO]; + return $type === entryType::MEDIA_CLIP && in_array($mediaType, $supportedMediaTypes); + } +} diff --git a/plugins/reach/lib/model/data/kClipsVendorTaskData.php b/plugins/reach/lib/model/data/kClipsVendorTaskData.php new file mode 100644 index 00000000000..421a49eef18 --- /dev/null +++ b/plugins/reach/lib/model/data/kClipsVendorTaskData.php @@ -0,0 +1,44 @@ +clipsDuration; + } + + public function setClipsDuration(int $clipsDuration): void + { + $this->clipsDuration = $clipsDuration; + } + + public function getInstruction(): string + { + return $this->instruction; + } + + public function setInstruction(string $instruction): void + { + $this->instruction = $instruction; + } + + public function getClipsOutputJson(): ?string + { + return $this->clipsOutputJson; + } + + public function setClipsOutputJson(?string $clipsOutputJson): void + { + $this->clipsOutputJson = $clipsOutputJson; + } +} diff --git a/plugins/reach/lib/model/enums/VendorServiceFeature.php b/plugins/reach/lib/model/enums/VendorServiceFeature.php index 7a776c2a619..8912b3118e6 100644 --- a/plugins/reach/lib/model/enums/VendorServiceFeature.php +++ b/plugins/reach/lib/model/enums/VendorServiceFeature.php @@ -14,4 +14,5 @@ interface VendorServiceFeature extends BaseEnum const DUBBING = 7; const LIVE_CAPTION = 8; const EXTENDED_AUDIO_DESCRIPTION = 9; -} \ No newline at end of file + const CLIPS = 10; +} From 921e06de58d78d9d301d5be619bd423773d0fa19 Mon Sep 17 00:00:00 2001 From: Amir Asaelov Date: Tue, 7 Nov 2023 09:01:47 +0200 Subject: [PATCH 48/96] VCP-15234: delete local thumb tmp file of resizeEntryImage dies for whatever reason --- alpha/apps/kaltura/lib/myEntryUtils.class.php | 41 +++++++++++++++---- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/alpha/apps/kaltura/lib/myEntryUtils.class.php b/alpha/apps/kaltura/lib/myEntryUtils.class.php index 947788658ac..b6d7f541360 100644 --- a/alpha/apps/kaltura/lib/myEntryUtils.class.php +++ b/alpha/apps/kaltura/lib/myEntryUtils.class.php @@ -879,7 +879,9 @@ public static function resizeEntryImage( entry $entry, $version, $width, $height // remark added so ffmpeg will try to load the thumbnail from the original source if ($entry->getMediaType() == entry::ENTRY_MEDIA_TYPE_IMAGE && !kFile::checkFileExists($orig_image_path)) + { throw new kFileSyncException('no ready filesync on current DC', kFileSyncException::FILE_DOES_NOT_EXIST_ON_CURRENT_DC); + } // check a request for animated thumbs without a concrete vid_slice // in which case we'll create all the frames as one wide image @@ -895,12 +897,18 @@ public static function resizeEntryImage( entry $entry, $version, $width, $height $cacheLockKey = "thumb-processing-resize" . $finalThumbPath; // creating the thumbnail is a very heavy operation prevent calling it in parallel for the same thumbnail for 5 minutes if ($cache && !$cache->add($cacheLockKey, true, 5 * 60)) + { + myEntryUtils::deleteLocalTempFile($fileToDelete); KExternalErrors::dieError(KExternalErrors::PROCESSING_CAPTURE_THUMBNAIL); + } // limit creation of more than XX Imagemagick processes if (kConf::hasParam("resize_thumb_max_processes_imagemagick") && trim(exec("ps -e -ocmd|awk '{print $1}'|grep -c ".kConf::get("bin_path_imagemagick") )) > kConf::get("resize_thumb_max_processes_imagemagick")) + { + myEntryUtils::deleteLocalTempFile($fileToDelete); KExternalErrors::dieError(KExternalErrors::TOO_MANY_PROCESSES); + } if ($entry->getType() == entryType::PLAYLIST) myPlaylistUtils::updatePlaylistStatistics($entry->getPartnerId(), $entry); @@ -979,6 +987,7 @@ public static function resizeEntryImage( entry $entry, $version, $width, $height $cacheLockKeyProcessing = "thumb-processing".$orig_image_path; if ($cache && !$cache->add($cacheLockKeyProcessing, true, 5 * 60)) { + myEntryUtils::deleteLocalTempFile($fileToDelete); KExternalErrors::dieError(KExternalErrors::PROCESSING_CAPTURE_THUMBNAIL); } @@ -1006,7 +1015,7 @@ public static function resizeEntryImage( entry $entry, $version, $width, $height if (!$success) { - $success = self::captureLocalThumb($entry, $capturedThumbPath, $calc_vid_sec, $cache, $cacheLockKey, $cacheLockKeyProcessing, $flavorAssetId); + $success = self::captureLocalThumb($entry, $capturedThumbPath, $calc_vid_sec, $cache, $cacheLockKey, $cacheLockKeyProcessing, $flavorAssetId, $fileToDelete); } } @@ -1052,7 +1061,10 @@ public static function resizeEntryImage( entry $entry, $version, $width, $height else { if (!file_exists($orig_image_path) || !filesize($orig_image_path)) + { + myEntryUtils::deleteLocalTempFile($fileToDelete); KExternalErrors::dieError(KExternalErrors::IMAGE_RESIZE_FAILED); + } $imageSizeArray = getimagesize($orig_image_path); if ($thumbParams->getSupportAnimatedThumbnail() && is_array($imageSizeArray) && $imageSizeArray[2] === IMAGETYPE_GIF) @@ -1075,7 +1087,9 @@ public static function resizeEntryImage( entry $entry, $version, $width, $height } // die if resize operation failed - if ($convertedImagePath === null || !@kFile::fileSize($convertedImagePath)) { + if ($convertedImagePath === null || !@kFile::fileSize($convertedImagePath)) + { + myEntryUtils::deleteLocalTempFile($fileToDelete); KExternalErrors::dieError(KExternalErrors::IMAGE_RESIZE_FAILED); } @@ -1126,13 +1140,20 @@ public static function resizeEntryImage( entry $entry, $version, $width, $height } - if($fileToDelete) - { - kFile::doDeleteFile($fileToDelete); - } + myEntryUtils::deleteLocalTempFile($fileToDelete); return $finalThumbPath; } + + private static function deleteLocalTempFile($filepath) + { + if (!is_file($filepath)) + { + return; + } + + kFile::doDeleteFile($filepath); + } private static function isTempFile($filePath) { @@ -1171,7 +1192,7 @@ public static function getLiveEntryDcId($entryId, $type) * @return flavorAsset * @throws PropelException */ - public static function getFlavorAssetForLocalCapture($entry, $allowNull = false) + public static function getFlavorAssetForLocalCapture($entry, $allowNull = false, $fileToDelete = null) { $flavorAsset = assetPeer::retrieveHighestBitrateByEntryId($entry->getId(), flavorParams::TAG_THUMBSOURCE); if(is_null($flavorAsset)) @@ -1202,15 +1223,16 @@ public static function getFlavorAssetForLocalCapture($entry, $allowNull = false) if (is_null($flavorAsset) && !$allowNull) { + myEntryUtils::deleteLocalTempFile($fileToDelete); KExternalErrors::dieError(KExternalErrors::FLAVOR_NOT_FOUND); } return $flavorAsset; } - public static function captureLocalThumb($entry, $capturedThumbPath, $calc_vid_sec, $cache, $cacheLockKey, $cacheLockKeyProcessing, &$flavorAssetId, $width = -1, $height = -1) + public static function captureLocalThumb($entry, $capturedThumbPath, $calc_vid_sec, $cache, $cacheLockKey, $cacheLockKeyProcessing, &$flavorAssetId, $width = -1, $height = -1, $fileToDelete = null) { - $flavorAsset = self::getFlavorAssetForLocalCapture($entry); + $flavorAsset = self::getFlavorAssetForLocalCapture($entry, false, $fileToDelete); $flavorAssetId = $flavorAsset->getId(); $flavorSyncKey = $flavorAsset->getSyncKey(flavorAsset::FILE_SYNC_FLAVOR_ASSET_SUB_TYPE_ASSET); $entry_data_path = self::getEntryDataPath($flavorSyncKey, $flavorAsset); @@ -1228,6 +1250,7 @@ public static function captureLocalThumb($entry, $capturedThumbPath, $calc_vid_s $cache->delete($cacheLockKeyProcessing); } + myEntryUtils::deleteLocalTempFile($fileToDelete); KExternalErrors::dieError(KExternalErrors::TOO_MANY_PROCESSES); } From 877573a815b537b0988e860120209be14453834f Mon Sep 17 00:00:00 2001 From: MosheMaorKaltura Date: Tue, 20 Aug 2024 16:10:42 +0300 Subject: [PATCH 49/96] PLAT-24912:integration issues --- alpha/apps/kaltura/lib/v2Tov7Utils.class.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/alpha/apps/kaltura/lib/v2Tov7Utils.class.php b/alpha/apps/kaltura/lib/v2Tov7Utils.class.php index fea68098eee..e632a04ab71 100644 --- a/alpha/apps/kaltura/lib/v2Tov7Utils.class.php +++ b/alpha/apps/kaltura/lib/v2Tov7Utils.class.php @@ -71,15 +71,14 @@ static function addV2toV7config($flashvars, $uiconfId) { $config = []; //Merge v7 config - $config["uiconf_id"] = $uiconfId; + if($flashvars) - { - $config["flashvars"] = []; - foreach ($flashvars as $key => $value) { + { foreach ($flashvars as $key => $value) { $key = trim(trim($key, '"'), "'"); - $config['flashvars'][$key] = json_decode($value); + $config[$key] = json_decode($value); } } + $config["uiconf_id"] = $uiconfId; return $config; } From 664e877ffa0a2b9856b33ce77fe736c3695280a7 Mon Sep 17 00:00:00 2001 From: Amir Asaelov Date: Thu, 22 Aug 2024 14:47:40 +0300 Subject: [PATCH 50/96] SUP-43987: fix the retry when uploading via s3 multipart upload --- .../kS3SharedFileSystemMgr.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/infra/storage/shared_file_system_managers/kS3SharedFileSystemMgr.php b/infra/storage/shared_file_system_managers/kS3SharedFileSystemMgr.php index cf0772953a1..44ad70b8606 100644 --- a/infra/storage/shared_file_system_managers/kS3SharedFileSystemMgr.php +++ b/infra/storage/shared_file_system_managers/kS3SharedFileSystemMgr.php @@ -20,6 +20,7 @@ use Aws\S3\Exception\S3Exception; use Aws\Exception\AwsException; +use Aws\S3\Exception\S3MultipartUploadException; class kS3SharedFileSystemMgr extends kSharedFileSystemMgr { @@ -46,6 +47,7 @@ class kS3SharedFileSystemMgr extends kSharedFileSystemMgr protected $concurrency; protected $userAgentRegex; protected $userAgentPartner; + protected $multiPartUploadState; /* @var S3Client $s3Client */ protected $s3Client; @@ -76,7 +78,6 @@ public function __construct(array $options = null) $this->endPoint = isset($options['endPoint']) ? $options['endPoint'] : null; $this->accessKeySecret = isset($options['accessKeySecret']) ? $options['accessKeySecret'] : null; $this->accessKeyId = isset($options['accessKeyId']) ? $options['accessKeyId'] : null; - $this->endPoint = isset($options['endPoint']) ? $options['endPoint'] : null; $this->s3Arn = isset($options['arnRole']) ? $options['arnRole'] : $arnRole; $this->userAgentRegex = isset($options['userAgentRegex']) ? $options['userAgentRegex'] : null; } @@ -242,7 +243,7 @@ private function doPutFileHelper($filePath , $fileContent, $params) $filePath, $fileContent, $this->filesAcl, - array('params' => $params) + array('params' => $params) + (isset($this->multiPartUploadState) ? array('state' => $this->multiPartUploadState) : array()) ); KalturaLog::debug("File uploaded to s3, info: " . print_r($res, true)); @@ -251,6 +252,20 @@ private function doPutFileHelper($filePath , $fileContent, $params) catch (Exception $e) { KalturaLog::warning("Failed to uploaded to s3, info with message: " . $e->getMessage()); + + if ($e instanceof S3MultipartUploadException) + { + KalturaLog::debug("S3MultiPartUpload exception - attempting to resume failed parts"); + $this->multiPartUploadState = $e->getState(); + + // To resume S3MultiPartUpload, if the 'body' ($fileContent) is a resource of type 'stream' + // Need to rewind the pointer (https://docs.aws.amazon.com/en_us/aws-sdk-php/guide/latest/service/s3-multipart-upload.html) + if (is_resource($fileContent) && get_resource_type($fileContent) === 'stream') + { + rewind($fileContent); + } + } + return array(false, $e->getMessage()); } } From d9c6ae8ebf248b15c3c8c7aa8cb4e6511a11aada Mon Sep 17 00:00:00 2001 From: coralburg12 Date: Sun, 25 Aug 2024 17:37:45 +0300 Subject: [PATCH 51/96] SUP-44075: extract kuser id without init --- alpha/apps/kaltura/lib/KSecureEntryHelper.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alpha/apps/kaltura/lib/KSecureEntryHelper.class.php b/alpha/apps/kaltura/lib/KSecureEntryHelper.class.php index a62fdae54ca..a132ef56f76 100644 --- a/alpha/apps/kaltura/lib/KSecureEntryHelper.class.php +++ b/alpha/apps/kaltura/lib/KSecureEntryHelper.class.php @@ -159,7 +159,7 @@ public function validateApiAccessControl() public function validateForPlay($performApiAccessCheck = true) { if ($this->entry->getDisplayInSearch() === EntryDisplayInSearchType::RECYCLED && - !($this->entry->isOwnerActionsAllowed(kCurrentContext::getCurrentKsKuserId()) || $this->isKsAdmin())) + !($this->entry->isOwnerActionsAllowed($this->ks->getKuserId()) || $this->isKsAdmin())) { KExternalErrors::dieError(KExternalErrors::RECYCLED_ENTRY_UNAVAILABLE); } From aaff267b2126bc75133168fa9ad6642599d5581f Mon Sep 17 00:00:00 2001 From: Inbal BD Date: Wed, 28 Aug 2024 10:08:24 +0300 Subject: [PATCH 52/96] Updated version - Tucana-20.19.0 --- VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.txt b/VERSION.txt index 5955dc01d7b..35590595cb2 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -Tucana-20.18.0 +Tucana-20.19.0 From 0afe31da5cc4af9a021ff007984da0a5e561d82f Mon Sep 17 00:00:00 2001 From: Salma Date: Wed, 28 Aug 2024 10:31:10 +0300 Subject: [PATCH 53/96] fix copyts flag --- alpha/apps/kaltura/lib/clipconcat/kClipManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alpha/apps/kaltura/lib/clipconcat/kClipManager.php b/alpha/apps/kaltura/lib/clipconcat/kClipManager.php index 3e535a8ca2f..134da45b583 100644 --- a/alpha/apps/kaltura/lib/clipconcat/kClipManager.php +++ b/alpha/apps/kaltura/lib/clipconcat/kClipManager.php @@ -968,7 +968,7 @@ protected function setConversionParamsOnResourcesData(&$resourcesData, $conversi if($subtitles) { $prevParams = isset($currentConversionParams[self::EXTRA_CONVERSION_PARAMS]) ? $currentConversionParams[self::EXTRA_CONVERSION_PARAMS] : ""; - $currentConversionParams[self::EXTRA_CONVERSION_PARAMS] = $prevParams . " -copyts"; + $currentConversionParams[self::EXTRA_CONVERSION_PARAMS] = "$prevParams -copyts "; } $resourcesData[$key][self::CONVERSION_PARAMS] = json_encode($currentConversionParams, true); From 98a1e5326cf149a2c3e48a3f3c109e20d4993adb Mon Sep 17 00:00:00 2001 From: Salma Date: Wed, 28 Aug 2024 10:51:53 +0300 Subject: [PATCH 54/96] fix copyts flag --- alpha/apps/kaltura/lib/clipconcat/kClipManager.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/alpha/apps/kaltura/lib/clipconcat/kClipManager.php b/alpha/apps/kaltura/lib/clipconcat/kClipManager.php index 134da45b583..bec36f080bc 100644 --- a/alpha/apps/kaltura/lib/clipconcat/kClipManager.php +++ b/alpha/apps/kaltura/lib/clipconcat/kClipManager.php @@ -898,7 +898,14 @@ protected function setConversionParamsOnResourcesData(&$resourcesData, $conversi { $imageToVideo = $resourceData[self::IMAGE_TO_VIDEO]; $mediaInfoObj = $resourceData[self::MEDIA_INFO_OBJECT]; - $subtitles = isset($resourceData[self::SUBTITLES_DATA_ARRAY]) && count($resourceData[self::SUBTITLES_DATA_ARRAY]) > 0; + $subtitles = false; + if(isset($resourceData[self::SUBTITLES_DATA_ARRAY])) + { + foreach ($resourceData[self::SUBTITLES_DATA_ARRAY] as $subtitlesArray) + { + $subtitles = $subtitles || count($subtitlesArray) > 0; + } + } $currentConversionParams = array(); $currentConversionParams[self::TARGET_HEIGHT] = $targetHeight; From e0722aa21033ccc1078fdddb0a09410467277086 Mon Sep 17 00:00:00 2001 From: Amir Asaelov Date: Wed, 28 Aug 2024 14:06:48 +0300 Subject: [PATCH 55/96] VCP-18589: add 'updated_at' index to schemas --- alpha/config/schema.xml | 3 +++ alpha/data/sql/schema.sql | 1 + deployment/base/sql/01.kaltura_ce_tables.sql | 3 ++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/alpha/config/schema.xml b/alpha/config/schema.xml index 2bc814e4757..2df2e4ca10e 100644 --- a/alpha/config/schema.xml +++ b/alpha/config/schema.xml @@ -2103,6 +2103,9 @@ + + + diff --git a/alpha/data/sql/schema.sql b/alpha/data/sql/schema.sql index 6c239137f47..06b8df1962a 100644 --- a/alpha/data/sql/schema.sql +++ b/alpha/data/sql/schema.sql @@ -2387,6 +2387,7 @@ CREATE TABLE `kuser_kgroup` KEY `partner_kuser_index`(`kuser_id`, `status`), KEY `partner_kgroup_index`(`kgroup_id`, `status`), KEY `partner_index`(`partner_id`, `status`), + KEY `updated_at`(`updated_at`), CONSTRAINT `kuser_kgroup_FK_1` FOREIGN KEY (`kgroup_id`) REFERENCES `kuser` (`id`), diff --git a/deployment/base/sql/01.kaltura_ce_tables.sql b/deployment/base/sql/01.kaltura_ce_tables.sql index 79e0e7f1792..f6f4f8eaa93 100644 --- a/deployment/base/sql/01.kaltura_ce_tables.sql +++ b/deployment/base/sql/01.kaltura_ce_tables.sql @@ -1440,7 +1440,8 @@ CREATE TABLE IF NOT EXISTS `kuser_kgroup` ( PRIMARY KEY (`id`), KEY `partner_kuser_index` (`kuser_id`,`status`), KEY `partner_kgroup_index` (`kgroup_id`,`status`), - KEY `partner_index` (`partner_id`,`status`) + KEY `partner_index` (`partner_id`,`status`), + KEY `updated_at` (`updated_at`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; CREATE TABLE IF NOT EXISTS `kuser_to_user_role` ( From e532074319cf957ca845094b04935b52ae392b53 Mon Sep 17 00:00:00 2001 From: yossipapi Date: Wed, 28 Aug 2024 15:36:07 +0300 Subject: [PATCH 56/96] FOUN-1911: Avoid fatal error when hosts in sphinx lag ky do not match host in db.ini resulting in empty array of hostToLag --- alpha/apps/kaltura/lib/db/DbManager.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/alpha/apps/kaltura/lib/db/DbManager.php b/alpha/apps/kaltura/lib/db/DbManager.php index 0de0f956ec9..b0a7cc241ed 100644 --- a/alpha/apps/kaltura/lib/db/DbManager.php +++ b/alpha/apps/kaltura/lib/db/DbManager.php @@ -233,6 +233,12 @@ protected static function getSphinxConnIndexByLastUpdatedAt($dataSources) } list($hostToLag, $hostToIndex) = self::filterLagsAndHosts($dataSources, $lastUpdatedAtPerSphinx); + if(!count($hostToLag)) + { + KalturaLog::debug("failed to map sphinx host to sphinx lag data, no sphinx index will be chosen by updatedAt"); + return false; + } + return self::getPreferredSphinxIndexByWeight($hostToLag, $hostToIndex); } From 345cf6f9fc7007ddefede5d18db2540f97294f03 Mon Sep 17 00:00:00 2001 From: Amir Asaelov Date: Wed, 28 Aug 2024 15:39:26 +0300 Subject: [PATCH 57/96] VCP-18577: when importing files, if no 'filesize' from headers default to shared path --- batch/batches/Import/KAsyncImport.class.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/batch/batches/Import/KAsyncImport.class.php b/batch/batches/Import/KAsyncImport.class.php index 4f8b6bc412a..7447060182a 100644 --- a/batch/batches/Import/KAsyncImport.class.php +++ b/batch/batches/Import/KAsyncImport.class.php @@ -606,6 +606,12 @@ protected function getTempFilePath($remotePath, $fileSize = null) $rootPath = self::$taskConfig->params->localTempPath; $fileSizeThreshold = isset(self::$taskConfig->params->fileSizeThreshold) ? self::$taskConfig->params->fileSizeThreshold : null; $shardTempPath = isset(self::$taskConfig->params->sharedTempPath) ? self::$taskConfig->params->sharedTempPath : null; + + if (!$fileSize && $shardTempPath) + { + $rootPath = $shardTempPath; + } + if ($fileSize && $fileSizeThreshold && $shardTempPath && $fileSize > $fileSizeThreshold ) { $rootPath = $shardTempPath; From d1df7b5df2f393e4dc88b0564fbba4929b221f44 Mon Sep 17 00:00:00 2001 From: MosheMaorKaltura Date: Wed, 28 Aug 2024 15:58:51 +0300 Subject: [PATCH 58/96] PLAT-24912: Move v2Redirect to be a plugin --- alpha/apps/kaltura/lib/v2Tov7Utils.class.php | 34 +----------- .../actions/embedIframeJsAction.class.php | 9 ++-- .../actions/embedPlaykitJsAction.class.php | 25 +++++---- alpha/lib/model/uiConf.php | 32 +++--------- alpha/lib/model/uiConfV2Redirect.php | 49 +++++++++++++++++ api_v3/lib/types/KalturaUiConf.php | 18 ++----- api_v3/lib/types/KalturaUiConfV2Redirect.php | 52 +++++++++++++++++++ 7 files changed, 130 insertions(+), 89 deletions(-) create mode 100644 alpha/lib/model/uiConfV2Redirect.php create mode 100644 api_v3/lib/types/KalturaUiConfV2Redirect.php diff --git a/alpha/apps/kaltura/lib/v2Tov7Utils.class.php b/alpha/apps/kaltura/lib/v2Tov7Utils.class.php index e632a04ab71..f834de438af 100644 --- a/alpha/apps/kaltura/lib/v2Tov7Utils.class.php +++ b/alpha/apps/kaltura/lib/v2Tov7Utils.class.php @@ -5,10 +5,11 @@ class v2Tov7Utils const V2TOV7_PARAM_NAME = 'v2tov7'; const FLASHVARS_PARAM_NAME = 'flashvars'; const SHOULD_TRANSLATE_PLUGINS = self::V2TOV7_PARAM_NAME ."translate"; + const SCRIPT_PLUGIN_NAME = "playkit-player-scripts"; + const SCRIPT_PLUGIN_VERSION = "1.0.1-canary.0-f456898"; static private function getV7PluginInfo($v2PluginName): array { - KalturaLog::log("Searching for " . $v2PluginName . " " . strlen($v2PluginName)); $translation = self::v2toV7PluginMap(); if(isset($translation[$v2PluginName])) { @@ -104,35 +105,4 @@ private static function v2toV7PluginMap() "bumper" => [ "playkit-bumper" , "bumper" ], "infoScreen" => ["playkit-info", "playkit-js-info"]]; } - - public static function getBundledFacade() - { - //build key based on version - $facadeVersion = kConf::getArrayValue('v2tov7FacadeVersion','playkit-js'); - $facadeVersion .= "/v2tov7Facade.js"; - - //try get value from local memcache - $cacheStore = kCacheManager::getSingleLayerCache(kCacheManager::CACHE_TYPE_PLAYKIT_JS); - $bundledFacade = $cacheStore->get($facadeVersion); - if(strlen($bundledFacade)) - { - return $bundledFacade; - } - - //if not local - get it from remote location - $remoteUrl = kConf::getArrayValue('v2tov7FacadeRemoteUrl','playkit-js'); - $remoteUrl .= '/' . $facadeVersion; - - $curlWrapper = new KCurlWrapper(); - - $content = $curlWrapper->exec($remoteUrl,null, null, true); - if(KCurlHeaderResponse::isError($curlWrapper->getHttpCode())) - { - throw new Exception ('Cannot find V2 to V7 facade in the following URL: ' . $remoteUrl . "Error code:" . $curlWrapper->getHttpCode()); - } - - //store in local cache for next time - $cacheStore->set($facadeVersion,$content); - return $content; - } } \ No newline at end of file diff --git a/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php index 4b14d28d172..4999b9e31d4 100644 --- a/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php @@ -62,9 +62,12 @@ public function execute() $iframeEmbed = $this->getRequestParameter('iframeembed'); //redirect the call to V7 - if($uiConf->getV2tov7id() && ($this->getRequestParameter(v2Tov7Utils::V2TOV7_PARAM_NAME) || $uiConf->getV2tov7Approved()) ) + if( $uiConf->getV2Redirect() && + $uiConf->getV2Redirect()->getV7id() && + ( $uiConf->getV2Redirect()->getIsApproved() || $this->getRequestParameter(v2Tov7Utils::V2TOV7_PARAM_NAME) ) + ) { - $this->redirectToV7($uiConf->getV2tov7id(), $uiconf_id, $partner_id, $uiConf->getV2tov7ShouldTranslatePlugins() ); + $this->redirectToV7($uiConf->getV2Redirect()->getV7id(), $uiconf_id, $partner_id, $uiConf->getV2Redirect()->getTranslatePlugins() ); } @@ -171,8 +174,6 @@ private function redirectToV7($v7Id, $v2UiConfId, $partnerId, $shouldTranslatePl $config['bundleConfig'], $config['playerConfig']); } - //validate that the facade is reachable - v2Tov7Utils::getBundledFacade(); } catch(Exception $e) { diff --git a/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php index e2442264fe0..a41c979cd6a 100644 --- a/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php @@ -67,11 +67,6 @@ public function execute() $lastModified = $this->getLastModified($bundleContent); - if($this->getRequestParameter(v2Tov7Utils::V2TOV7_PARAM_NAME)) - { - $bundleContent .= PHP_EOL . v2Tov7Utils::getBundledFacade(); - } - //Format bundle content $bundleContent = $this->formatBundleContent($bundleContent, $i18nContent, $extraModulesNames); @@ -518,8 +513,8 @@ private function getAutoEmbedCode($targetId = null) if($this->getRequestParameter(v2Tov7Utils::V2TOV7_PARAM_NAME)) { $v2ToV7config = v2Tov7Utils::addV2toV7config($this->getRequestParameter(v2Tov7Utils::FLASHVARS_PARAM_NAME), $this->uiconfId); - $v2tov7ConfigJs = 'var v2toV7Config = window.v2tov7_buildConfigFromFlashvars(' . JSON_encode($v2ToV7config) . '); - config = {...config,...v2toV7Config};'; + $v2tov7ConfigJs = 'config = window.__buildV7Config('.JSON_encode($v2ToV7config).',config)'; + } $autoEmbedCode = " @@ -827,12 +822,16 @@ private function initMembers() $this->mergeVersionsParamIntoConfig(); - if($this->getRequestParameter(v2Tov7Utils::V2TOV7_PARAM_NAME) && $this->getRequestParameter(v2Tov7Utils::SHOULD_TRANSLATE_PLUGINS)) - { - v2Tov7Utils::addV2toV7plugins( - $this->getRequestParameter(v2Tov7Utils::FLASHVARS_PARAM_NAME), - $this->bundleConfig, - $this->playerConfig); + if($this->getRequestParameter(v2Tov7Utils::V2TOV7_PARAM_NAME)) + { + $this->bundleConfig[v2Tov7Utils::SCRIPT_PLUGIN_NAME] = v2Tov7Utils::SCRIPT_PLUGIN_VERSION; + if($this->getRequestParameter(v2Tov7Utils::SHOULD_TRANSLATE_PLUGINS)) + { + v2Tov7Utils::addV2toV7plugins( + $this->getRequestParameter(v2Tov7Utils::FLASHVARS_PARAM_NAME), + $this->bundleConfig, + $this->playerConfig); + } } if (!$this->bundleConfig) { diff --git a/alpha/lib/model/uiConf.php b/alpha/lib/model/uiConf.php index 508678c3876..a7c098bd870 100644 --- a/alpha/lib/model/uiConf.php +++ b/alpha/lib/model/uiConf.php @@ -114,9 +114,7 @@ class uiConf extends BaseuiConf implements ISyncableFile, IRelatedObject const CUSTOM_DATA_CON_FILE_VERSION = 'conf_file_version'; const CUSTOM_DATA_CONF_FILE_FEATURES_VERSION = 'conf_file_features_version'; - const CUSTOM_DATA_V2V7_ID = "v2v7_id"; - const CUSTOM_DATA_V2V7_APPROVED = "v2v7_approved"; - const CUSTOM_DATA_V2V7_TRANSLATE_PLUGINS = "v2v7_translate_plugins"; + const CUSTOM_DATA_V2REDIRECT = "v2redirect"; public function save(PropelPDO $con = null) { @@ -815,30 +813,14 @@ public function setVersion($v, $subType = self::FILE_SYNC_UICONF_SUB_TYPE_CONFIG } //v2 to v7 - public function getV2tov7id() + public function getV2Redirect() { - return $this->getFromCustomData(self::CUSTOM_DATA_V2V7_ID, null, null); + return $this->getFromCustomData( self::CUSTOM_DATA_V2REDIRECT); } - public function setV2tov7id($v) - { - return $this->putInCustomData(self::CUSTOM_DATA_V2V7_ID, $v); - } - public function getV2tov7Approved() - { - $val = $this->getFromCustomData(self::CUSTOM_DATA_V2V7_APPROVED, null, false, null); - return ($val === 1 || $val === true || $val === "true"); - } - public function setV2tov7Approved($v) - { - return $this->putInCustomData(self::CUSTOM_DATA_V2V7_APPROVED, $v); - } - public function getV2tov7ShouldTranslatePlugins() - { - $val = $this->getFromCustomData(self::CUSTOM_DATA_V2V7_TRANSLATE_PLUGINS, null, false, null); - return ($val === 1 || $val === true || $val === "true"); - } - public function setV2tov7ShouldTranslatePlugins($v) + + public function setV2Redirect($v) { - return $this->putInCustomData( self::CUSTOM_DATA_V2V7_TRANSLATE_PLUGINS, $v ); + KalturaLog::log(JSON_encode($v)); + return $this->putInCustomData(self::CUSTOM_DATA_V2REDIRECT, $v); } } diff --git a/alpha/lib/model/uiConfV2Redirect.php b/alpha/lib/model/uiConfV2Redirect.php new file mode 100644 index 00000000000..d00f6c28139 --- /dev/null +++ b/alpha/lib/model/uiConfV2Redirect.php @@ -0,0 +1,49 @@ +v7Id = $v; + } + + public function setIsApproved($v) + { + $this->isApproved = $v; + } + + public function setTranslatePlugins($v) + { + $this->translatePlugins = $v; + } + + public function getV7Id() + { + return $this->v7Id; + } + + public function getIsApproved() + { + return $this->isApproved; + } + + public function getTranslatePlugins() + { + return $this->translatePlugins; + } +} \ No newline at end of file diff --git a/api_v3/lib/types/KalturaUiConf.php b/api_v3/lib/types/KalturaUiConf.php index c9bd5d4e825..82b6a58a4ca 100644 --- a/api_v3/lib/types/KalturaUiConf.php +++ b/api_v3/lib/types/KalturaUiConf.php @@ -158,19 +158,9 @@ class KalturaUiConf extends KalturaObject implements IFilterable /** - * @var string - */ - public $v2tov7id; - - /** - * @var string - */ - public $v2tov7Approved; - - /** - * @var string + * @var KalturaUiConfV2Redirect */ - public $v2tov7ShouldTranslatePlugins; + public $v2Redirect; private static $map_between_objects = array @@ -199,9 +189,7 @@ class KalturaUiConf extends KalturaObject implements IFilterable "config", "version", "partnerTags", - "v2tov7id", - "v2tov7Approved", - "v2tov7ShouldTranslatePlugins" + "v2Redirect" ); public function getMapBetweenObjects ( ) diff --git a/api_v3/lib/types/KalturaUiConfV2Redirect.php b/api_v3/lib/types/KalturaUiConfV2Redirect.php new file mode 100644 index 00000000000..d82af40d894 --- /dev/null +++ b/api_v3/lib/types/KalturaUiConfV2Redirect.php @@ -0,0 +1,52 @@ +validatePropertyNumeric('v7id'); + $this->validatePropertyNotNull('isApproved'); + $this->validatePropertyNotNull('translatePlugins'); + $uiConfV2Redirect = new uiConfV2Redirect(); + return parent::toObject($uiConfV2Redirect, $props_to_skip); + } + + public function doFromObject($srcObj, KalturaDetachedResponseProfile $responseProfile = null) + { + $this->v7id = $srcObj->getV7Id(); + $this->isApproved = $srcObj->getIsApproved(); + $this->translatePlugins = $srcObj->getTranslatePlugins(); + parent::doFromObject($srcObj, $responseProfile); // TODO: Change the autogenerated stub + } +} \ No newline at end of file From ecb9813b3f142f127a2c0aa32da1fb5df822a86e Mon Sep 17 00:00:00 2001 From: MosheMaorKaltura Date: Wed, 28 Aug 2024 16:33:44 +0300 Subject: [PATCH 59/96] PLAT-24912: redirect v2 to v7 --- ...ls.class.php => v2RedirectUtils.class.php} | 27 ++++++++++++++----- .../actions/embedIframeJsAction.class.php | 12 ++++----- .../actions/embedPlaykitJsAction.class.php | 26 +++++++++--------- 3 files changed, 40 insertions(+), 25 deletions(-) rename alpha/apps/kaltura/lib/{v2Tov7Utils.class.php => v2RedirectUtils.class.php} (72%) diff --git a/alpha/apps/kaltura/lib/v2Tov7Utils.class.php b/alpha/apps/kaltura/lib/v2RedirectUtils.class.php similarity index 72% rename from alpha/apps/kaltura/lib/v2Tov7Utils.class.php rename to alpha/apps/kaltura/lib/v2RedirectUtils.class.php index f834de438af..ccc46a23f62 100644 --- a/alpha/apps/kaltura/lib/v2Tov7Utils.class.php +++ b/alpha/apps/kaltura/lib/v2RedirectUtils.class.php @@ -1,16 +1,29 @@ ["playkitscreen", "playkit-js-info"], + "quiz" => ["playkit-ivq", "ivq"], + "moderation" => ["playkit-moderation", "playkit-js-moderation"], + "playlistAPI" => ["playkit-playlist", "playlist"], + "liveStatus" => ["playkit-kaltura-live","kaltura-live"], + "related" => ["playkit-related", "related"], + "dualScreen" => ["playkit-dual-screen", "dualscreen"], + "video360" => ["playkit-vr" ,"vr"], + "raptMedia" => ["rapt", "rapt"], + "transcript" => ["playkit-transcript", "playkit-js-transcript"], + "qna" => ["playkit-qna", "qna"], + "bumper" => [ "playkit-bumper" , "bumper" ], + "infoScreen" => ["playkit-info", "playkit-js-info"]]; + if(isset($translation[$v2PluginName])) { $v7PluginInfo = $translation[$v2PluginName]; @@ -79,7 +92,7 @@ static function addV2toV7config($flashvars, $uiconfId) $config[$key] = json_decode($value); } } - $config["uiconf_id"] = $uiconfId; + $config["uiconf_id"] = $uiconfId; return $config; } diff --git a/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php index 4999b9e31d4..b14b7113691 100644 --- a/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php @@ -64,7 +64,7 @@ public function execute() //redirect the call to V7 if( $uiConf->getV2Redirect() && $uiConf->getV2Redirect()->getV7id() && - ( $uiConf->getV2Redirect()->getIsApproved() || $this->getRequestParameter(v2Tov7Utils::V2TOV7_PARAM_NAME) ) + ( $uiConf->getV2Redirect()->getIsApproved() || $this->getRequestParameter(v2RedirectUtils::V2REDIRECT_PARAM_NAME) ) ) { $this->redirectToV7($uiConf->getV2Redirect()->getV7id(), $uiconf_id, $partner_id, $uiConf->getV2Redirect()->getTranslatePlugins() ); @@ -166,11 +166,11 @@ private function redirectToV7($v7Id, $v2UiConfId, $partnerId, $shouldTranslatePl $config = array(); $config['bundleConfig'] = null; $config['playerConfig'] = new stdClass(); - v2Tov7Utils::addV2toV7config($this->getRequestParameter(v2Tov7Utils::FLASHVARS_PARAM_NAME),$v7Id); + v2RedirectUtils::addV2toV7config($this->getRequestParameter(v2RedirectUtils::FLASHVARS_PARAM_NAME),$v7Id); if($shouldTranslatePlugins) { - v2Tov7Utils::addV2toV7plugins( - $this->getRequestParameter(v2Tov7Utils::FLASHVARS_PARAM_NAME), + v2RedirectUtils::addV2toV7plugins( + $this->getRequestParameter(v2RedirectUtils::FLASHVARS_PARAM_NAME), $config['bundleConfig'], $config['playerConfig']); } @@ -182,11 +182,11 @@ private function redirectToV7($v7Id, $v2UiConfId, $partnerId, $shouldTranslatePl return; } - $shouldTranslatePluginsQueryParam = $shouldTranslatePlugins ? '&' . v2Tov7Utils::SHOULD_TRANSLATE_PLUGINS . '=true' : '' ; + $shouldTranslatePluginsQueryParam = $shouldTranslatePlugins ? '&' . v2RedirectUtils::SHOULD_TRANSLATE_PLUGINS . '=true' : '' ; $host = myPartnerUtils::getCdnHost($partnerId, null , 'api'); $url = $host . '/p/' . $partnerId . '/embedPlaykitJs/uiconf_id/' . $v7Id . '?' . $_SERVER['QUERY_STRING'] . "&" - . v2Tov7Utils::V2TOV7_PARAM_NAME .'=true' + . v2RedirectUtils::V2REDIRECT_PARAM_NAME .'=true' . $shouldTranslatePluginsQueryParam; header("Location:$url"); KExternalErrors::dieGracefully(); diff --git a/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php index a41c979cd6a..a4c17f446f8 100644 --- a/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php @@ -510,9 +510,9 @@ private function getAutoEmbedCode($targetId = null) } $v2tov7ConfigJs=''; - if($this->getRequestParameter(v2Tov7Utils::V2TOV7_PARAM_NAME)) + if($this->getRequestParameter(v2RedirectUtils::V2REDIRECT_PARAM_NAME)) { - $v2ToV7config = v2Tov7Utils::addV2toV7config($this->getRequestParameter(v2Tov7Utils::FLASHVARS_PARAM_NAME), $this->uiconfId); + $v2ToV7config = v2RedirectUtils::addV2toV7config($this->getRequestParameter(v2RedirectUtils::FLASHVARS_PARAM_NAME), $this->uiconfId); $v2tov7ConfigJs = 'config = window.__buildV7Config('.JSON_encode($v2ToV7config).',config)'; } @@ -822,16 +822,18 @@ private function initMembers() $this->mergeVersionsParamIntoConfig(); - if($this->getRequestParameter(v2Tov7Utils::V2TOV7_PARAM_NAME)) - { - $this->bundleConfig[v2Tov7Utils::SCRIPT_PLUGIN_NAME] = v2Tov7Utils::SCRIPT_PLUGIN_VERSION; - if($this->getRequestParameter(v2Tov7Utils::SHOULD_TRANSLATE_PLUGINS)) - { - v2Tov7Utils::addV2toV7plugins( - $this->getRequestParameter(v2Tov7Utils::FLASHVARS_PARAM_NAME), - $this->bundleConfig, - $this->playerConfig); - } + if($this->getRequestParameter(v2RedirectUtils::V2REDIRECT_PARAM_NAME)) + { + $this->bundleConfig[v2RedirectUtils::SCRIPT_PLUGIN_NAME] = + kConf::getArrayValue('v2RedirectPluginVersion', + 'playkit-js', 'local', v2RedirectUtils::SCRIPT_PLUGIN_VERSION); + if($this->getRequestParameter(v2RedirectUtils::SHOULD_TRANSLATE_PLUGINS)) + { + v2RedirectUtils::addV2toV7plugins( + $this->getRequestParameter(v2RedirectUtils::FLASHVARS_PARAM_NAME), + $this->bundleConfig, + $this->playerConfig); + } } if (!$this->bundleConfig) { From c016c3c6d7d11ef4146119f5fa1206ccf66a431e Mon Sep 17 00:00:00 2001 From: amirhalfon1 Date: Thu, 29 Aug 2024 11:03:37 +0300 Subject: [PATCH 60/96] KME-2084: add templateRoomEntryId to RoomEntry add templateRoomEntryId to RoomEntry, KME will use this room to calculate the room settings --- plugins/room/lib/api/KalturaRoomEntry.php | 36 +++++++++++++++++++++-- plugins/room/lib/model/RoomEntry.php | 11 +++++++ 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/plugins/room/lib/api/KalturaRoomEntry.php b/plugins/room/lib/api/KalturaRoomEntry.php index 0a95e435546..42f8f7abf3f 100644 --- a/plugins/room/lib/api/KalturaRoomEntry.php +++ b/plugins/room/lib/api/KalturaRoomEntry.php @@ -19,9 +19,16 @@ class KalturaRoomEntry extends KalturaBaseEntry */ public $broadcastEntryId; + /** + * The entryId of the room where settings will be taken from + * @var string + */ + public $templateRoomEntryId; + private static $map_between_objects = array( 'roomType', - 'broadcastEntryId' + 'broadcastEntryId', + 'templateRoomEntryId' ); public function __construct() @@ -47,8 +54,33 @@ public function toObject($object_to_fill = null, $props_to_skip = array()) public function validateForInsert($propertiesToSkip = array()) { $this->validatePropertyNotNull('roomType'); - + $this->validateTemplateRoomEntry(); return parent::validateForInsert($propertiesToSkip); } + public function validateForUpdate($sourceObject, $propertiesToSkip = array()) + { + $this->validateTemplateRoomEntry(); + return parent::validateForUpdate($sourceObject, $propertiesToSkip); + } + + public function validateTemplateRoomEntry() + { + if (!isset($this->templateRoomEntryId)) + { + return; + } + $entry = entryPeer::retrieveByPK($this->templateRoomEntryId); + if (!$entry) + { + throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $this->templateRoomEntryId); + } + if ($entry->getType() !== RoomPlugin::getEntryTypeCoreValue(RoomEntryType::ROOM)) + { + throw new KalturaAPIException(APIErrors::INVALID_FIELD_VALUE, 'templateRoomEntryId'); + } + } + + + } \ No newline at end of file diff --git a/plugins/room/lib/model/RoomEntry.php b/plugins/room/lib/model/RoomEntry.php index 0255a6e74bb..65f32edaf52 100644 --- a/plugins/room/lib/model/RoomEntry.php +++ b/plugins/room/lib/model/RoomEntry.php @@ -8,6 +8,7 @@ class RoomEntry extends entry const CUSTOM_DATA_ROOM_TYPE = 'roomType'; const CUSTOM_DATA_BROADCAST_ENTRY_ID = 'broadcastEntryId'; + const CUSTOM_DATA_TEMPLATE_ROOM_ENTRY_ID = 'templateRoomEntryId'; public function getRoomType() { @@ -19,6 +20,11 @@ public function getBroadcastEntryId() return $this->getFromCustomData(self::CUSTOM_DATA_BROADCAST_ENTRY_ID); } + public function getTemplateRoomEntryId() + { + return $this->getFromCustomData(self::CUSTOM_DATA_TEMPLATE_ROOM_ENTRY_ID); + } + public function setRoomType($v) { $this->putInCustomData(self::CUSTOM_DATA_ROOM_TYPE, $v); @@ -28,6 +34,11 @@ public function setBroadcastEntryId($v) { $this->putInCustomData(self::CUSTOM_DATA_BROADCAST_ENTRY_ID, $v); } + + public function setTemplateRoomEntryId($v) + { + $this->putInCustomData(self::CUSTOM_DATA_TEMPLATE_ROOM_ENTRY_ID, $v); + } public function getObjectParams($params = null) { From 320a53b2bece13189d94dfd823e6a9beb050fd3a Mon Sep 17 00:00:00 2001 From: yossipapi Date: Fri, 30 Aug 2024 18:44:24 +0300 Subject: [PATCH 61/96] Pass default values for optional params before passing file to delete --- alpha/apps/kaltura/lib/myEntryUtils.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alpha/apps/kaltura/lib/myEntryUtils.class.php b/alpha/apps/kaltura/lib/myEntryUtils.class.php index b6d7f541360..e412d0bff93 100644 --- a/alpha/apps/kaltura/lib/myEntryUtils.class.php +++ b/alpha/apps/kaltura/lib/myEntryUtils.class.php @@ -1015,7 +1015,7 @@ public static function resizeEntryImage( entry $entry, $version, $width, $height if (!$success) { - $success = self::captureLocalThumb($entry, $capturedThumbPath, $calc_vid_sec, $cache, $cacheLockKey, $cacheLockKeyProcessing, $flavorAssetId, $fileToDelete); + $success = self::captureLocalThumb($entry, $capturedThumbPath, $calc_vid_sec, $cache, $cacheLockKey, $cacheLockKeyProcessing, $flavorAssetId, -1, -1, $fileToDelete); } } From b20566db2fa025566b8cff08a73c9840dc0b49c6 Mon Sep 17 00:00:00 2001 From: amirhalfon1 Date: Mon, 2 Sep 2024 12:23:07 +0300 Subject: [PATCH 62/96] CR changes - fix indent, handle receive of "0" and "" --- plugins/room/lib/api/KalturaRoomEntry.php | 2 +- plugins/room/lib/model/RoomEntry.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/room/lib/api/KalturaRoomEntry.php b/plugins/room/lib/api/KalturaRoomEntry.php index 42f8f7abf3f..1db3704ae79 100644 --- a/plugins/room/lib/api/KalturaRoomEntry.php +++ b/plugins/room/lib/api/KalturaRoomEntry.php @@ -66,7 +66,7 @@ public function validateForUpdate($sourceObject, $propertiesToSkip = array()) public function validateTemplateRoomEntry() { - if (!isset($this->templateRoomEntryId)) + if (!isset($this->templateRoomEntryId) || $this->templateRoomEntryId === '') { return; } diff --git a/plugins/room/lib/model/RoomEntry.php b/plugins/room/lib/model/RoomEntry.php index 65f32edaf52..9fbeabb0c3e 100644 --- a/plugins/room/lib/model/RoomEntry.php +++ b/plugins/room/lib/model/RoomEntry.php @@ -20,10 +20,10 @@ public function getBroadcastEntryId() return $this->getFromCustomData(self::CUSTOM_DATA_BROADCAST_ENTRY_ID); } - public function getTemplateRoomEntryId() - { - return $this->getFromCustomData(self::CUSTOM_DATA_TEMPLATE_ROOM_ENTRY_ID); - } + public function getTemplateRoomEntryId() + { + return $this->getFromCustomData(self::CUSTOM_DATA_TEMPLATE_ROOM_ENTRY_ID); + } public function setRoomType($v) { From 7e6270ec9dabe8913562fa60d8558492f0722926 Mon Sep 17 00:00:00 2001 From: coralburg12 Date: Mon, 2 Sep 2024 12:48:16 +0300 Subject: [PATCH 63/96] SUP-43308: Enable recycle bin will force enable scheduled task permission --- alpha/apps/kaltura/lib/kPermissionManager.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/alpha/apps/kaltura/lib/kPermissionManager.php b/alpha/apps/kaltura/lib/kPermissionManager.php index a7cbc058ecc..3385f1feb1c 100644 --- a/alpha/apps/kaltura/lib/kPermissionManager.php +++ b/alpha/apps/kaltura/lib/kPermissionManager.php @@ -1120,6 +1120,12 @@ protected static function handleRecycleBinPermission($permission) if ($permission->getStatus() == PermissionStatus::ACTIVE) { self::enableRecycleBinScheduledTaskProfile($permission->getPartnerId()); + $scheduledTaskPluginPermission = PermissionPeer::getByNameAndPartner('SCHEDULEDTASK_PLUGIN_PERMISSION', array($permission->getPartnerId())); + if ($scheduledTaskPluginPermission->getStatus() != PermissionStatus::ACTIVE) + { + $scheduledTaskPluginPermission->setStatus(PermissionStatus::ACTIVE); + $scheduledTaskPluginPermission->save(); + } } elseif ($permission->getStatus() == PermissionStatus::BLOCKED) { From 0d45b6c0148a7292fb8e5ed136da563b2296e607 Mon Sep 17 00:00:00 2001 From: coralburg12 Date: Mon, 2 Sep 2024 13:25:23 +0300 Subject: [PATCH 64/96] SUP-43308: Enable recycle bin will force enable scheduled task permission --- alpha/apps/kaltura/lib/kPermissionManager.php | 17 +++++++++++------ alpha/lib/enums/PermissionName.php | 1 + 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/alpha/apps/kaltura/lib/kPermissionManager.php b/alpha/apps/kaltura/lib/kPermissionManager.php index 3385f1feb1c..1180cd68b4a 100644 --- a/alpha/apps/kaltura/lib/kPermissionManager.php +++ b/alpha/apps/kaltura/lib/kPermissionManager.php @@ -1120,18 +1120,23 @@ protected static function handleRecycleBinPermission($permission) if ($permission->getStatus() == PermissionStatus::ACTIVE) { self::enableRecycleBinScheduledTaskProfile($permission->getPartnerId()); - $scheduledTaskPluginPermission = PermissionPeer::getByNameAndPartner('SCHEDULEDTASK_PLUGIN_PERMISSION', array($permission->getPartnerId())); - if ($scheduledTaskPluginPermission->getStatus() != PermissionStatus::ACTIVE) - { - $scheduledTaskPluginPermission->setStatus(PermissionStatus::ACTIVE); - $scheduledTaskPluginPermission->save(); - } + self::enableRequiredPluginsPermissions($permission->getPartnerId(), PermissionName::SCHEDULEDTASK_PLUGIN_PERMISSION); } elseif ($permission->getStatus() == PermissionStatus::BLOCKED) { self::disableRecycleBinScheduledTaskProfile($permission->getPartnerId()); } } + + protected static function enableRequiredPluginsPermissions($partnerId, $permissionName) + { + $scheduledTaskPluginPermission = PermissionPeer::getByNameAndPartner($permissionName, array($partnerId)); + if ($scheduledTaskPluginPermission->getStatus() != PermissionStatus::ACTIVE) + { + $scheduledTaskPluginPermission->setStatus(PermissionStatus::ACTIVE); + $scheduledTaskPluginPermission->save(); + } + } protected static function enableRecycleBinScheduledTaskProfile($partnerId) { diff --git a/alpha/lib/enums/PermissionName.php b/alpha/lib/enums/PermissionName.php index ff8aa5ce32f..69a985a2000 100644 --- a/alpha/lib/enums/PermissionName.php +++ b/alpha/lib/enums/PermissionName.php @@ -95,6 +95,7 @@ interface PermissionName extends BaseEnum const GAME_PLUGIN_PERMISSION = 'GAME_PLUGIN_PERMISSION'; const FEATURE_ALLOW_CNC_PERMISSION = 'FEATURE_ALLOW_CNC_PERMISSION'; const FEATURE_RECYCLE_BIN = 'FEATURE_RECYCLE_BIN'; + const SCHEDULEDTASK_PLUGIN_PERMISSION = 'SCHEDULEDTASK_PLUGIN_PERMISSION'; const SSO_ADMIN_PERMISSION = 'SSO_ADMIN_PERMISSION'; const ALLOW_SSO_PER_USER = 'ALLOW_SSO_PER_USER'; const FEATURE_THEME_EDITOR_PERMISSION = 'FEATURE_THEME_EDITOR_PERMISSION'; From 1a1e045a3cf2b467e66bbcd3c531dae49e8f3829 Mon Sep 17 00:00:00 2001 From: Amir Asaelov Date: Mon, 2 Sep 2024 13:42:26 +0300 Subject: [PATCH 65/96] move logic to same if condition --- batch/batches/Import/KAsyncImport.class.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/batch/batches/Import/KAsyncImport.class.php b/batch/batches/Import/KAsyncImport.class.php index 7447060182a..df6b738e215 100644 --- a/batch/batches/Import/KAsyncImport.class.php +++ b/batch/batches/Import/KAsyncImport.class.php @@ -607,12 +607,7 @@ protected function getTempFilePath($remotePath, $fileSize = null) $fileSizeThreshold = isset(self::$taskConfig->params->fileSizeThreshold) ? self::$taskConfig->params->fileSizeThreshold : null; $shardTempPath = isset(self::$taskConfig->params->sharedTempPath) ? self::$taskConfig->params->sharedTempPath : null; - if (!$fileSize && $shardTempPath) - { - $rootPath = $shardTempPath; - } - - if ($fileSize && $fileSizeThreshold && $shardTempPath && $fileSize > $fileSizeThreshold ) + if ($shardTempPath && (!$fileSize || ($fileSizeThreshold && $fileSize > $fileSizeThreshold))) { $rootPath = $shardTempPath; } From 0f074f00600b4aded3ebc62302001ca51bab945c Mon Sep 17 00:00:00 2001 From: drorsouhami Date: Mon, 2 Sep 2024 15:16:39 +0300 Subject: [PATCH 66/96] REACH2-1236: Moved code to kReachUtils --- plugins/reach/lib/kReachUtils.php | 13 +++++++++++++ plugins/reach/services/EntryVendorTaskService.php | 7 ++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/plugins/reach/lib/kReachUtils.php b/plugins/reach/lib/kReachUtils.php index 4cc0ef9b8cd..c09f991a72a 100644 --- a/plugins/reach/lib/kReachUtils.php +++ b/plugins/reach/lib/kReachUtils.php @@ -203,6 +203,19 @@ public static function isFeatureTypeSupportedForEntry($entry, $featureType) return true; } + public static function isTranslationWithRequiredSource($dbVendorCatalogItem, $dbTaskData) + { + if ($dbVendorCatalogItem instanceof VendorTranslationCatalogItem && $dbVendorCatalogItem->getRequireSource()) + { + if (!$dbTaskData instanceof kTranslationVendorTaskData || !$dbTaskData->getCaptionAssetId()) + { + return false; + } + } + + return true; + } + public static function reachStrToTime($offset , $value) { $original = date_default_timezone_get(); diff --git a/plugins/reach/services/EntryVendorTaskService.php b/plugins/reach/services/EntryVendorTaskService.php index 2713e764f86..ddf8f3b34d4 100644 --- a/plugins/reach/services/EntryVendorTaskService.php +++ b/plugins/reach/services/EntryVendorTaskService.php @@ -68,12 +68,9 @@ public function addAction(KalturaEntryVendorTask $entryVendorTask) throw new KalturaAPIException(KalturaReachErrors::FEATURE_TYPE_NOT_SUPPORTED_FOR_ENTRY, $featureType, $entryVendorTask->entryId); } - if ($dbVendorCatalogItem instanceof VendorTranslationCatalogItem && $dbVendorCatalogItem->getRequireSource()) + if (!kReachUtils::isTranslationWithRequiredSource($dbVendorCatalogItem, $dbTaskData)) { - if (!$dbTaskData instanceof kTranslationVendorTaskData || !$dbTaskData->getCaptionAssetId()) - { - throw new KalturaAPIException(KalturaReachErrors::REQUIRE_CAPTION, $dbVendorCatalogItem->getId()); - } + throw new KalturaAPIException(KalturaReachErrors::REQUIRE_CAPTION, $dbVendorCatalogItem->getId()); } //check if credit has expired From f4b0f3629e9febc4ebf9b2941807e0442fd3a420 Mon Sep 17 00:00:00 2001 From: rkreich Date: Mon, 19 Aug 2024 17:47:44 +0300 Subject: [PATCH 67/96] CR-19: Added eventSessionContextId to clips vendor task --- .../entryVendorTaks/KalturaClipsVendorTaskData.php | 9 +++++++++ .../reach/lib/model/data/kClipsVendorTaskData.php | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/plugins/reach/lib/api/data/entryVendorTaks/KalturaClipsVendorTaskData.php b/plugins/reach/lib/api/data/entryVendorTaks/KalturaClipsVendorTaskData.php index 55851e92e10..9d3b9e5f037 100644 --- a/plugins/reach/lib/api/data/entryVendorTaks/KalturaClipsVendorTaskData.php +++ b/plugins/reach/lib/api/data/entryVendorTaks/KalturaClipsVendorTaskData.php @@ -15,6 +15,14 @@ class KalturaClipsVendorTaskData extends KalturaVendorTaskData */ public $clipsDuration; + /** + * Event session context ID used to enhance clip results. + * + * @insertonly + * @var string + */ + public $eventSessionContextId; + /** * Instruction describing the moments to capture or the objectives to achieve with the clips. * @@ -34,6 +42,7 @@ class KalturaClipsVendorTaskData extends KalturaVendorTaskData private static $map_between_objects = array ( 'clipsDuration', + 'eventSessionContextId', 'instruction', 'clipsOutputJson', ); diff --git a/plugins/reach/lib/model/data/kClipsVendorTaskData.php b/plugins/reach/lib/model/data/kClipsVendorTaskData.php index 421a49eef18..c7d6e7b1f58 100644 --- a/plugins/reach/lib/model/data/kClipsVendorTaskData.php +++ b/plugins/reach/lib/model/data/kClipsVendorTaskData.php @@ -8,6 +8,8 @@ class kClipsVendorTaskData extends kVendorTaskData { public int $clipsDuration = 0; + public ?string $eventSessionContextId = null; + public string $instruction = ""; public ?string $clipsOutputJson = null; @@ -17,6 +19,16 @@ public function getClipsDuration(): int return $this->clipsDuration; } + public function getEventSessionContextId(): ?string + { + return $this->eventSessionContextId; + } + + public function setEventSessionContextId(?string $eventSessionContextId): void + { + $this->eventSessionContextId = $eventSessionContextId; + } + public function setClipsDuration(int $clipsDuration): void { $this->clipsDuration = $clipsDuration; From 60b74b3815ef9f4f8a78fccb3a21dd50162e528f Mon Sep 17 00:00:00 2001 From: coralburg12 Date: Mon, 2 Sep 2024 15:59:15 +0300 Subject: [PATCH 68/96] SUP-43308: Enable recycle bin will force enable scheduled task permission --- alpha/apps/kaltura/lib/kPermissionManager.php | 8 ++++---- plugins/scheduled_task/ScheduledTaskPlugin.php | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/alpha/apps/kaltura/lib/kPermissionManager.php b/alpha/apps/kaltura/lib/kPermissionManager.php index 1180cd68b4a..b29e383506d 100644 --- a/alpha/apps/kaltura/lib/kPermissionManager.php +++ b/alpha/apps/kaltura/lib/kPermissionManager.php @@ -1130,11 +1130,11 @@ protected static function handleRecycleBinPermission($permission) protected static function enableRequiredPluginsPermissions($partnerId, $permissionName) { - $scheduledTaskPluginPermission = PermissionPeer::getByNameAndPartner($permissionName, array($partnerId)); - if ($scheduledTaskPluginPermission->getStatus() != PermissionStatus::ACTIVE) + $requiredPluginPermission = PermissionPeer::getByNameAndPartner($permissionName, array($partnerId)); + if ($requiredPluginPermission->getStatus() != PermissionStatus::ACTIVE) { - $scheduledTaskPluginPermission->setStatus(PermissionStatus::ACTIVE); - $scheduledTaskPluginPermission->save(); + $requiredPluginPermission->setStatus(PermissionStatus::ACTIVE); + $requiredPluginPermission->save(); } } diff --git a/plugins/scheduled_task/ScheduledTaskPlugin.php b/plugins/scheduled_task/ScheduledTaskPlugin.php index a7a7f7b43f8..94754e2153e 100644 --- a/plugins/scheduled_task/ScheduledTaskPlugin.php +++ b/plugins/scheduled_task/ScheduledTaskPlugin.php @@ -163,9 +163,9 @@ public static function getApplicationPages() */ public static function permissionEnabled($partnerId, $permissionName) { - if ($permissionName == 'SCHEDULEDTASK_PLUGIN_PERMISSION') + if ($permissionName == PermissionName::SCHEDULEDTASK_PLUGIN_PERMISSION) { - MediaRepurposingHandler::enableMrPermission($partnerId); + MediaRepurposingHandler::enanbleMrPermission($partnerId); } } } From 92ef0b747f1eb4641ebd00c7cf7ab22f45b26e1c Mon Sep 17 00:00:00 2001 From: drorsouhami Date: Tue, 3 Sep 2024 10:15:21 +0300 Subject: [PATCH 69/96] REACH2-1235: Improved datepicker functionality --- plugins/reach/admin/ReachRequestsListAction.php | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/plugins/reach/admin/ReachRequestsListAction.php b/plugins/reach/admin/ReachRequestsListAction.php index 7da672ed8bc..0122d0ac97a 100644 --- a/plugins/reach/admin/ReachRequestsListAction.php +++ b/plugins/reach/admin/ReachRequestsListAction.php @@ -45,7 +45,7 @@ public function doAction(Zend_Controller_Action $action) protected function initFilter($request) { $entryVendorTaskFilter = $this->getEntryVendorTaskFilter($request); - $this->setCreatedAtFilter($entryVendorTaskFilter); + $entryVendorTaskFilter->orderBy = '-createdAt'; $this->setStatusFilter($request, $entryVendorTaskFilter); kReachUtils::setSelectedRelativeTime($request->getParam('from_time'), $entryVendorTaskFilter); return $entryVendorTaskFilter; @@ -93,12 +93,6 @@ protected function getEntryVendorTaskFilter(Zend_Controller_Request_Abstract $re return $filter; } - protected function setCreatedAtFilter($entryVendorTaskFilter) - { - $entryVendorTaskFilter->updatedAtGreaterThanOrEqual = time() - (VendorServiceTurnAroundTime::TEN_DAYS + VendorServiceTurnAroundTime::TWENTY_FOUR_HOURS); - $entryVendorTaskFilter->orderBy = '-createdAt'; - } - protected function setStatusFilter($request, $entryVendorTaskFilter) { $filterStatusInput = $request->getParam('filter_status'); @@ -138,20 +132,19 @@ private function addCreatedAtParamsToFilter($request, $action, &$entryVendorTask { if ($request->getParam('createdAtFrom', false)) { - $createdAtFrom = new Zend_Date($this->_getParam('createdAtFrom', $this->getDefaultFromDate())); + $createdAtFrom = new Zend_Date($this->_getParam('createdAtFrom'), 'MM/DD/YYYY'); $entryVendorTaskFilter->createdAtGreaterThanOrEqual = $createdAtFrom->toString(Zend_Date::TIMESTAMP); } else { $createdAtFrom = $action->view->filterForm->getElement('createdAtFrom'); $createdAtFrom->setValue(date('m/d/Y', $this->getDefaultFromDate())); - $entryVendorTaskFilter->createdAtGreaterThanOrEqual = $this->getDefaultFromDate(); } if ($request->getParam('createdAtTo', false)) { - $createdAtTo = new Zend_Date($this->_getParam('createdAtTo', $this->getDefaultToDate())); + $createdAtTo = new Zend_Date($this->_getParam('createdAtTo'), 'MM/DD/YYYY'); $createdAtTo->addDay(1); $entryVendorTaskFilter->createdAtLessThanOrEqual = $createdAtTo->toString(Zend_Date::TIMESTAMP); } @@ -159,7 +152,6 @@ private function addCreatedAtParamsToFilter($request, $action, &$entryVendorTask { $createdAtTo = $action->view->filterForm->getElement('createdAtTo'); $createdAtTo->setValue(date('m/d/Y', $this->getDefaultToDate())); - $entryVendorTaskFilter->createdAtLessThanOrEqual = $this->getDefaultToDate(); } } From 6d65a70c08b149d1f4e1b0583f9f58cf19dfad33 Mon Sep 17 00:00:00 2001 From: drorsouhami Date: Tue, 3 Sep 2024 10:23:31 +0300 Subject: [PATCH 70/96] REACH2-1236: Renamed utility function --- plugins/reach/lib/kReachUtils.php | 2 +- plugins/reach/services/EntryVendorTaskService.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/reach/lib/kReachUtils.php b/plugins/reach/lib/kReachUtils.php index c09f991a72a..55c08a506d3 100644 --- a/plugins/reach/lib/kReachUtils.php +++ b/plugins/reach/lib/kReachUtils.php @@ -203,7 +203,7 @@ public static function isFeatureTypeSupportedForEntry($entry, $featureType) return true; } - public static function isTranslationWithRequiredSource($dbVendorCatalogItem, $dbTaskData) + public static function verifyRequiredSource($dbVendorCatalogItem, $dbTaskData) { if ($dbVendorCatalogItem instanceof VendorTranslationCatalogItem && $dbVendorCatalogItem->getRequireSource()) { diff --git a/plugins/reach/services/EntryVendorTaskService.php b/plugins/reach/services/EntryVendorTaskService.php index ddf8f3b34d4..9e976380df8 100644 --- a/plugins/reach/services/EntryVendorTaskService.php +++ b/plugins/reach/services/EntryVendorTaskService.php @@ -68,7 +68,7 @@ public function addAction(KalturaEntryVendorTask $entryVendorTask) throw new KalturaAPIException(KalturaReachErrors::FEATURE_TYPE_NOT_SUPPORTED_FOR_ENTRY, $featureType, $entryVendorTask->entryId); } - if (!kReachUtils::isTranslationWithRequiredSource($dbVendorCatalogItem, $dbTaskData)) + if (!kReachUtils::verifyRequiredSource($dbVendorCatalogItem, $dbTaskData)) { throw new KalturaAPIException(KalturaReachErrors::REQUIRE_CAPTION, $dbVendorCatalogItem->getId()); } From f15055cbe011bd8788ce49352e42f84983307f0e Mon Sep 17 00:00:00 2001 From: Salma Date: Tue, 3 Sep 2024 10:36:50 +0300 Subject: [PATCH 71/96] add media repurposing metadata profile for enabling media repurposing NG permission --- alpha/apps/kaltura/lib/kPermissionManager.php | 20 +++++++++++++++---- alpha/lib/enums/PermissionName.php | 1 + 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/alpha/apps/kaltura/lib/kPermissionManager.php b/alpha/apps/kaltura/lib/kPermissionManager.php index a7cbc058ecc..879834a7c57 100644 --- a/alpha/apps/kaltura/lib/kPermissionManager.php +++ b/alpha/apps/kaltura/lib/kPermissionManager.php @@ -1093,17 +1093,29 @@ public function objectCreated(BaseObject $object) return true; } - protected static function handlePermissions($object) + protected static function handlePermissions($permission) { - switch ($object->getName()) + switch ($permission->getName()) { case PermissionName::FEATURE_RECYCLE_BIN: - self::handleRecycleBinPermission($object); + self::handleRecycleBinPermission($permission); return; case PermissionName::GAME_PLUGIN_PERMISSION: - self::handleGamePluginPermission($object); + self::handleGamePluginPermission($permission); return; + + case PermissionName::FEATURE_MEDIA_REPURPOSING_NG_PERMISSION: + self::handleMediaRepurposingNGPermission($permission); + return; + } + } + + protected static function handleMediaRepurposingNGPermission($permission) + { + if ($permission->getStatus() == PermissionStatus::ACTIVE) + { + MediaRepurposingHandler::enableMrPermission($permission->getPartnerId()); } } diff --git a/alpha/lib/enums/PermissionName.php b/alpha/lib/enums/PermissionName.php index ff8aa5ce32f..477fd3c1436 100644 --- a/alpha/lib/enums/PermissionName.php +++ b/alpha/lib/enums/PermissionName.php @@ -93,6 +93,7 @@ interface PermissionName extends BaseEnum const FEATURE_ALLOW_VAST_CUE_POINT_NO_URL = 'FEATURE_ALLOW_VAST_CUE_POINT_NO_URL'; const VIRTUALEVENT_PLUGIN_PERMISSION = 'VIRTUALEVENT_PLUGIN_PERMISSION'; const GAME_PLUGIN_PERMISSION = 'GAME_PLUGIN_PERMISSION'; + const FEATURE_MEDIA_REPURPOSING_NG_PERMISSION = 'FEATURE_MEDIA_REPURPOSING_NG_PERMISSION'; const FEATURE_ALLOW_CNC_PERMISSION = 'FEATURE_ALLOW_CNC_PERMISSION'; const FEATURE_RECYCLE_BIN = 'FEATURE_RECYCLE_BIN'; const SSO_ADMIN_PERMISSION = 'SSO_ADMIN_PERMISSION'; From e66cff46cbcbca83aaef653c47232a0181c89790 Mon Sep 17 00:00:00 2001 From: "daniel.barak" Date: Tue, 3 Sep 2024 13:20:44 +0300 Subject: [PATCH 72/96] PLAT-24930: Add enum value "reels-player" to the ui-confs types --- admin_console/configs/lang/en.php | 1 + alpha/lib/model/uiConf.php | 4 ++++ api_v3/lib/types/enums/KalturaUiConfObjType.php | 1 + configurations/admin.template.ini | 1 + release-notes.md | 9 +++++++++ var_console/configs/lang/en.php | 1 + 6 files changed, 17 insertions(+) diff --git a/admin_console/configs/lang/en.php b/admin_console/configs/lang/en.php index baa1074156e..8177df33464 100644 --- a/admin_console/configs/lang/en.php +++ b/admin_console/configs/lang/en.php @@ -393,6 +393,7 @@ 'Kaltura_Client_Enum_UiConfObjType::WEBCASTING' => 'Kaltura Webcasting Studio', 'Kaltura_Client_Enum_UiConfObjType::CLIPPER' => 'KMC Clipper', 'Kaltura_Client_Enum_UiConfObjType::SAP' => 'Slim Audio Player', + 'Kaltura_Client_Enum_UiConfObjType::REELS' => 'Reels Player', //audit trail 'Kaltura_Client_Enum_AuditTrailObjectType::ACCESS_CONTROL' => 'ACCESS_CONTROL', diff --git a/alpha/lib/model/uiConf.php b/alpha/lib/model/uiConf.php index 7c3b67c1388..b7d2e8739ed 100644 --- a/alpha/lib/model/uiConf.php +++ b/alpha/lib/model/uiConf.php @@ -35,6 +35,7 @@ class uiConf extends BaseuiConf implements ISyncableFile, IRelatedObject const UI_CONF_TYPE_KUPLOAD = 20; const UI_CONF_TYPE_WEBCASTING = 21; const UI_CONF_TYPE_SAP = 22; + const UI_CONF_TYPE_REELS = 23; const UI_CONF_CREATION_MODE_MANUAL = 1; @@ -84,6 +85,7 @@ class uiConf extends BaseuiConf implements ISyncableFile, IRelatedObject self::UI_CONF_TYPE_KUPLOAD => "KUpload.swf", self::UI_CONF_TYPE_WEBCASTING => "", self::UI_CONF_TYPE_SAP => "", + self::UI_CONF_TYPE_REELS => "", ); private static $swf_directory_map = array ( @@ -109,6 +111,7 @@ class uiConf extends BaseuiConf implements ISyncableFile, IRelatedObject self::UI_CONF_TYPE_KUPLOAD => "kupload", self::UI_CONF_TYPE_WEBCASTING => "", self::UI_CONF_TYPE_SAP => "", + self::UI_CONF_TYPE_REELS => "", ); const CUSTOM_DATA_CON_FILE_VERSION = 'conf_file_version'; @@ -212,6 +215,7 @@ private static function initUiConfTypeMap() self::UI_CONF_TYPE_KUPLOAD => "Kaltura Simple Uploader", self::UI_CONF_TYPE_WEBCASTING => "Kaltura Webcasting Studio", self::UI_CONF_TYPE_SAP => "Slim Audio Player", + self::UI_CONF_TYPE_REELS => "Reels Player", ); } } diff --git a/api_v3/lib/types/enums/KalturaUiConfObjType.php b/api_v3/lib/types/enums/KalturaUiConfObjType.php index c7989eb2406..0fad97a5c88 100644 --- a/api_v3/lib/types/enums/KalturaUiConfObjType.php +++ b/api_v3/lib/types/enums/KalturaUiConfObjType.php @@ -27,4 +27,5 @@ class KalturaUiConfObjType extends KalturaEnum const KUPLOAD = 20; const WEBCASTING = 21; const SAP = 22; + const REELS = 23; } diff --git a/configurations/admin.template.ini b/configurations/admin.template.ini index 211c57546ae..88cfc7948b5 100644 --- a/configurations/admin.template.ini +++ b/configurations/admin.template.ini @@ -47,6 +47,7 @@ settings.uiConfTypes[] = Kaltura_Client_Enum_UiConfObjType::CLIPPER settings.uiConfTypes[] = Kaltura_Client_Enum_UiConfObjType::KSR settings.uiConfTypes[] = Kaltura_Client_Enum_UiConfObjType::WEBCASTING settings.uiConfTypes[] = Kaltura_Client_Enum_UiConfObjType::SAP +settings.uiConfTypes[] = Kaltura_Client_Enum_UiConfObjType::REELS ; disable KCW visual editor for on-prem/ce (editor is enabled if property is true or missing) settings.enableKCWVisualEditor = false; diff --git a/release-notes.md b/release-notes.md index 7637d6228a4..04fb1e00e49 100644 --- a/release-notes.md +++ b/release-notes.md @@ -1,3 +1,12 @@ +# Tucana-20.20.0 +## Add Reels Player ## +* Issue Type: Story +* Issue ID: PLAT-24930 +### Configuration ### +Add the following to admin.template.ini: + + settings.uiConfTypes[] = Kaltura_Client_Enum_UiConfObjType::REELS + # Tucana-20.17.0 ## New KME user reset password link ## - Issue Type: Bug diff --git a/var_console/configs/lang/en.php b/var_console/configs/lang/en.php index cccd7a6b7f9..73822d40b95 100644 --- a/var_console/configs/lang/en.php +++ b/var_console/configs/lang/en.php @@ -333,6 +333,7 @@ 'Kaltura_Client_Enum_UiConfObjType::KMC_GENERAL' => 'KMC General', 'Kaltura_Client_Enum_UiConfObjType::KMC_ROLES_AND_PERMISSIONS' => 'KMC Roles and Permissions', 'KalturaUiConfObjType::SAP' => 'Slim Audio Player', + 'KalturaUiConfObjType::REELS' => 'Reels Player', 'KalturaUiConfObjType::PLAYER_SL' => 'Player Silverlight', 'KalturaUiConfObjType::CLIENTSIDE_ENCODER' => 'Client Side Encoder', From e6aee33bf3d27fdb0f32ea29f327899d3209dd9f Mon Sep 17 00:00:00 2001 From: amirhalfon1 Date: Wed, 4 Sep 2024 09:38:01 +0300 Subject: [PATCH 73/96] KME-2117: allow setting of templateRoomEntry from "global" partner --- alpha/lib/model/Partner.php | 1 + plugins/room/lib/api/KalturaRoomEntry.php | 16 +++++++++++++++- plugins/room/services/RoomService.php | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/alpha/lib/model/Partner.php b/alpha/lib/model/Partner.php index 550b2baac6d..6965952a08b 100644 --- a/alpha/lib/model/Partner.php +++ b/alpha/lib/model/Partner.php @@ -18,6 +18,7 @@ class Partner extends BasePartner const PLAY_SERVER_PARTNER_ID = -6; const EP_PARTNER_ID = -11; const SELF_SERVE_PARTNER_ID = -12; + const KME_PARTNER_ID = -13; const BI_PARTNER_ID = -15; const AUTH_BROKER_PARTNER = -17; diff --git a/plugins/room/lib/api/KalturaRoomEntry.php b/plugins/room/lib/api/KalturaRoomEntry.php index 1db3704ae79..dc1e08bd3c7 100644 --- a/plugins/room/lib/api/KalturaRoomEntry.php +++ b/plugins/room/lib/api/KalturaRoomEntry.php @@ -70,7 +70,7 @@ public function validateTemplateRoomEntry() { return; } - $entry = entryPeer::retrieveByPK($this->templateRoomEntryId); + $entry = $this->retrieveTemplateRoomEntry($this->templateRoomEntryId); if (!$entry) { throw new KalturaAPIException(KalturaErrors::ENTRY_ID_NOT_FOUND, $this->templateRoomEntryId); @@ -81,6 +81,20 @@ public function validateTemplateRoomEntry() } } + private function retrieveTemplateRoomEntry($entryId) + { + $c = new Criteria(); + $partnerId = kCurrentContext::$partner_id ? kCurrentContext::$partner_id : kCurrentContext::$ks_partner_id; + entryPeer::setUseCriteriaFilter ( false ); + // allow setting entry of the "global" partner + $allowedPids = array($partnerId, Partner::KME_PARTNER_ID); + $c->addAnd(entryPeer::PARTNER_ID, $allowedPids, Criteria::IN); + $c->addAnd ( entryPeer::STATUS, entryStatus::DELETED, Criteria::NOT_EQUAL); + $c->addAnd ( entryPeer::ID, $entryId, Criteria::EQUAL); + $entry = entryPeer::doSelectOne($c); + entryPeer::setUseCriteriaFilter ( true ); + return $entry; + } } \ No newline at end of file diff --git a/plugins/room/services/RoomService.php b/plugins/room/services/RoomService.php index bd19cf1c856..5104b790361 100644 --- a/plugins/room/services/RoomService.php +++ b/plugins/room/services/RoomService.php @@ -15,7 +15,7 @@ class RoomService extends KalturaEntryService function addAction(KalturaRoomEntry $entry) { - $dbEntry = parent::add($entry); + $dbEntry = parent::add($entry, conversionProfile2::CONVERSION_PROFILE_NONE); $dbEntry->setStatus(entryStatus::NO_CONTENT); $dbEntry->save(); From 0535a093c485d5b151fdd93121565c6d3d96e79a Mon Sep 17 00:00:00 2001 From: amirhalfon1 Date: Wed, 4 Sep 2024 09:42:35 +0300 Subject: [PATCH 74/96] remove spaces --- plugins/room/lib/api/KalturaRoomEntry.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/room/lib/api/KalturaRoomEntry.php b/plugins/room/lib/api/KalturaRoomEntry.php index dc1e08bd3c7..152ec3d8ca3 100644 --- a/plugins/room/lib/api/KalturaRoomEntry.php +++ b/plugins/room/lib/api/KalturaRoomEntry.php @@ -85,14 +85,14 @@ private function retrieveTemplateRoomEntry($entryId) { $c = new Criteria(); $partnerId = kCurrentContext::$partner_id ? kCurrentContext::$partner_id : kCurrentContext::$ks_partner_id; - entryPeer::setUseCriteriaFilter ( false ); + entryPeer::setUseCriteriaFilter (false); // allow setting entry of the "global" partner $allowedPids = array($partnerId, Partner::KME_PARTNER_ID); $c->addAnd(entryPeer::PARTNER_ID, $allowedPids, Criteria::IN); - $c->addAnd ( entryPeer::STATUS, entryStatus::DELETED, Criteria::NOT_EQUAL); - $c->addAnd ( entryPeer::ID, $entryId, Criteria::EQUAL); + $c->addAnd (entryPeer::STATUS, entryStatus::DELETED, Criteria::NOT_EQUAL); + $c->addAnd (entryPeer::ID, $entryId, Criteria::EQUAL); $entry = entryPeer::doSelectOne($c); - entryPeer::setUseCriteriaFilter ( true ); + entryPeer::setUseCriteriaFilter (true); return $entry; } From 5b56b26dab454202c83f0856fcc1e79040978fc1 Mon Sep 17 00:00:00 2001 From: amirhalfon1 Date: Wed, 4 Sep 2024 09:45:05 +0300 Subject: [PATCH 75/96] remove spaces #2 --- plugins/room/lib/api/KalturaRoomEntry.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/room/lib/api/KalturaRoomEntry.php b/plugins/room/lib/api/KalturaRoomEntry.php index 152ec3d8ca3..2d1914b7a2c 100644 --- a/plugins/room/lib/api/KalturaRoomEntry.php +++ b/plugins/room/lib/api/KalturaRoomEntry.php @@ -89,8 +89,8 @@ private function retrieveTemplateRoomEntry($entryId) // allow setting entry of the "global" partner $allowedPids = array($partnerId, Partner::KME_PARTNER_ID); $c->addAnd(entryPeer::PARTNER_ID, $allowedPids, Criteria::IN); - $c->addAnd (entryPeer::STATUS, entryStatus::DELETED, Criteria::NOT_EQUAL); - $c->addAnd (entryPeer::ID, $entryId, Criteria::EQUAL); + $c->addAnd(entryPeer::STATUS, entryStatus::DELETED, Criteria::NOT_EQUAL); + $c->addAnd(entryPeer::ID, $entryId, Criteria::EQUAL); $entry = entryPeer::doSelectOne($c); entryPeer::setUseCriteriaFilter (true); return $entry; From be6ceedd9167501e6e22b5832f4952eceae5f767 Mon Sep 17 00:00:00 2001 From: MosheMaorKaltura Date: Wed, 4 Sep 2024 13:02:48 +0300 Subject: [PATCH 76/96] PLAT-24912: indentation --- .../modules/extwidget/actions/embedPlaykitJsAction.class.php | 2 +- alpha/lib/model/uiConf.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php index a4c17f446f8..ae92ca5eca5 100644 --- a/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php @@ -822,7 +822,7 @@ private function initMembers() $this->mergeVersionsParamIntoConfig(); - if($this->getRequestParameter(v2RedirectUtils::V2REDIRECT_PARAM_NAME)) + if($this->getRequestParameter(v2RedirectUtils::V2REDIRECT_PARAM_NAME)) { $this->bundleConfig[v2RedirectUtils::SCRIPT_PLUGIN_NAME] = kConf::getArrayValue('v2RedirectPluginVersion', diff --git a/alpha/lib/model/uiConf.php b/alpha/lib/model/uiConf.php index a7c098bd870..f342a493d04 100644 --- a/alpha/lib/model/uiConf.php +++ b/alpha/lib/model/uiConf.php @@ -116,7 +116,7 @@ class uiConf extends BaseuiConf implements ISyncableFile, IRelatedObject const CUSTOM_DATA_V2REDIRECT = "v2redirect"; - public function save(PropelPDO $con = null) + public function save(PropelPDO $con = null) { try { From 36c2789f60bbd07168f6e4ec52139ca6d1381ab1 Mon Sep 17 00:00:00 2001 From: drorsouhami Date: Sun, 8 Sep 2024 10:37:25 +0300 Subject: [PATCH 77/96] REACH2-1284: Add fields to admin console for Partner Catalog Items --- plugins/reach/admin/forms/ReachProfileFilter.php | 2 +- .../plugin/partner-catalog-item-list-action.phtml | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/plugins/reach/admin/forms/ReachProfileFilter.php b/plugins/reach/admin/forms/ReachProfileFilter.php index 630036a9e5b..3f489a32ce6 100644 --- a/plugins/reach/admin/forms/ReachProfileFilter.php +++ b/plugins/reach/admin/forms/ReachProfileFilter.php @@ -10,7 +10,7 @@ public function init() parent::init(); $filterType = $this->getElement('filter_type'); $filterType->setMultiOptions(array( - 'partnerIdEqual' => 'Publisher ID', + 'partnerIdEqual' => 'Partner ID', )); } } \ No newline at end of file diff --git a/plugins/reach/admin/scripts/plugin/partner-catalog-item-list-action.phtml b/plugins/reach/admin/scripts/plugin/partner-catalog-item-list-action.phtml index 3f48beddcf5..c17b3d8ec3a 100644 --- a/plugins/reach/admin/scripts/plugin/partner-catalog-item-list-action.phtml +++ b/plugins/reach/admin/scripts/plugin/partner-catalog-item-list-action.phtml @@ -24,12 +24,15 @@ + + + - @@ -59,6 +62,13 @@ else echo null;?> + + + - + From a2afa610dddb24267191559de4c61e93c29010ee Mon Sep 17 00:00:00 2001 From: drorsouhami Date: Sun, 8 Sep 2024 10:40:56 +0300 Subject: [PATCH 79/96] REACH2-1284: Fix tabs --- plugins/reach/admin/forms/ReachProfileFilter.php | 2 +- .../scripts/plugin/partner-catalog-item-list-action.phtml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/reach/admin/forms/ReachProfileFilter.php b/plugins/reach/admin/forms/ReachProfileFilter.php index 3f489a32ce6..00fbc0a7517 100644 --- a/plugins/reach/admin/forms/ReachProfileFilter.php +++ b/plugins/reach/admin/forms/ReachProfileFilter.php @@ -13,4 +13,4 @@ public function init() 'partnerIdEqual' => 'Partner ID', )); } -} \ No newline at end of file +} diff --git a/plugins/reach/admin/scripts/plugin/partner-catalog-item-list-action.phtml b/plugins/reach/admin/scripts/plugin/partner-catalog-item-list-action.phtml index 664fe3cf8c5..a254587f5ba 100644 --- a/plugins/reach/admin/scripts/plugin/partner-catalog-item-list-action.phtml +++ b/plugins/reach/admin/scripts/plugin/partner-catalog-item-list-action.phtml @@ -24,10 +24,10 @@ - - - - + + + + From 398d5ce8437938e0ac33e6c1392ab1a26151c44e Mon Sep 17 00:00:00 2001 From: "daniel.barak" Date: Sun, 8 Sep 2024 13:02:39 +0300 Subject: [PATCH 80/96] PLAT-24937: Add Unisphere endpoint to KMC server config object --- .../microservice/MicroServiceUnisphereLoader.php | 15 +++++++++++++++ .../modules/kmcng/actions/kmcngAction.class.php | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 alpha/apps/kaltura/lib/microservice/MicroServiceUnisphereLoader.php diff --git a/alpha/apps/kaltura/lib/microservice/MicroServiceUnisphereLoader.php b/alpha/apps/kaltura/lib/microservice/MicroServiceUnisphereLoader.php new file mode 100644 index 00000000000..8459e212621 --- /dev/null +++ b/alpha/apps/kaltura/lib/microservice/MicroServiceUnisphereLoader.php @@ -0,0 +1,15 @@ +hostName = self::$host; + parent::__construct(); + } +} diff --git a/alpha/apps/kaltura/modules/kmcng/actions/kmcngAction.class.php b/alpha/apps/kaltura/modules/kmcng/actions/kmcngAction.class.php index 1c055594b97..d67a804dfe5 100644 --- a/alpha/apps/kaltura/modules/kmcng/actions/kmcngAction.class.php +++ b/alpha/apps/kaltura/modules/kmcng/actions/kmcngAction.class.php @@ -299,7 +299,8 @@ private function initConfig($deployUrl, $kmcngParams, $enforceSecureProtocol, $r 'userProfileEndpoint' => array('uri' => MicroServiceUserProfile::buildServiceUrl(MicroServiceUserProfile::$host, MicroServiceUserProfile::$service)), 'userReportsEndpoint' => array('uri' => MicroServiceUserReports::buildServiceUrl(MicroServiceUserReports::$host, MicroServiceUserReports::$service)), 'mrEndpoint' => array('uri' => MicroServiceMediaRepurposing::buildServiceUrl(MicroServiceMediaRepurposing::$host, MicroServiceMediaRepurposing::$service)), - 'vendorIntegrationsEndpoint' => array('uri' => MicroServiceVendorIntegrations::buildServiceUrl(MicroServiceVendorIntegrations::$host, MicroServiceVendorIntegrations::$service)) + 'vendorIntegrationsEndpoint' => array('uri' => MicroServiceVendorIntegrations::buildServiceUrl(MicroServiceVendorIntegrations::$host, MicroServiceVendorIntegrations::$service)), + 'unisphereLoaderEndpoint' => array('uri' => MicroServiceUnisphereLoader::buildServiceUrl(MicroServiceUnisphereLoader::$host, MicroServiceUnisphereLoader::$service)) ), ); From 97d0906cba05b7ac47d2e2b28d70b207392d3128 Mon Sep 17 00:00:00 2001 From: "daniel.barak" Date: Sun, 8 Sep 2024 14:07:22 +0300 Subject: [PATCH 81/96] PLAT-24930: fix readme --- release-notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release-notes.md b/release-notes.md index 04fb1e00e49..e0d35913b95 100644 --- a/release-notes.md +++ b/release-notes.md @@ -3,7 +3,7 @@ * Issue Type: Story * Issue ID: PLAT-24930 ### Configuration ### -Add the following to admin.template.ini: +Add the following to admin.ini: settings.uiConfTypes[] = Kaltura_Client_Enum_UiConfObjType::REELS From f4d027a6b102ea5c37a7816c8efb47b98d91e115 Mon Sep 17 00:00:00 2001 From: drorsouhami Date: Sun, 8 Sep 2024 15:39:45 +0300 Subject: [PATCH 82/96] PLAT-24926: requireSource does not change from bulk CSV --- .../csv/batch/BulkUploadVendorCatalogItemEngineCsv.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/bulk_upload/csv/batch/BulkUploadVendorCatalogItemEngineCsv.php b/plugins/bulk_upload/csv/batch/BulkUploadVendorCatalogItemEngineCsv.php index aa2e4baa166..027bc76f1db 100644 --- a/plugins/bulk_upload/csv/batch/BulkUploadVendorCatalogItemEngineCsv.php +++ b/plugins/bulk_upload/csv/batch/BulkUploadVendorCatalogItemEngineCsv.php @@ -29,7 +29,7 @@ class BulkUploadVendorCatalogItemEngineCsv extends BulkUploadEngineCsv private $bulkUploadResultParams = array( 'vendorPartnerId', 'name', 'systemName', 'serviceType', 'turnAroundTime', 'sourceLanguage', 'targetLanguage', 'outputFormat', 'enableSpeakerId', 'fixedPriceAddons', - 'pricing', 'flavorParamsId', 'clearAudioFlavorParamsId', 'allowResubmission', 'stage', 'contract', 'notes', 'createdBy'); + 'pricing', 'flavorParamsId', 'clearAudioFlavorParamsId', 'allowResubmission', 'requireSource', 'stage', 'contract', 'notes', 'createdBy'); /** * (non-PHPdoc) From 6fe8a38b0fc4811470d96270b33d53c11de6408f Mon Sep 17 00:00:00 2001 From: Inbal BD Date: Mon, 9 Sep 2024 10:42:38 +0300 Subject: [PATCH 83/96] Updated version - Tucana-20.20.0 --- VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.txt b/VERSION.txt index 35590595cb2..2c3b046077e 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -Tucana-20.19.0 +Tucana-20.20.0 From 905353eb340a2c3eadb6c56c9614697939a78329 Mon Sep 17 00:00:00 2001 From: drorsouhami Date: Mon, 9 Sep 2024 14:52:14 +0300 Subject: [PATCH 84/96] PLAT-24926: Add Reach pricing per hour --- plugins/reach/config/lang/en.php | 1 + plugins/reach/lib/kReachUtils.php | 5 +++++ .../reach/lib/model/enums/VendorCatalogItemPriceFunction.php | 1 + 3 files changed, 7 insertions(+) diff --git a/plugins/reach/config/lang/en.php b/plugins/reach/config/lang/en.php index dcdd218776b..73e909fa074 100644 --- a/plugins/reach/config/lang/en.php +++ b/plugins/reach/config/lang/en.php @@ -53,6 +53,7 @@ 'Kaltura_Client_Reach_Enum_VendorCatalogItemStatus::DELETED' => "Deleted", 'Kaltura_Client_Reach_Enum_VendorCatalogItemStatus::ACTIVE' => "Enabled", + 'Kaltura_Client_Reach_Enum_VendorCatalogItemPriceFunction::PRICE_PER_HOUR' => "Price Per Hour", 'Kaltura_Client_Reach_Enum_VendorCatalogItemPriceFunction::PRICE_PER_MINUTE' => "Price Per Minute", 'Kaltura_Client_Reach_Enum_VendorCatalogItemPriceFunction::PRICE_PER_SECOND' => "Price Per Second", diff --git a/plugins/reach/lib/kReachUtils.php b/plugins/reach/lib/kReachUtils.php index 55c08a506d3..5f88a638f0a 100644 --- a/plugins/reach/lib/kReachUtils.php +++ b/plugins/reach/lib/kReachUtils.php @@ -68,6 +68,11 @@ public static function calcPricePerMinute($durationMsec, $pricePerUnit) { return ceil($durationMsec/1000/dateUtils::MINUTE) * $pricePerUnit; } + + public static function calcPricePerHour($durationMsec, $pricePerUnit) + { + return ceil($durationMsec/1000/dateUtils::HOUR) * $pricePerUnit; + } public static function calculateTaskPrice(entry $entry, VendorCatalogItem $vendorCatalogItem, $taskDuration = null) { diff --git a/plugins/reach/lib/model/enums/VendorCatalogItemPriceFunction.php b/plugins/reach/lib/model/enums/VendorCatalogItemPriceFunction.php index fc2c23e1728..12f90376560 100644 --- a/plugins/reach/lib/model/enums/VendorCatalogItemPriceFunction.php +++ b/plugins/reach/lib/model/enums/VendorCatalogItemPriceFunction.php @@ -7,4 +7,5 @@ interface VendorCatalogItemPriceFunction extends BaseEnum { const PRICE_PER_SECOND = "kReachUtils::calcPricePerSecond"; const PRICE_PER_MINUTE = "kReachUtils::calcPricePerMinute"; + const PRICE_PER_HOUR = "kReachUtils::calcPricePerHour"; } \ No newline at end of file From 62b010bb3579bc6947ef49613eeaf901ce6f9b9c Mon Sep 17 00:00:00 2001 From: "daniel.barak" Date: Tue, 10 Sep 2024 12:55:02 +0300 Subject: [PATCH 85/96] PLAT-24940: Enable Content Lab feature --- alpha/lib/enums/PermissionName.php | 1 + configurations/admin.template.ini | 6 ++++++ release-notes.md | 12 ++++++++++++ 3 files changed, 19 insertions(+) diff --git a/alpha/lib/enums/PermissionName.php b/alpha/lib/enums/PermissionName.php index 477fd3c1436..822322248c1 100644 --- a/alpha/lib/enums/PermissionName.php +++ b/alpha/lib/enums/PermissionName.php @@ -298,4 +298,5 @@ interface PermissionName extends BaseEnum const FEATURE_DISABLE_PREVIEW_PAGE = 'FEATURE_DISABLE_PREVIEW_PAGE'; const FEATURE_SYNC_VOD_LIVE_METADATA = 'FEATURE_SYNC_VOD_LIVE_METADATA'; + const FEATURE_CONTENT_LAB = 'FEATURE_CONTENT_LAB'; } diff --git a/configurations/admin.template.ini b/configurations/admin.template.ini index 88cfc7948b5..da5b194ad2b 100644 --- a/configurations/admin.template.ini +++ b/configurations/admin.template.ini @@ -1233,6 +1233,12 @@ moduls.cncAISentimentAnalysis.label = "Enable AI in CNC - Sentiment Analysis" moduls.cncAISentimentAnalysis.permissionName = FEATURE_CNC_AI_SENTIMENT_ANALYSIS_PERMISSION moduls.cncAISentimentAnalysis.group = GROUP_ENABLE_DISABLE_FEATURES +moduls.contentLab.enabled = true +moduls.contentLab.permissionType = 2 +moduls.contentLab.label = "Enable Content Lab" +moduls.contentLab.permissionName = FEATURE_CONTENT_LAB +moduls.contentLab.group = GROUP_ENABLE_DISABLE_FEATURES + ; ACCESS PERMISSIONS access.error = * diff --git a/release-notes.md b/release-notes.md index e0d35913b95..3f91ed92a2b 100644 --- a/release-notes.md +++ b/release-notes.md @@ -1,4 +1,16 @@ # Tucana-20.20.0 +## Enable Content Lab ## +* Issue Type: Task +* Issue ID: PLAT-24940 +### Deployment ### +Add the following to admin.ini +``` +moduls.contentLab.enabled = true +moduls.contentLab.permissionType = 2 +moduls.contentLab.label = "Enable Content Lab" +moduls.contentLab.permissionName = FEATURE_CONTENT_LAB +moduls.contentLab.group = GROUP_ENABLE_DISABLE_FEATURES +``` ## Add Reels Player ## * Issue Type: Story * Issue ID: PLAT-24930 From 10f993a1f2a92acc96bdf8ecf82323e309221bbd Mon Sep 17 00:00:00 2001 From: drorsouhami Date: Wed, 11 Sep 2024 11:20:35 +0300 Subject: [PATCH 86/96] SUP-43308: Correct function call name --- plugins/scheduled_task/ScheduledTaskPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/scheduled_task/ScheduledTaskPlugin.php b/plugins/scheduled_task/ScheduledTaskPlugin.php index 94754e2153e..9d3898aabc3 100644 --- a/plugins/scheduled_task/ScheduledTaskPlugin.php +++ b/plugins/scheduled_task/ScheduledTaskPlugin.php @@ -165,7 +165,7 @@ public static function permissionEnabled($partnerId, $permissionName) { if ($permissionName == PermissionName::SCHEDULEDTASK_PLUGIN_PERMISSION) { - MediaRepurposingHandler::enanbleMrPermission($partnerId); + MediaRepurposingHandler::enableMrPermission($partnerId); } } } From b1d3e78ca35a2571cb6f7dc8ed5423abfa1fc0ae Mon Sep 17 00:00:00 2001 From: "daniel.barak" Date: Wed, 11 Sep 2024 12:09:47 +0300 Subject: [PATCH 87/96] PLAT-24937: unisphere uri fix --- .../kaltura/lib/microservice/MicroServiceBaseService.php | 6 +++++- .../kaltura/modules/kmcng/actions/kmcngAction.class.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/alpha/apps/kaltura/lib/microservice/MicroServiceBaseService.php b/alpha/apps/kaltura/lib/microservice/MicroServiceBaseService.php index 6e8777f4d4a..2add7ca6481 100644 --- a/alpha/apps/kaltura/lib/microservice/MicroServiceBaseService.php +++ b/alpha/apps/kaltura/lib/microservice/MicroServiceBaseService.php @@ -47,7 +47,7 @@ private function generateSession($partnerId) * @return string * @throws Exception */ - public static function buildServiceUrl($hostName, $serviceName) + public static function buildServiceUrl($hostName, $serviceName, $isApi = true) { $serviceUrl = kConf::get("microservice_url", 'local', null); if(!$serviceUrl) @@ -61,6 +61,10 @@ public static function buildServiceUrl($hostName, $serviceName) { $serviceUrl = $serviceUrl . '/' . trim($serviceName, "\/"); } + if(!$isApi) + { + return str_replace('/api', '', $serviceUrl); + } return $serviceUrl; } diff --git a/alpha/apps/kaltura/modules/kmcng/actions/kmcngAction.class.php b/alpha/apps/kaltura/modules/kmcng/actions/kmcngAction.class.php index d67a804dfe5..db1392eba60 100644 --- a/alpha/apps/kaltura/modules/kmcng/actions/kmcngAction.class.php +++ b/alpha/apps/kaltura/modules/kmcng/actions/kmcngAction.class.php @@ -300,7 +300,7 @@ private function initConfig($deployUrl, $kmcngParams, $enforceSecureProtocol, $r 'userReportsEndpoint' => array('uri' => MicroServiceUserReports::buildServiceUrl(MicroServiceUserReports::$host, MicroServiceUserReports::$service)), 'mrEndpoint' => array('uri' => MicroServiceMediaRepurposing::buildServiceUrl(MicroServiceMediaRepurposing::$host, MicroServiceMediaRepurposing::$service)), 'vendorIntegrationsEndpoint' => array('uri' => MicroServiceVendorIntegrations::buildServiceUrl(MicroServiceVendorIntegrations::$host, MicroServiceVendorIntegrations::$service)), - 'unisphereLoaderEndpoint' => array('uri' => MicroServiceUnisphereLoader::buildServiceUrl(MicroServiceUnisphereLoader::$host, MicroServiceUnisphereLoader::$service)) + 'unisphereLoaderEndpoint' => array('uri' => MicroServiceUnisphereLoader::buildServiceUrl(MicroServiceUnisphereLoader::$host, MicroServiceUnisphereLoader::$service, false)) ), ); From 5e5d8b85cb225592fd0f099f397eb84925b7bf39 Mon Sep 17 00:00:00 2001 From: Moshe Maor Date: Thu, 12 Sep 2024 11:26:40 +0300 Subject: [PATCH 88/96] Update v2RedirectUtils.class.php --- alpha/apps/kaltura/lib/v2RedirectUtils.class.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/alpha/apps/kaltura/lib/v2RedirectUtils.class.php b/alpha/apps/kaltura/lib/v2RedirectUtils.class.php index ccc46a23f62..94f4f2bbeea 100644 --- a/alpha/apps/kaltura/lib/v2RedirectUtils.class.php +++ b/alpha/apps/kaltura/lib/v2RedirectUtils.class.php @@ -84,8 +84,6 @@ static function addV2toV7plugins($flashvars, &$bundleConfig, &$playerConfig) static function addV2toV7config($flashvars, $uiconfId) { $config = []; - //Merge v7 config - if($flashvars) { foreach ($flashvars as $key => $value) { $key = trim(trim($key, '"'), "'"); @@ -118,4 +116,4 @@ private static function v2toV7PluginMap() "bumper" => [ "playkit-bumper" , "bumper" ], "infoScreen" => ["playkit-info", "playkit-js-info"]]; } -} \ No newline at end of file +} From 490fd661e64994b3c16ddbcf1b585c443fa0cd43 Mon Sep 17 00:00:00 2001 From: Moshe Maor Date: Thu, 12 Sep 2024 11:27:28 +0300 Subject: [PATCH 89/96] Update v2RedirectUtils.class.php --- .../apps/kaltura/lib/v2RedirectUtils.class.php | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/alpha/apps/kaltura/lib/v2RedirectUtils.class.php b/alpha/apps/kaltura/lib/v2RedirectUtils.class.php index 94f4f2bbeea..54e56c92d79 100644 --- a/alpha/apps/kaltura/lib/v2RedirectUtils.class.php +++ b/alpha/apps/kaltura/lib/v2RedirectUtils.class.php @@ -98,22 +98,4 @@ private static function isVarPlugin($varKeyName) { return str_contains($varKeyName, ".plugin"); } - - private static function v2toV7PluginMap() - { - return - ["info" => ["playkitscreen", "playkit-js-info"], - "quiz" => ["playkit-ivq", "ivq"], - "moderation" => ["playkit-moderation", "playkit-js-moderation"], - "playlistAPI" => ["playkit-playlist", "playlist"], - "liveStatus" => ["playkit-kaltura-live","kaltura-live"], - "related" => ["playkit-related", "related"], - "dualScreen" => ["playkit-dual-screen", "dualscreen"], - "video360" => ["playkit-vr" ,"vr"], - "raptMedia" => ["rapt", "rapt"], - "transcript" => ["playkit-transcript", "playkit-js-transcript"], - "qna" => ["playkit-qna", "qna"], - "bumper" => [ "playkit-bumper" , "bumper" ], - "infoScreen" => ["playkit-info", "playkit-js-info"]]; - } } From dbe15179488e8b39c07fb8c8a880e539c3fabddf Mon Sep 17 00:00:00 2001 From: Moshe Maor Date: Thu, 12 Sep 2024 11:29:47 +0300 Subject: [PATCH 90/96] Update embedIframeJsAction.class.php --- .../modules/extwidget/actions/embedIframeJsAction.class.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php index b14b7113691..101ae10d3bf 100644 --- a/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/embedIframeJsAction.class.php @@ -154,10 +154,6 @@ public function execute() KExternalErrors::dieGracefully(); } - /* - * v2 - https://cdnapisec.kaltura.com/p/1915851/sp/191585100/embedIframeJs/uiconf_id/32880931/partner_id/1915851?iframeembed=true&playerId=kaltura_player_1719900446&entry_id=1_aeg07vpv - * v7 - https://cdnapisec.kaltura.com/p/1915851/embedPlaykitJs/uiconf_id/54813242?iframeembed=true&entry_id=1_aeg07vpv - */ private function redirectToV7($v7Id, $v2UiConfId, $partnerId, $shouldTranslatePlugins) : void { //validate all the params are handled From 8fd9b40a370aeb25f5bc45e95b05bb6a730319db Mon Sep 17 00:00:00 2001 From: Moshe Maor Date: Sun, 15 Sep 2024 09:26:52 +0300 Subject: [PATCH 91/96] Update embedPlaykitJsAction.class.php --- .../modules/extwidget/actions/embedPlaykitJsAction.class.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php index ae92ca5eca5..59379d3a691 100644 --- a/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php @@ -845,8 +845,6 @@ private function initMembers() $this->setBundleName(); } - - private function setBundleName() { //sort bundle config by key From 55e51b4831c01f358541dbf0f82a0bb13dd83aff Mon Sep 17 00:00:00 2001 From: Moshe Maor Date: Sun, 15 Sep 2024 09:41:30 +0300 Subject: [PATCH 92/96] Update embedPlaykitJsAction.class.php --- .../modules/extwidget/actions/embedPlaykitJsAction.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php b/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php index 59379d3a691..596648e414d 100644 --- a/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php +++ b/alpha/apps/kaltura/modules/extwidget/actions/embedPlaykitJsAction.class.php @@ -583,7 +583,6 @@ private function mergeVersionsParamIntoConfig() if (!$this->bundleConfig) { $this->bundleConfig = array(); } - KalturaLog::log("versionsArr" . print_r($versionsArr,true)); $this->bundleConfig = array_merge($this->bundleConfig, $versionsArr); } } From 5d19c6694f0bbaab7dc85274e143919d66f57e7f Mon Sep 17 00:00:00 2001 From: Moshe Maor Date: Mon, 16 Sep 2024 13:03:00 +0300 Subject: [PATCH 93/96] Update v2RedirectUtils.class.php --- alpha/apps/kaltura/lib/v2RedirectUtils.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/alpha/apps/kaltura/lib/v2RedirectUtils.class.php b/alpha/apps/kaltura/lib/v2RedirectUtils.class.php index 54e56c92d79..cbd6400c42c 100644 --- a/alpha/apps/kaltura/lib/v2RedirectUtils.class.php +++ b/alpha/apps/kaltura/lib/v2RedirectUtils.class.php @@ -51,8 +51,10 @@ static function addV2toV7plugins($flashvars, &$bundleConfig, &$playerConfig) { //get plugin name KalturaLog::log("V2 to V7 adding plugin: " . $key. " value:" . $value); - if ($value) { - if (!$bundleConfig) { + if ($value) + { + if (!$bundleConfig) + { $bundleConfig = []; } $key = trim(trim($key, '"'), "'"); From b21d86b61ceb940bd3af0f29ef149337a5e393de Mon Sep 17 00:00:00 2001 From: Moshe Maor Date: Mon, 16 Sep 2024 13:03:29 +0300 Subject: [PATCH 94/96] Update v2RedirectUtils.class.php --- alpha/apps/kaltura/lib/v2RedirectUtils.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/alpha/apps/kaltura/lib/v2RedirectUtils.class.php b/alpha/apps/kaltura/lib/v2RedirectUtils.class.php index cbd6400c42c..f7b5c618a78 100644 --- a/alpha/apps/kaltura/lib/v2RedirectUtils.class.php +++ b/alpha/apps/kaltura/lib/v2RedirectUtils.class.php @@ -64,10 +64,12 @@ static function addV2toV7plugins($flashvars, &$bundleConfig, &$playerConfig) $v7PluginName = self::getV7PluginInfo($v2PluginName[0]); $bundleConfig = array_merge($bundleConfig, [$v7PluginName[0] => "{latest}"]); $v7PluginConfig = $v7PluginName[1]; - if (!isset($playerConfig->plugins)) { + if (!isset($playerConfig->plugins)) + { $playerConfig->plugins = new stdClass(); } - if (!isset($playerConfig->plugins->$v7PluginConfig)) { + if (!isset($playerConfig->plugins->$v7PluginConfig)) + { $playerConfig->plugins->$v7PluginConfig = new stdClass(); } } From b3850e5033b2ed58d98c56adac6892ee005e3f4a Mon Sep 17 00:00:00 2001 From: Moshe Maor Date: Mon, 16 Sep 2024 13:03:58 +0300 Subject: [PATCH 95/96] Update v2RedirectUtils.class.php --- alpha/apps/kaltura/lib/v2RedirectUtils.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/alpha/apps/kaltura/lib/v2RedirectUtils.class.php b/alpha/apps/kaltura/lib/v2RedirectUtils.class.php index f7b5c618a78..83336c443ae 100644 --- a/alpha/apps/kaltura/lib/v2RedirectUtils.class.php +++ b/alpha/apps/kaltura/lib/v2RedirectUtils.class.php @@ -89,7 +89,8 @@ static function addV2toV7config($flashvars, $uiconfId) { $config = []; if($flashvars) - { foreach ($flashvars as $key => $value) { + { foreach ($flashvars as $key => $value) + { $key = trim(trim($key, '"'), "'"); $config[$key] = json_decode($value); } From 27c2322bccb0fbcd526aebe2e7c8568bdc10e333 Mon Sep 17 00:00:00 2001 From: Moshe Maor Date: Mon, 16 Sep 2024 13:05:31 +0300 Subject: [PATCH 96/96] Update KalturaUiConfV2Redirect.php --- api_v3/lib/types/KalturaUiConfV2Redirect.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api_v3/lib/types/KalturaUiConfV2Redirect.php b/api_v3/lib/types/KalturaUiConfV2Redirect.php index d82af40d894..5c11e1d9a1d 100644 --- a/api_v3/lib/types/KalturaUiConfV2Redirect.php +++ b/api_v3/lib/types/KalturaUiConfV2Redirect.php @@ -47,6 +47,6 @@ public function doFromObject($srcObj, KalturaDetachedResponseProfile $responsePr $this->v7id = $srcObj->getV7Id(); $this->isApproved = $srcObj->getIsApproved(); $this->translatePlugins = $srcObj->getTranslatePlugins(); - parent::doFromObject($srcObj, $responseProfile); // TODO: Change the autogenerated stub + parent::doFromObject($srcObj, $responseProfile); } -} \ No newline at end of file +}
translate('Source Language'); ?> translate('Target Language'); ?> translate('Output Format'); ?>translate('Stage'); ?>translate('Contract'); ?>translate('Notes'); ?> translate('Action'); ?>
+ paginator; ?>
stage)) + echo $this->enumTranslate('Kaltura_Client_Reach_Enum_VendorCatalogItemStage', $catalogItem->stage); + else + echo null;?> + contract; ?>notes; ?> translate('Stage'); ?> translate('Contract'); ?> translate('Notes'); ?>translate('Action'); ?>translate('Action'); ?>
translate('Source Language'); ?> translate('Target Language'); ?> translate('Output Format'); ?>translate('Stage'); ?>translate('Contract'); ?>translate('Notes'); ?>translate('Action'); ?>translate('Stage'); ?>translate('Contract'); ?>translate('Notes'); ?>translate('Action'); ?>