Skip to content

Instantly share code, notes, and snippets.

@anointed
Created July 2, 2012 20:06
Show Gist options
  • Select an option

  • Save anointed/3035366 to your computer and use it in GitHub Desktop.

Select an option

Save anointed/3035366 to your computer and use it in GitHub Desktop.
More fields kaltura addon
<?php
/*
Plugin Name: More Fields: Kaltura
Description: Adds Kaltura video as a type for the "More Fields" plugin. The plugins "all-in-one-video-pack" and "more-fields" needs to be installed and setup.
Version: 0.1
Author: Jonathan Bigler
*/
function mf_kaltura_init($types) {
require_once("lib/kaltura_client.php");
require_once('lib/kaltura_model.php');
require_once('lib/kaltura_helpers.php');
define(KALTURA_PARTNER_ID, get_option("kaltura_partner_id"));
define(KALTURA_SUBP_ID, get_option("kaltura_subp_id"));
define(KALTURA_SECRET, get_option("kaltura_secret"));
//$config = new KalturaConfiguration(KALTURA_PARTNER_ID,KALTURA_SUBP_ID);
$config = KalturaHelpers::getKalturaConfiguration();
//$kalt_user = new KalturaSessionUser();
//$kalt_user->userId = get_option("kaltura_cms_user");
//$kalt_user->screenName = get_option("kaltura_cms_user");
$kalt_user = $kalturaSessionUser;
//$client = new KalturaClient($config);
//$client = $kalturaClient;
//$result = $client->startSession($kalt_user, KALTURA_SECRET, false);
//$ks = $result["result"]["ks"];
$kmodel = KalturaModel::getInstance();
$ks = $kmodel->getClientSideSession();
$flashVars = array();
$flashVars["partnerId"] = KALTURA_PARTNER_ID;
$flashVars["subpId"] = KALTURA_SUBP_ID;
//$flashVars["uid"] = $kalt_user->userId;
$flashVars["uid"] = KalturaHelpers::getLoggedUserId() ;
$flashVars["ks"] = $ks;
$flashVars["kshowId"] = -2;
$flashVars["afterAddEntry"] = "onContributionWizardAfterAddEntry";
$flashVars["showCloseButton"] = false;
//print_r($flashVars);
$language = ($a = substr(WPLANG, 0, 2)) ? $a : 'en';
$select->title = 'Kaltura video';
$select->html_before = "
<!--The version of swfobject embbeded with the plugin 1.5 didn't work for this extension. -->
<!--It doesn't display KCW at all.-->
<!--I installed the latest version 2.2 next to it and it works fine !-->
<script type=\"text/javascript\" src=\"".KalturaHelpers::getPluginUrl()."/js/swfobject_2_2.js\"></script>
<div id=\"kcw\"></div>
<script type=\"text/javascript\">
var params = {
allowScriptAccess: \"always\",
allowNetworking: \"all\",
wmode: \"opaque\"
};
var flashVars = ".json_encode($flashVars).";
swfobject.embedSWF(\"http://www.kaltura.com/kcw/ui_conf_id/1000741\", \"kcw\", \"650\", \"360\", \"9.0.0\", false, flashVars, params);
</script>
<script type=\"text/javascript\">
//For now, I only keep the last media uploaded.
//TODO : limit KCW to one upload
function onContributionWizardAfterAddEntry(entries) {
for(var i = 0; i < entries.length; i++) {
//Writes the result in the custom input box
theInput = document.getElementById('%key%');
theInput.value = entries[i].entryId;
}
}
</script><br/>
";
$select->html_item = "<br/>Entry ID of the media uploaded : <input id='%key%' name='%key%' value='%value%' class=%class% style='width: 160px;'>";
$select->html_after = '';
$select->html_selected = '';
$select->values = false;
$types[] = $select;
return $types;
}
add_filter('more_fields_field_types', 'mf_kaltura_init');
?>
@anointed

anointed commented Jul 2, 2012

Copy link
Copy Markdown
Author

The above 'plugin' is a very old addon for the 'more fields' plugin, very outdated. This 'plugin' adds a custom field type 'kaltura' which allows us to browse our kaltura videos from the kaltura server and then choose and insert a selected video into a custom field.

I've been trying to 'convert' this concept to work with Jared's custom meta box plugin, but I am currently stuck.

Can someone help out in converting the above logic to work with Jared's plugin?

thanks

@tnorthcutt

Copy link
Copy Markdown

Can you show (with another gist) what you've tried so far?

@anointed

anointed commented Jul 3, 2012

Copy link
Copy Markdown
Author

I'd post what I have tried, but absolutely nothing has come even close to working. 90% of the time I end up 500 error etc..
I'll keep working on it, and if I get any closer at all, I'll post it here for everyone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment