Created
July 2, 2012 23:26
-
-
Save anointed/3036361 to your computer and use it in GitHub Desktop.
more fields
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| 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'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment