Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
MDL-13766, add a navbar to thumbnail view.
  • Loading branch information
dongsheng committed Sep 1, 2008
1 parent a846af6 commit 31640be
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 30 deletions.
10 changes: 7 additions & 3 deletions repository/boxnet/boxlibphp5.php
Expand Up @@ -125,7 +125,7 @@ function getAuthToken($ticket, $username, $password) {
}
}
//
function getfiletree($params = array()) {
function getfiletree($path, $params = array()) {
$this->_clearErrors();
$params['auth_token'] = $this->auth_token;
$params['folder_id'] = 0;
Expand Down Expand Up @@ -154,13 +154,15 @@ function getfiletree($params = array()) {

function buildtree($sax, &$tree){
$sax = (array)$sax;
$count = 0;
foreach($sax as $k=>$v){
if($k == 'folders'){
$o = $sax[$k];
foreach($o->folder as $z){
$tmp = array('title'=>(string)$z->attributes()->name,
'size'=>0, 'date'=>userdate(time()),
'thumbnail'=>'http://www.box.net/img/small_folder_icon.gif');
'thumbnail'=>'http://www.box.net/img/small_folder_icon.gif',
'path'=>array('name'=>(string)$z->attributes()->name, 'path'=>(int)$z->attributes()->id));
$tmp['children'] = array();
$this->buildtree($z, $tmp['children']);
$tree[] = $tmp;
Expand All @@ -177,10 +179,12 @@ function buildtree($sax, &$tree){
'thumbnail'=>$thumbnail,
'date'=>userdate((int)$file->attributes()->updated),
'source'=>'http://box.net/api/1.0/download/'
.$this->auth_token.'/'.(string)$file->attributes()->id);
.$this->auth_token.'/'.(string)$file->attributes()->id,
'url'=>(string)$file->attributes()->shared_link);
$tree[] = $tmp;
}
}
$count++;
}
}
// Get the file list
Expand Down
4 changes: 2 additions & 2 deletions repository/boxnet/repository.class.php
Expand Up @@ -96,12 +96,12 @@ public function get_listing($path = '/', $search = ''){
global $CFG, $SESSION;
$list = array();
$ret = array();
$tree = $this->box->getfiletree();
$tree = $this->box->getfiletree($path);
if(!empty($tree)) {
// TODO: think about how to search
$ret['list'] = $tree;
$ret['manage'] = 'http://www.box.net/files';
$ret['path'] = array(array('name'=>'Root','path'=>null));
$ret['path'] = array(array('name'=>'Root', 'path'=>0));
$this->listing = $tree;
return $ret;
} else {
Expand Down
41 changes: 16 additions & 25 deletions repository/lib.php
Expand Up @@ -653,7 +653,8 @@ function repository_get_client($context){
#repo-list-$suffix li{margin-bottom: 1em}
#paging-$suffix{margin:10px 5px; clear:both;}
#paging-$suffix a{padding: 4px;border: 1px solid #CCC}
#path-$suffix a{padding: 4px;background: gray}
#path-$suffix{margin: 4px;border-bottom: 1px dotted gray;}
#path-$suffix a{padding: 4px;}
#panel-$suffix{padding:0;margin:0; text-align:left;}
#rename-form{text-align:center}
#rename-form p{margin: 1em;}
Expand Down Expand Up @@ -1097,30 +1098,20 @@ function _client(){
oDiv.id = "path-$suffix";
panel.get('element').appendChild(oDiv);
for(var i = 0; i < _client.ds.path.length; i++) {
if(_client.ds.dynload){
var str = '<a onclick="repository_client_$suffix.req('+_client.repositoryid+', "'+_client.ds.path[i].path+'", 0)" href="###">';
str += _client.ds.path[i].name;
str += '</a> ';
//oDiv.innerHTML += str;
}else{
var link = document.createElement('A');
link.href = "###";
link.innerHTML = _client.ds.path[i].name;
link.id = 'path-'+i+'-el';
var sep = document.createElement('SPAN');
sep.innerHTML = ' / ';
panel.get('element').appendChild(link);
panel.get('element').appendChild(sep);
var el = new YAHOO.util.Element(link.id);
//el.ds = list[k].children;
el.on('click', function(){
if(_client.ds.dynload) {
// TODO: get file list dymanically
}else{
// TODO: try to find children
}
});
}
var link = document.createElement('A');
link.href = "###";
link.innerHTML = _client.ds.path[i].name;
link.id = 'path-'+i+'-el';
var sep = document.createElement('SPAN');
sep.innerHTML = '/';
oDiv.appendChild(link);
oDiv.appendChild(sep);
var el = new YAHOO.util.Element(link.id);
el.id = _client.repositoryid;
el.path = _client.ds.path[i].path;
el.on('click', function(){
repository_client_$suffix.req(this.id, this.path, 0);
});
}
}
}
Expand Down

0 comments on commit 31640be

Please sign in to comment.