private function getAutoEmbedCode() { $o = ''; // Get the kWidget call ( pass along iframe payload path ) // Check required params: $wid = $this->request()->get('wid'); if (!$wid) { $this->setError("missing wid param"); return ''; } $wid = htmlspecialchars($wid); $uiconf_id = $this->request()->get('uiconf_id'); if (!$uiconf_id) { $this->setError("missing uiconf_id param"); return ''; } $uiconf_id = htmlspecialchars($uiconf_id); $playerId = $this->request()->get('playerId'); if (!$playerId) { $this->setError("missing playerId param"); return ''; } // Check optional params $width = $this->request()->get('width') ? htmlspecialchars($this->request()->get('width')) : 400; $height = $this->request()->get('height') ? htmlspecialchars($this->request()->get('height')) : 330; // Get the iframe payload $kIframe = new kalturaIframeClass(); $this->iframeHeaders = $kIframe->getHeaders(); // get the kIframe $json = array('content' => $kIframe->getIFramePageOutput()); $o .= "kWidget.iframeAutoEmbedCache[ '{$playerId}' ] = " . json_encode($json) . ";\n"; $o .= "if(!document.getElementById('{$playerId}')) { document.write( '<div id=\"{$playerId}\" style=\"width:{$width}px;height:{$height}px\"></div>' ); } \n"; $o .= "kWidget.embed( '{$playerId}', { \n" . "\t'wid': '{$wid}', \n" . "\t'uiconf_id' : '{$uiconf_id}'"; // conditionally add in the entry id: ( no entry id in playlists ) if ($this->request()->get('entry_id') && !$this->getUiConfObject()->isPlaylist()) { $o .= ",\n\t'entry_id': '" . htmlspecialchars($this->request()->get('entry_id')) . "'"; } $flashVars = $this->request()->getFlashVars(); //$o.=",\n\t'width': {$width},\n\t'height': {$height}"; // conditionally output flashvars: if ($flashVars && is_array($flashVars)) { $o .= ",\n\t'flashvars': {"; $coma = ''; foreach ($flashVars as $fvKey => $fvValue) { $o .= $coma; $coma = ','; // check for json flavar and set acordingly if (is_object(json_decode(html_entity_decode($fvValue)))) { $o .= "\n\t\t'{$fvKey}':"; $fvSet = json_decode(html_entity_decode($fvValue)); $o .= json_encode($fvSet); } else { $o .= "\"{$fvKey}\"" . ':' . json_encode($this->utility()->formatString($fvValue)); } } $o .= '}'; } $o .= "\n});"; return $o; }