Merge branch 'refactoring' of git://anongit.kde.org/owncloud into refactoring
|
@ -16,3 +16,5 @@ _darcs/*
|
|||
CVS/*
|
||||
.svn/*
|
||||
RCS/*
|
||||
.kdev
|
||||
*.kdev4
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
OC_APP::register( array( "order" => 1, "id" => "admin", "name" => "Administration" ));
|
||||
|
||||
OC_APP::addAdminPage( array( "id" => "core_system", "order" => 1, "href" => OC_HELPER::linkTo( "admin", "system.php" ), "name" => "System setting", "icon" => OC_HELPER::imagePath( "admin", "administration.png" )));
|
||||
OC_APP::addAdminPage( array( "id" => "core_system", "order" => 1, "href" => OC_HELPER::linkTo( "admin", "system.php" ), "name" =>"System", "icon" => OC_HELPER::imagePath( "admin", "administration.png" )));
|
||||
OC_APP::addAdminPage( array( "id" => "core_users", "order" => 2, "href" => OC_HELPER::linkTo( "admin", "users.php" ), "name" => "Users", "icon" => OC_HELPER::imagePath( "admin", "users.png" )));
|
||||
OC_APP::addAdminPage( array( "id" => "core_apps", "order" => 3, "href" => OC_HELPER::linkTo( "admin", "apps.php" ), "name" => "Apps", "icon" => OC_HELPER::imagePath( "admin", "apps.png" )));
|
||||
OC_APP::addAdminPage( array( "id" => "core_plugins", "order" => 4, "href" => OC_HELPER::linkTo( "admin", "plugins.php" ), "name" => "Plugins", "icon" => OC_HELPER::imagePath( "admin", "apps.png" )));
|
||||
OC_APP::addAdminPage( array( "id" => "core_plugins", "order" => 4, "href" => OC_HELPER::linkTo( "admin", "plugins.php" ), "name" => "Plugins", "icon" => OC_HELPER::imagePath( "admin", "plugins.png" )));
|
||||
|
||||
// Add subentries for App installer
|
||||
OC_APP::addNavigationSubEntry( "core_apps", array( "id" => "core_apps_installed", "order" => 4, "href" => OC_HELPER::linkTo( "admin", "apps.php?add=some¶meters=here" ), "name" => "Installed apps", "icon" => OC_HELPER::imagePath( "admin", "navicon.png" )));
|
||||
|
|
Before Width: | Height: | Size: 217 B After Width: | Height: | Size: 216 B |
After Width: | Height: | Size: 217 B |
Before Width: | Height: | Size: 765 B After Width: | Height: | Size: 741 B |
|
@ -99,6 +99,9 @@ table td.download { background-image:url('../img/download.png'); }
|
|||
table td.upload { background-image:url('../img/upload.png'); }
|
||||
table td.create { background-image:url('../img/folder-new.png'); }
|
||||
table td.delete { background-image:url('../img/delete.png'); }
|
||||
#fileList tr input[type=checkbox] { display:none; }
|
||||
#fileList tr input[type=checkbox]:checked { display:inline; }
|
||||
#fileList tr:hover input[type=checkbox] { display:inline; }
|
||||
|
||||
/* NAVIGATION BAR */
|
||||
p.nav { margin:1em 0 0 2em; padding:0.8em; line-height:16px; font-weight:bold; }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
OC_APP::register( array( "order" => 2, "id" => "files", "name" => "Files" ));
|
||||
|
||||
OC_APP::addNavigationEntry( array( "id" => "files_index", "order" => 1, "href" => OC_HELPER::linkTo( "files", "index.php" ), "icon" => OC_HELPER::imagePath( "files", "navicon.png" ), "name" => "Files" ));
|
||||
OC_APP::addNavigationEntry( array( "id" => "files_index", "order" => 1, "href" => OC_HELPER::linkTo( "files", "index.php" ), "icon" => OC_HELPER::imagePath( "files", "home.png" ), "name" => "Files" ));
|
||||
OC_APP::addSettingsPage( array( "id" => "files_administration", "order" => 1, "href" => OC_HELPER::linkTo( "files", "admin.php" ), "name" => "Files", "icon" => OC_HELPER::imagePath( "files", "folder.png" )));
|
||||
|
||||
|
||||
|
|
After Width: | Height: | Size: 391 B |
Before Width: | Height: | Size: 436 B After Width: | Height: | Size: 386 B |
After Width: | Height: | Size: 416 B |
Before Width: | Height: | Size: 397 B |
|
@ -42,6 +42,9 @@ $dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';
|
|||
$files = array();
|
||||
foreach( OC_FILES::getdirectorycontent( $dir ) as $i ){
|
||||
$i["date"] = OC_UTIL::formatDate($i["mtime"] );
|
||||
if($i['directory']=='/'){
|
||||
$i['directory']='';
|
||||
}
|
||||
$files[] = $i;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,19 @@ $(document).ready(function() {
|
|||
$('.browser input:checkbox').attr('checked', false);
|
||||
});
|
||||
|
||||
// Delete current file
|
||||
$('#delete_single_file').click(function() {
|
||||
filename = $('#file_menu').parents('tr:first').find('.filename:first').children('a:first').text();
|
||||
$.ajax({
|
||||
url: 'ajax/delete.php',
|
||||
data: "dir="+$('#dir').val()+"&file="+filename,
|
||||
complete: function(data){
|
||||
boolOperationFinished(data, true, $('#file_menu').parents('tr:first'));
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#file_upload_start').click(function() {
|
||||
$('#file_upload_target').load(uploadFinished);
|
||||
});
|
||||
|
@ -47,7 +60,7 @@ $(document).ready(function() {
|
|||
$.ajax({
|
||||
url: 'ajax/newfolder.php',
|
||||
data: "dir="+$('#dir').val()+"&foldername="+$('#file_new_dir_name').val(),
|
||||
complete: boolOpFinished
|
||||
complete: function(data){boolOperationFinished(data, false);}
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -98,14 +111,20 @@ function resetFileActionPanel() {
|
|||
$('#file_action_panel').attr('activeAction', false);
|
||||
}
|
||||
|
||||
function boolOpFinished(data) {
|
||||
function boolOperationFinished(data, single, el) {
|
||||
result = eval("("+data.responseText+");");
|
||||
if(result.status == 'success'){
|
||||
if(single) {
|
||||
$('#file_menu').slideToggle(0);
|
||||
$('body').append($('#file_menu'));
|
||||
$(el).remove();
|
||||
} else {
|
||||
$.ajax({
|
||||
url: 'ajax/list.php',
|
||||
data: "dir="+$('#dir').val(),
|
||||
complete: refreshContents
|
||||
});
|
||||
}
|
||||
} else {
|
||||
alert(result.data.message);
|
||||
}
|
||||
|
@ -117,7 +136,11 @@ function refreshContents(data) {
|
|||
updateBreadcrumb(result.data.breadcrumb);
|
||||
}
|
||||
updateFileList(result.data.files);
|
||||
$('#file_upload_button').click();
|
||||
$('td.fileaction a').click(function() {
|
||||
$(this).parent().append($('#file_menu'));
|
||||
$('#file_menu').slideToggle(250);
|
||||
return false;
|
||||
});
|
||||
resetFileActionPanel();
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,6 @@ name="file_upload_target" src=""></iframe></form>
|
|||
<ul>
|
||||
<li><a href="" title="">Download</a></li>
|
||||
<li><a href="" title="">Share</a></li>
|
||||
<li><a href="" title="">Delete</a></li>
|
||||
<li><a href="" title="" id="delete_single_file">Delete</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<a href="<?php echo link_to("files", "index.php?dir=/"); ?>"><img src="<?php echo image_path("", "actions/go-home.png"); ?>" alt="Root" /></a>
|
||||
<?php foreach($_["breadcrumb"] as $crumb): ?>
|
||||
<a href="<?php echo link_to("files", "index.php?dir=".$crumb["dir"]); ?>"><?php echo $crumb["name"]; ?></a>
|
||||
<a href="<?php echo link_to("files", "index.php?dir=".$crumb["dir"]); ?>"><?php echo htmlspecialchars($crumb["name"]); ?></a>
|
||||
<?php endforeach; ?>
|
|
@ -1,9 +1,9 @@
|
|||
<?php foreach($_["files"] as $file): ?>
|
||||
<tr>
|
||||
<td class="selection"><input type="checkbox" /></td>
|
||||
<td class="filename"><a style="background-image:url(<?php if($file["type"] == "dir") echo mimetype_icon("dir"); else echo mimetype_icon($file["mime"]); ?>)" href="<?php if($file["type"] == "dir") echo link_to("files", "index.php?dir=".$file["directory"]."/".$file["name"]); else echo link_to("files", "download.php?file=".$file["directory"]."/".$file["name"]); ?>" title=""><?php echo $file["name"]; ?></a></td>
|
||||
<td class="filename"><a style="background-image:url(<?php if($file["type"] == "dir") echo mimetype_icon("dir"); else echo mimetype_icon($file["mime"]); ?>)" href="<?php if($file["type"] == "dir") echo link_to("files", "index.php?dir=".$file["directory"]."/".$file["name"]); else echo link_to("files", "download.php?file=".$file["directory"]."/".$file["name"]); ?>" title=""><?php echo htmlspecialchars($file["name"]); ?></a></td>
|
||||
<td class="filesize"><?php echo human_file_size($file["size"]); ?></td>
|
||||
<td class="date"><?php if($file["type"] != "dir") echo $file["date"]; ?></td>
|
||||
<td class="date"><?php echo $file["date"]; ?></td>
|
||||
<td class="fileaction"><a href="" title=""><img src="images/drop-arrow.png" alt="+" /></a></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
Before Width: | Height: | Size: 467 B After Width: | Height: | Size: 483 B |
Before Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 391 B |
Before Width: | Height: | Size: 436 B After Width: | Height: | Size: 386 B |
Before Width: | Height: | Size: 1.7 KiB |
31
lib/base.php
|
@ -242,36 +242,21 @@ class OC_UTIL {
|
|||
public static function showPageNavi($pagecount,$page,$url) {
|
||||
|
||||
$pagelinkcount=8;
|
||||
$txt='';
|
||||
if ($pagecount>1) {
|
||||
$txt.='<center><table class="pager" cellspacing="0" cellpadding="0" border="0"><tr><td width="1">';
|
||||
|
||||
if ($page>'0') {
|
||||
$txt.='<span class="pagerbutton1"><a href="'.$url.($page-1).'">prev</a> </span>';
|
||||
}
|
||||
$txt.='</td><td width="1">';
|
||||
|
||||
$pagestart=$page-$pagelinkcount;
|
||||
if($pagestart<0) $pagestart=0;
|
||||
$pagestop=$page+$pagelinkcount;
|
||||
if($pagestop>$pagecount) $pagestop=$pagecount;
|
||||
if ($pagestart<>0) $txt.='...';
|
||||
for ($i=$pagestart; $i < $pagestop;$i++) {
|
||||
if ($i<>$page) {
|
||||
$txt.='<a href="'.$url.$i.'"> '.($i+1).' </a>';
|
||||
} else {
|
||||
$txt.=' <b>'.($i+1).'</b> ';
|
||||
|
||||
$tmpl = new OC_TEMPLATE( '', 'part.pagenavi', '' );
|
||||
$tmpl->assign('page',$page);
|
||||
$tmpl->assign('pagecount',$pagecount);
|
||||
$tmpl->assign('pagestart',$pagestart);
|
||||
$tmpl->assign('pagestop',$pagestop);
|
||||
$tmpl->assign('url',$url);
|
||||
$tmpl->printPage();
|
||||
}
|
||||
}
|
||||
if ($pagecount>$pagestop) $txt.='...';
|
||||
$txt.='</td><td width="1">';
|
||||
if (($page+1)<$pagecount) {
|
||||
$txt.='<span class="pagerbutton2"><a href="'.$url.($page+1).'">next</a></span>';
|
||||
}
|
||||
$txt.='</td></tr></table></center>';
|
||||
}
|
||||
echo($txt);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
$RUNTIME_NOAPPS=true; //no need to load the apps
|
||||
$RUNTIME_NOSETUPFS=true; //don't setup the fs yet
|
||||
|
||||
require_once '../../lib/base.php';
|
||||
require( 'template.php' );
|
||||
|
||||
require_once 'lib_public.php';
|
||||
|
||||
//get the path of the shared file
|
||||
$token=$_GET['token'];
|
||||
$path=OC_PublicLink::getPath($token);
|
||||
$root=$path;
|
||||
|
||||
if($path!==false){
|
||||
if(isset($_GET['path']) and !strstr($_GET['path'],'..')){
|
||||
$subPath=$_GET['path'];
|
||||
}else{
|
||||
$subPath='';
|
||||
}
|
||||
$path.=$subPath;
|
||||
if(OC_FILESYSTEM::is_dir($path)){
|
||||
$files = array();
|
||||
$rootLength=strlen($root);
|
||||
foreach( OC_FILES::getdirectorycontent( $path ) as $i ){
|
||||
$i['date'] = OC_UTIL::formatDate($i['mtime'] );
|
||||
$i['directory']=substr($i['directory'],$rootLength);
|
||||
if($i['directory']=='/'){
|
||||
$i['directory']='';
|
||||
}
|
||||
$files[] = $i;
|
||||
}
|
||||
|
||||
// Make breadcrumb
|
||||
$breadcrumb = array();
|
||||
$pathtohere = "/";
|
||||
foreach( explode( "/", $subPath ) as $i ){
|
||||
if( $i != "" ){
|
||||
$pathtohere .= "$i/";
|
||||
$breadcrumb[] = array( "dir" => $pathtohere, "name" => $i );
|
||||
}
|
||||
}
|
||||
|
||||
$breadcrumbNav = new OC_TEMPLATE( "plugins/publiclink", "breadcrumb", "" );
|
||||
$breadcrumbNav->assign( "breadcrumb", $breadcrumb );
|
||||
$breadcrumbNav->assign('token',$token);
|
||||
|
||||
$list = new OC_TEMPLATE( 'plugins/publiclink', 'files', '' );
|
||||
$list->assign( 'files', $files );
|
||||
$list->assign('token',$token);
|
||||
|
||||
$tmpl = new OC_TEMPLATE( 'plugins/publiclink', 'index', 'user' );
|
||||
$tmpl->assign('fileList', $list->fetchPage());
|
||||
$tmpl->assign( "breadcrumb", $breadcrumbNav->fetchPage() );
|
||||
$tmpl->printPage();
|
||||
}else{
|
||||
//get time mimetype and set the headers
|
||||
$mimetype=OC_FILESYSTEM::getMimeType($path);
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
header('Content-Disposition: attachment; filename="'.basename($path).'"');
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||
header('Pragma: public');
|
||||
header('Content-Type: ' . $mimetype);
|
||||
header('Content-Length: ' . OC_FILESYSTEM::filesize($path));
|
||||
|
||||
//download the file
|
||||
ob_clean();
|
||||
OC_FILESYSTEM::readfile($path);
|
||||
}
|
||||
}else{
|
||||
header("HTTP/1.0 404 Not Found");
|
||||
echo '404 Not Found';
|
||||
die();
|
||||
}
|
||||
?>
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
$RUNTIME_NOAPPS=true; //no need to load the apps
|
||||
$RUNTIME_NOSETUPFS=true; //don't setup the fs yet
|
||||
|
||||
require_once '../../lib/base.php';
|
||||
|
||||
require_once 'lib_public.php';
|
||||
|
||||
$token=$_GET['token'];
|
||||
OC_PublicLink::downloadFile($token);
|
||||
?>
|
|
@ -6,9 +6,9 @@ class OC_PublicLink{
|
|||
* @param int (optional) expiretime time the link expires, as timestamp
|
||||
*/
|
||||
public function __construct($path,$expiretime=0){
|
||||
if($path && OC_FILESYSTEM::file_exists($path)){
|
||||
$token=sha1("$path-$expiretime");
|
||||
if($path and OC_FILESYSTEM::file_exists($path) and OC_FILESYSTEM::is_readable($path)){
|
||||
$user=$_SESSION['user_id'];
|
||||
$token=sha1("$user-$path-$expiretime");
|
||||
$query=OC_DB::prepare("INSERT INTO *PREFIX*publiclink VALUES(?,?,?,?)");
|
||||
$result=$query->execute(array($token,$path,$user,$expiretime));
|
||||
if( PEAR::isError($result)) {
|
||||
|
@ -22,10 +22,9 @@ class OC_PublicLink{
|
|||
}
|
||||
|
||||
/**
|
||||
* download a file shared by a public link
|
||||
* @param string token
|
||||
* get the path of that shared file
|
||||
*/
|
||||
public static function downloadFile($token){
|
||||
public static function getPath($token){
|
||||
//remove expired links
|
||||
$query=OC_DB::prepare("DELETE FROM *PREFIX*publiclink WHERE expire_time < NOW() AND expire_time!=0");
|
||||
$query->execute();
|
||||
|
@ -41,23 +40,9 @@ class OC_PublicLink{
|
|||
//prepare the filesystem
|
||||
OC_UTIL::setupFS($user);
|
||||
|
||||
//get time mimetype and set the headers
|
||||
$mimetype=OC_FILESYSTEM::getMimeType($path);
|
||||
// header('Content-Disposition: attachment; filename="'.basename($path).'"');
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||
header('Pragma: public');
|
||||
header('Content-Type: ' . $mimetype);
|
||||
header('Content-Length: ' . OC_FILESYSTEM::filesize($path));
|
||||
|
||||
//download the file
|
||||
ob_clean();
|
||||
OC_FILESYSTEM::readfile($path);
|
||||
return $path;
|
||||
}else{
|
||||
header("HTTP/1.0 404 Not Found");
|
||||
echo '404 Not Found';
|
||||
die();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
<a href="<?php echo link_to("plugins/publiclink", "get.php?token=".$_['token']); ?>"><img src="<?php echo image_path("", "actions/go-home.png"); ?>" alt="Root" /></a>
|
||||
<?php foreach($_["breadcrumb"] as $crumb): ?>
|
||||
<a href="<?php echo link_to("plugins/publiclink", "get.php?token=".$_['token']."&path=".$crumb["dir"]); ?>"><?php echo htmlspecialchars($crumb["name"]); ?></a>
|
||||
<?php endforeach; ?>
|
|
@ -0,0 +1,9 @@
|
|||
<?php foreach($_["files"] as $file): ?>
|
||||
<tr>
|
||||
<td class="selection"><input type="checkbox" /></td>
|
||||
<td class="filename"><a style="background-image:url(<?php if($file["type"] == "dir") echo mimetype_icon("dir"); else echo mimetype_icon($file["mime"]); ?>)" href="<?php if($file["type"] == "dir") echo link_to("plugins/publiclink", "get.php?token=".$_['token']."&path=".$file["directory"]."/".$file["name"]); else echo link_to("plugins/publiclink", "get.php?token=".$_['token']."&path=".$file["directory"]."/".$file["name"]); ?>" title=""><?php echo htmlspecialchars($file["name"]); ?></a></td>
|
||||
<td class="filesize"><?php echo human_file_size($file["size"]); ?></td>
|
||||
<td class="date"><?php if($file["type"] != "dir") echo $file["date"]; ?></td>
|
||||
<td class="fileaction"><a href="" title=""><img src="images/drop-arrow.png" alt="+" /></a></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
|
@ -0,0 +1,17 @@
|
|||
<p class="nav">
|
||||
<?php echo($_['breadcrumb']); ?>
|
||||
</p>
|
||||
<table cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><input type="checkbox" id="select_all" /></th>
|
||||
<th>Name</th>
|
||||
<th>Size</th>
|
||||
<th>Modified</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="fileList">
|
||||
<?php echo($_['fileList']); ?>
|
||||
</tbody>
|
||||
</table>
|
Before Width: | Height: | Size: 597 B After Width: | Height: | Size: 595 B |
|
@ -0,0 +1,31 @@
|
|||
<center>
|
||||
<table class="pager" cellspacing="0" cellpadding="0" border="0">
|
||||
<tr>
|
||||
<td width="1">
|
||||
<?php if($_['page']>0):?>
|
||||
<span class="pagerbutton1"><a href="<?php echo $_['url'].($_['page']-1);?>">prev</a> </span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php if ($_['pagestart']>0):?>
|
||||
...
|
||||
<?php endif;?>
|
||||
<?php for ($i=$_['pagestart']; $i < $_['pagestop'];$i++):?>
|
||||
<?php if ($_['page']!=$i):?>
|
||||
<a href="<?php echo $_['url'].$i;?>"><?php echo $i+1;?> </a>
|
||||
<?php else:?>
|
||||
<?php echo $i+1;?>
|
||||
<?php endif?>
|
||||
<?php endfor;?>
|
||||
<?php if ($_['pagestop']<$_['pagecount']):?>
|
||||
...
|
||||
<?php endif;?>
|
||||
</td>
|
||||
<td width="1">
|
||||
<?php if(($_['page']+1)<$_['pagecount']):?>
|
||||
<span class="pagerbutton2"><a href="<?php echo $_['url'].($_['page']+1);?>">next</a></span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|