From 31640be23a4376b015f3c30922a56e6d7f332a96 Mon Sep 17 00:00:00 2001
From: dongsheng <dongsheng>
Date: Mon, 1 Sep 2008 03:07:16 +0000
Subject: [PATCH] MDL-13766, add a navbar to thumbnail view.

---
 repository/boxnet/boxlibphp5.php       | 10 +++++--
 repository/boxnet/repository.class.php |  4 +--
 repository/lib.php                     | 41 ++++++++++----------------
 3 files changed, 25 insertions(+), 30 deletions(-)

diff --git a/repository/boxnet/boxlibphp5.php b/repository/boxnet/boxlibphp5.php
index a4312d6d74..8cabe5c367 100755
--- a/repository/boxnet/boxlibphp5.php
+++ b/repository/boxnet/boxlibphp5.php
@@ -125,7 +125,7 @@ class boxclient {
         }
     }
     //
-    function getfiletree($params = array()) {
+    function getfiletree($path, $params = array()) {
         $this->_clearErrors();
         $params['auth_token'] = $this->auth_token;
         $params['folder_id']  = 0;
@@ -154,13 +154,15 @@ class boxclient {
 
     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;
@@ -177,10 +179,12 @@ class boxclient {
                         '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
diff --git a/repository/boxnet/repository.class.php b/repository/boxnet/repository.class.php
index e898e6ca2f..aa80928a91 100755
--- a/repository/boxnet/repository.class.php
+++ b/repository/boxnet/repository.class.php
@@ -96,12 +96,12 @@ class repository_boxnet extends repository{
         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 {
diff --git a/repository/lib.php b/repository/lib.php
index 624ccf4161..07000464ba 100644
--- a/repository/lib.php
+++ b/repository/lib.php
@@ -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;}
@@ -1097,30 +1098,20 @@ _client.makepath = function(){
         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);
+            });
         }
     }
 }
-- 
2.39.5