]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-13766, add a navbar to thumbnail view.
authordongsheng <dongsheng>
Mon, 1 Sep 2008 03:07:16 +0000 (03:07 +0000)
committerdongsheng <dongsheng>
Mon, 1 Sep 2008 03:07:16 +0000 (03:07 +0000)
repository/boxnet/boxlibphp5.php
repository/boxnet/repository.class.php
repository/lib.php

index a4312d6d745592408fc9724b38d3b2d80fe49694..8cabe5c367c1dd3aacc16b736bbf17c05ccd8283 100755 (executable)
@@ -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
index e898e6ca2fc3052e440795d60c4f46c7d7a09787..aa80928a91953b90eb68102da47269b7141560bd 100755 (executable)
@@ -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 {
index 624ccf4161d71c232ada0454f8f5ca73d9a87ed6..07000464baffb5c617f5a28e38cc4d40238b4aa6 100644 (file)
@@ -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);
+            });
         }
     }
 }