mirror of
https://github.com/kennethreitz-archive/wp-s3.git
synced 2026-06-05 23:50:19 +00:00
more initial work
This commit is contained in:
@@ -9,4 +9,7 @@ addLoadEvent(function () {
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
<style type="text/css">
|
||||
@import url(../wp-content/plugins/tantan/wordpress-s3/styles.css);
|
||||
</style>
|
||||
@@ -2,9 +2,9 @@
|
||||
function print_keys($keys, $level=0) {
|
||||
echo "<ul class='level-$level'>\n";
|
||||
foreach ($keys as $key => $obj) if ($key{0} != '_') {
|
||||
echo '<li class="level-'.$level.'">'.$key."\n";
|
||||
echo '<li class="level-'.$level.'"><div class="prefix">'.$key."</div>\n";
|
||||
|
||||
print_keys($obj, $level++);
|
||||
print_keys($obj, $level+1);
|
||||
echo "</li>\n";
|
||||
}
|
||||
|
||||
@@ -16,16 +16,33 @@ function print_keys($keys, $level=0) {
|
||||
}
|
||||
|
||||
?>
|
||||
<style>
|
||||
#upload-content {
|
||||
padding-top:10px;
|
||||
<div class="path">
|
||||
Path:
|
||||
<?php
|
||||
$tree = $keys;
|
||||
echo '<a href="'.add_query_arg('prefix', urlencode(''), $_SERVER['REQUEST_URI']).'">home</a> / ';
|
||||
$path = '';
|
||||
while (!$tree['_objects'] && $i++ < 1000) {
|
||||
$name = key($tree);
|
||||
$path .= $name .'/';
|
||||
echo '<a href="'.add_query_arg('prefix', urlencode($path), $_SERVER['REQUEST_URI']).'">'.$name.'</a> / ';
|
||||
$tree = array_pop($tree);
|
||||
}
|
||||
</style>
|
||||
<div>
|
||||
|
||||
?>
|
||||
</div>
|
||||
<div class="folders">
|
||||
<ul>
|
||||
<?php if (is_array($prefixes)) foreach ($prefixes as $prefix):?>
|
||||
<li><?php echo $prefix;?></li>
|
||||
<li><a href="<?php echo add_query_arg('prefix', urlencode($prefix), $_SERVER['REQUEST_URI']);?>"><?php echo ereg_replace("^$path", "", $prefix);?></a></li>
|
||||
<?php endforeach;?>
|
||||
</ul>
|
||||
<?php print_keys($keys); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="files">
|
||||
<ul>
|
||||
<?php foreach ($tree['_objects'] as $file): ?>
|
||||
<li><a href="<?php echo 'http://'.$bucket.'.s3.amazonaws.com'.$tree['_path'].$file?>"><?php echo $file;?></a></li>
|
||||
<?php endforeach;?>
|
||||
</ul>
|
||||
</div>
|
||||
<br clear="both" />
|
||||
@@ -112,11 +112,16 @@ class TanTanWordPressS3Plugin {
|
||||
if (!$this->options['key'] || !$this->options['secret']) {
|
||||
return;
|
||||
}
|
||||
$bucket = $this->options['bucket'];
|
||||
|
||||
require_once(dirname(__FILE__).'/lib.s3.php');
|
||||
$s3 = new TanTanS3($this->options['key'], $this->options['secret']);
|
||||
$ret = $s3->listKeys($this->options['bucket'], false, urlencode('s3/'), '/');//, false, 's3/', '/');
|
||||
print_r($ret);
|
||||
|
||||
$prefix = $_GET['prefix'] ? $_GET['prefix'] : '';
|
||||
//echo urlencode($prefix);
|
||||
|
||||
$ret = $s3->listKeys($bucket, false, urlencode($prefix), '/');//, false, 's3/', '/');
|
||||
//print_r($ret);
|
||||
$keysList = $ret['keys'];
|
||||
$prefixes = $ret['prefixes'];
|
||||
//print_r($keysList);
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
.path {
|
||||
padding:5px 0 0 0;
|
||||
margin:0 0 5px 0;
|
||||
font-size:0.9em;
|
||||
background:#eee;
|
||||
}
|
||||
.path a {
|
||||
border:0;
|
||||
color:black;
|
||||
text-decoration:none;
|
||||
}
|
||||
.path a:hover {
|
||||
text-decoration:underline;
|
||||
}
|
||||
.folders ul {
|
||||
list-style:none;
|
||||
margin:0;
|
||||
padding:0;
|
||||
|
||||
}
|
||||
.folders li {
|
||||
float:left;
|
||||
background:url(folder.gif) no-repeat;
|
||||
padding:0 0 0 20px;
|
||||
margin-right:10px;
|
||||
font-size:0.9em;
|
||||
|
||||
}
|
||||
.folders li a {
|
||||
color:#555;
|
||||
border:0;
|
||||
text-decoration:none;
|
||||
}
|
||||
.folders li a:hover {
|
||||
background:#eee;
|
||||
}
|
||||
|
||||
.files {
|
||||
clear:both;
|
||||
}
|
||||
.files ul {
|
||||
list-style:none;
|
||||
margin:0;
|
||||
padding:0;
|
||||
}
|
||||
.files ul li {
|
||||
float:left;
|
||||
width:30%;
|
||||
font-size:0.9em;
|
||||
}
|
||||
.files ul li a {
|
||||
border:0;
|
||||
text-decoration:underline;
|
||||
|
||||
}
|
||||
.files ul li a:hover {
|
||||
background:#eee;
|
||||
}
|
||||
Reference in New Issue
Block a user