Skip to content

Commit

Permalink
Added an upload widget and also removed the pear libs from the Cached…
Browse files Browse the repository at this point in the history
…Request.
  • Loading branch information
travist committed Jan 22, 2012
1 parent f15379c commit e4d57e7
Show file tree
Hide file tree
Showing 55 changed files with 102 additions and 13,705 deletions.
15 changes: 12 additions & 3 deletions LimelightConfig.php
Expand Up @@ -37,6 +37,7 @@ class LimelightConfig {
'access_key' => '',
'secret' => '',
'cache_timeout' => 4800,
'request_timeout' => 300,
'request_class' => 'LimelightCachedRequest',
'authenticate' => FALSE
);
Expand All @@ -49,14 +50,22 @@ class LimelightConfig {
*/
public static function getConfig($defaults = array()) {
global $limelight_config;

// Get the static configuration.
$config = self::$config;

// Set the request timeout to the session cache expiration.
$config['request_timeout'] = (session_cache_expire() * 60);

// Return the correct configuration.
if ($limelight_config) {
return array_merge(self::$config, array_filter($limelight_config));
return array_merge($config, array_filter($limelight_config));
}
else if ($defaults) {
return array_merge(self::$config, array_filter($defaults));
return array_merge($config, array_filter($defaults));
}
else {
return self::$config;
return $config;
}
}
}
Expand Down
38 changes: 38 additions & 0 deletions LimelightMedia.php
Expand Up @@ -211,6 +211,44 @@ public function getChannels($query = array()) {
return $list;
}

/**
* Returns an Upload Widget for your page.
*/
public function getUploadWidget($redirect = '', $width = 475, $height = 325) {

// Get the POST request.
$this->server->setConfig('authenticate', TRUE);
$request = $this->server->setRequest($this->endpoint('set'),HTTP_Request2::METHOD_POST);
$this->server->setConfig('authenticate', FALSE);

// Get the URL for this request.
$url = urlencode($request->request()->getUrl()->getUrl());

// Get the flashvars for this request.
$flashVars = "presigned_url={$url}";
if ($redirect) {
$redirect = urlencode($redirect);
$flashVars .= "&redirect_to={$redirect}";
}

$widget = "<object id='obj1'
width='{$width}' height='{$height}'
classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'
codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,5,0,0' height='400' width='500'>
<param name='src' value='http://assets.delvenetworks.com/upload-widget/current.swf'/>
<param name='AllowScriptAccess' value='always'/>
<param name='flashvars' value='{$flashVars}'/>
<embed name='obj2'
pluginspage='http://www.macromedia.com/go/getflashplayer'
AllowScriptAccess='always'
src='http://assets.delvenetworks.com/upload-widget/current.swf'
height='{$height}' width='{$width}' flashvars='{$flashVars}'/>
</object><br/>";

// Return the upload widget.
return $widget;
}

/**
* Returns the object to send to the server when creating/updating.
* @return type
Expand Down
3 changes: 2 additions & 1 deletion LimelightServer.php
Expand Up @@ -99,7 +99,8 @@ protected function authenticate() {
$this->request->getUrl()->setQueryVariable('access_key', $params['access_key']);
}
if (!isset($params['expires'])) {
$params['expires'] = time() + 300;
$timeout = $this->config['request_timeout'] ? $this->config['request_timeout'] : 300;
$params['expires'] = time() + $timeout;
$this->request->getUrl()->setQueryVariable('expires', $params['expires']);
}

Expand Down
24 changes: 24 additions & 0 deletions index.php
@@ -0,0 +1,24 @@
<?php
/*
* This will simply be the Upload Widget to upload files directly to your server.
*/
include_once 'LimelightMedia.php';
$media = new LimelightMedia();
?>
<!DOCTYPE html>
<html>
<head>
<title>Limelight Upload Widget</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type='text/javascript'>
var media = null;
function delveUploadWidgetCallback(data) {
media = eval(unescape(data));
console.log(media);
}
</script>
</head>
<body>
<?php print $media->getUploadWidget(); ?>
</body>
</html>
6 changes: 0 additions & 6 deletions lib/CachedRequest/HTTP/CachedRequest.php
Expand Up @@ -2,12 +2,6 @@

// Include the HTTP_Request2 class.
include_once 'HTTP/Request2.php';
if (!class_exists('HTTP_Request2', FALSE)) {
// Add the included pear library in the include path.
ini_set('include_path',ini_get('include_path').':' . dirname(__FILE__) . '/PEAR:');
include_once 'HTTP/Request2.php';
}

require_once 'CachedResponse.php';

class HTTP_CachedRequest extends HTTP_Request2 {
Expand Down

0 comments on commit e4d57e7

Please sign in to comment.