Browse Source

dav : suite

Valentin CARRUESCO 4 years ago
parent
commit
6ddfd8fdd9
3 changed files with 1878 additions and 1264 deletions
  1. 20 12
      plugin/hackpoint/hackpoint.plugin.php
  2. 1 0
      plugin/hackpoint/logs/dav-lock.json
  3. 1857 1252
      plugin/hackpoint/logs/dav-logs.txt

+ 20 - 12
plugin/hackpoint/hackpoint.plugin.php

@@ -251,12 +251,7 @@ function hackpoint_dav($requested){
 		require_once(__DIR__.SLASH.'Resource.class.php');
 		User::check_access('hackpoint','read');
 
-
-
-		
 		$files  = array();
-		
-		
 		$file = array();
 		$file['label'] = '';
 		$file['type'] = 'directory';
@@ -266,17 +261,30 @@ function hackpoint_dav($requested){
 		if($depth>0){
 			if(!empty($utf8Path)){
 
-				preg_match('/#([0-9]*)/i', $utf8Path,$matches);
+				preg_match_all('/#([0-9]*)/i', $utf8Path,$matches,PREG_SET_ORDER);
+				
+				$sketch = Sketch::getById($matches[0][1]);
+				if(count($matches)>1){
+					$resources = array(Resource::getById($matches[1][1]));
+				}else{
+					$resources = Resource::loadAll(array('sketch'=>$sketch->id));
+				}
+				foreach($resources as $resource){
 
-				$sketch = Sketch::load(array('id'=>$matches[1]));
-				foreach(Resource::loadAll(array('sketch'=>$sketch->id)) as $resource){
 					$type = $resource->type();
 					$file = array();
-					$file['label'] = $resource->label.' #'.$resource->id.'.'.$type['toExtension'];
-					$file['type'] = 'file';
+
+					if(in_array($type['uid'], array('arduino'))  && count($matches)==1 ){
+						$file['label'] = $resource->label.' #'.$resource->id;
+						$file['type'] = 'directory';
+					}else{
+						$file['label'] = $resource->label.' #'.$resource->id.'.'.$type['toExtension'];
+						$file['type'] = 'file';
+					}
+
 					$file['create_time']  = $resource->created;
 					$file['update_time']  =  $resource->updated;
-					$file['length'] =  1000;
+					$file['length'] =  strlen($resource->content);
 					$files[] = $file;
 				}
 			}else{
@@ -286,7 +294,7 @@ function hackpoint_dav($requested){
 					$file['type'] = 'directory';
 					$file['create_time']  = $sketch->created;
 					$file['update_time']  =  $sketch->updated;
-					$file['length'] =  1000;
+					$file['length'] =  1;
 					$files[] = $file;
 				}
 			}

+ 1 - 0
plugin/hackpoint/logs/dav-lock.json

@@ -0,0 +1 @@
+[]

File diff suppressed because it is too large
+ 1857 - 1252
plugin/hackpoint/logs/dav-logs.txt


Some files were not shown because too many files changed in this diff