]> source.dussan.org Git - nextcloud-server.git/commitdiff
One class per file!
authorJakob Sack <kde@jakobsack.de>
Fri, 29 Jul 2011 19:03:53 +0000 (21:03 +0200)
committerJakob Sack <kde@jakobsack.de>
Fri, 29 Jul 2011 19:03:53 +0000 (21:03 +0200)
27 files changed:
apps/media/lib_media.php
lib/app.php
lib/appconfig.php
lib/base.php
lib/config.php
lib/connect.php
lib/connector/sabre/locks.php
lib/connector/sabre/node.php
lib/db.php
lib/fakedirstream.php [new file with mode: 0644]
lib/files.php
lib/filestorage/remote.php [new file with mode: 0644]
lib/filesystem.php
lib/helper.php
lib/log.php
lib/mimetypes.list.php
lib/ocs.php
lib/ocsclient.php
lib/preferences.php
lib/remote/cloud.php
lib/remotestorage.php [deleted file]
lib/search.php
lib/search/provider.php [new file with mode: 0644]
lib/search/provider/file.php [new file with mode: 0644]
lib/search/result.php [new file with mode: 0644]
lib/setup.php
lib/template.php

index 9c3d0622360d583976be18eef083ddccdc8f56b1..6fde2ab748745116e370bfe956e4ca7b0635a6e9 100644 (file)
@@ -82,7 +82,7 @@ class OC_MEDIA{
        }
 }
 
-class OC_MediaSearchProvider extends OC_SearchProvider{
+class OC_MediaSearchProvider extends OC_Search_Provider{
        function search($query){
                require_once('lib_collection.php');
                $artists=OC_MEDIA_COLLECTION::getArtists($query);
@@ -90,18 +90,18 @@ class OC_MediaSearchProvider extends OC_SearchProvider{
                $songs=OC_MEDIA_COLLECTION::getSongs(0,0,$query);
                $results=array();
                foreach($artists as $artist){
-                       $results[]=new OC_SearchResult($artist['artist_name'],'',OC_HELPER::linkTo( 'apps/media', 'index.php#artist='.urlencode($artist['artist_name']) ),'Music');
+                       $results[]=new OC_Search_Result($artist['artist_name'],'',OC_HELPER::linkTo( 'apps/media', 'index.php#artist='.urlencode($artist['artist_name']) ),'Music');
                }
                foreach($albums as $album){
                        $artist=urlencode(OC_MEDIA_COLLECTION::getArtistName($album['album_artist']));
-                       $results[]=new OC_SearchResult($album['album_name'],'',OC_HELPER::linkTo( 'apps/media', 'index.php#artist='.$artist.'&album='.urlencode($album['album_name']) ),'Music');
+                       $results[]=new OC_Search_Result($album['album_name'],'',OC_HELPER::linkTo( 'apps/media', 'index.php#artist='.$artist.'&album='.urlencode($album['album_name']) ),'Music');
                }
                foreach($songs as $song){
                        $minutes=floor($song['song_length']/60);
                        $secconds=$song['song_length']%60;
                        $artist=urlencode(OC_MEDIA_COLLECTION::getArtistName($song['song_artist']));
                        $album=urlencode(OC_MEDIA_COLLECTION::getalbumName($song['song_album']));
-                       $results[]=new OC_SearchResult($song['song_name'],"$minutes:$secconds",OC_HELPER::linkTo( 'apps/media', 'index.php#artist='.$artist.'&album='.$album.'&song='.urlencode($song['song_name']) ),'Music');
+                       $results[]=new OC_Search_Result($song['song_name'],"$minutes:$secconds",OC_HELPER::linkTo( 'apps/media', 'index.php#artist='.$artist.'&album='.$album.'&song='.urlencode($song['song_name']) ),'Music');
                }
                return $results;
        }
index b6c2512e79a8e1f7798bc8e66d0e948d50561c8f..fad0714c3f43c4054d154be79265b76743b70796 100644 (file)
@@ -408,4 +408,3 @@ class OC_APP{
                }
        }
 }
-?>
\ No newline at end of file
index 4fef7542f405c2a94ade6375d290d8161d79cda5..b4735a309bc9b35084d2da3283d437116e7cb0c4 100644 (file)
@@ -158,4 +158,3 @@ class OC_APPCONFIG{
                return true;
        }
 }
-?>
index 4e1b9bd006440579511a4385e66c7030b40d18af..236b5d926a4c9f61d2f428c72a48ad7a2e20254a 100644 (file)
@@ -110,3 +110,93 @@ OC_UTIL::addStyle( "styles" );
 if(!$error and !$RUNTIME_NOAPPS ){
        OC_APP::loadApps();
 }
+
+// FROM Connect.php
+function OC_CONNECT_TEST($path,$user,$password){
+       echo 'connecting...';
+       $remote=OC_CONNECT::connect($path,$user,$password);
+       if($remote->connected){
+               echo 'done<br/>';
+               if($remote->isLoggedIn()){
+                       echo 'logged in, session working<br/>';
+                       echo 'trying to get remote files...';
+                       $files=$remote->getFiles('');
+                       if($files){
+                               echo count($files).' files found:<br/>';
+                               foreach($files as $file){
+                                       echo "{$file['type']} {$file['name']}: {$file['size']} bytes<br/>";
+                               }
+                               echo 'getting file "'.$file['name'].'"...';
+                               $size=$file['size'];
+                               $file=$remote->getFile('',$file['name']);
+                               if(file_exists($file)){
+                                       $newSize=filesize($file);
+                                       if($size!=$newSize){
+                                               echo "fail<br/>Error: $newSize bytes received, $size expected.";
+                                               echo '<br/><br/>Recieved file:<br/>';
+                                               readfile($file);
+                                               unlink($file);
+                                               return;
+                                       }
+                                       OC_FILESYSTEM::fromTmpFile($file,'/remoteFile');
+                                       echo 'done<br/>';
+                                       echo 'sending file "burning_avatar.png"...';
+                                       $res=$remote->sendFile('','burning_avatar.png','','burning_avatar.png');
+                                       if($res){
+                                               echo 'done<br/>';
+                                       }else{
+                                               echo 'fail<br/>';
+                                       }
+                               }else{
+                                       echo 'fail<br/>';
+                               }
+                       }else{
+                               echo 'fail<br/>';
+                       }
+               }else{
+                       echo 'no longer logged in, session fail<br/>';
+               }
+       }else{
+               echo 'fail<br/>';
+       }
+       $remote->disconnect();
+       die();
+}
+
+// From files.php
+function zipAddDir($dir,$zip,$internalDir=''){
+    $dirname=basename($dir);
+    $zip->addEmptyDir($internalDir.$dirname);
+    $internalDir.=$dirname.='/';
+    $files=OC_FILES::getdirectorycontent($dir);
+    foreach($files as $file){
+        $filename=$file['name'];
+        $file=$dir.'/'.$filename;
+        if(OC_FILESYSTEM::is_file($file)){
+                       $tmpFile=OC_FILESYSTEM::toTmpFile($file);
+                       OC_FILES::$tmpFiles[]=$tmpFile;
+            $zip->addFile($tmpFile,$internalDir.$filename);
+        }elseif(OC_FILESYSTEM::is_dir($file)){
+            zipAddDir($file,$zip,$internalDir);
+        }
+    }
+}
+
+if(!function_exists('sys_get_temp_dir')) {
+    function sys_get_temp_dir() {
+        if( $temp=getenv('TMP') )        return $temp;
+        if( $temp=getenv('TEMP') )        return $temp;
+        if( $temp=getenv('TMPDIR') )    return $temp;
+        $temp=tempnam(__FILE__,'');
+        if (file_exists($temp)) {
+          unlink($temp);
+          return dirname($temp);
+        }
+        return null;
+    }
+}
+
+require_once('fakedirstream.php');
+
+// FROM search.php
+new OC_Search_Provider_File();
index cd18ddd499c3bbe94dce296cc3aca1e8766b92a5..ea3647858edb62ed2b0dc0d31e908d58c9d71e18 100644 (file)
@@ -182,4 +182,3 @@ class OC_CONFIG{
                return true;
        }
 }
-?>
index 57017cf9bb41dbc00bba64ed7a619d375704cbee..c02b999ffc2b5f101d78a4057be4af592514914f 100644 (file)
@@ -38,57 +38,3 @@ class OC_CONNECT{
                }
        }
 }
-
-function OC_CONNECT_TEST($path,$user,$password){
-       echo 'connecting...';
-       $remote=OC_CONNECT::connect($path,$user,$password);
-       if($remote->connected){
-               echo 'done<br/>';
-               if($remote->isLoggedIn()){
-                       echo 'logged in, session working<br/>';
-                       echo 'trying to get remote files...';
-                       $files=$remote->getFiles('');
-                       if($files){
-                               echo count($files).' files found:<br/>';
-                               foreach($files as $file){
-                                       echo "{$file['type']} {$file['name']}: {$file['size']} bytes<br/>";
-                               }
-                               echo 'getting file "'.$file['name'].'"...';
-                               $size=$file['size'];
-                               $file=$remote->getFile('',$file['name']);
-                               if(file_exists($file)){
-                                       $newSize=filesize($file);
-                                       if($size!=$newSize){
-                                               echo "fail<br/>Error: $newSize bytes received, $size expected.";
-                                               echo '<br/><br/>Recieved file:<br/>';
-                                               readfile($file);
-                                               unlink($file);
-                                               return;
-                                       }
-                                       OC_FILESYSTEM::fromTmpFile($file,'/remoteFile');
-                                       echo 'done<br/>';
-                                       echo 'sending file "burning_avatar.png"...';
-                                       $res=$remote->sendFile('','burning_avatar.png','','burning_avatar.png');
-                                       if($res){
-                                               echo 'done<br/>';
-                                       }else{
-                                               echo 'fail<br/>';
-                                       }
-                               }else{
-                                       echo 'fail<br/>';
-                               }
-                       }else{
-                               echo 'fail<br/>';
-                       }
-               }else{
-                       echo 'no longer logged in, session fail<br/>';
-               }
-       }else{
-               echo 'fail<br/>';
-       }
-       $remote->disconnect();
-       die();
-}
-
-
-?>
index 88bab509898a1eebae869e799a384c0d9145dda6..9f0b983a5cc19c4ffa660b37c4a43366f5af30f1 100644 (file)
@@ -149,4 +149,3 @@ class OC_Connector_Sabre_Locks extends Sabre_DAV_Locks_Backend_Abstract {
        }
 
 }
-
index 03d5e90012e0f4edc9102f00e08688b57458439a..0edd9b7816185f503012ff893c12f42fcc4b47d6 100644 (file)
@@ -155,4 +155,3 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
                return $props;
        }
 }
-
index 8d7c76756c117dfdffc1b38792f695c054c093d9..f5f877176e927e40c615a9171670235350a6fa41 100644 (file)
@@ -362,4 +362,3 @@ class OC_DB {
                }
        }
 }
-?>
\ No newline at end of file
diff --git a/lib/fakedirstream.php b/lib/fakedirstream.php
new file mode 100644 (file)
index 0000000..fa3e64d
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+global $FAKEDIRS;
+$FAKEDIRS=array();
+
+class fakeDirStream{
+       private $name;
+       private $data;
+       private $index;
+
+       public function dir_opendir($path,$options){
+               global $FAKEDIRS;
+               $url=parse_url($path);
+               $this->name=substr($path,strlen('fakedir://'));
+               $this->index=0;
+               if(isset($FAKEDIRS[$this->name])){
+                       $this->data=$FAKEDIRS[$this->name];
+               }else{
+                       $this->data=array();
+               }
+               return true;
+       }
+
+       public function dir_readdir(){
+               if($this->index>=count($this->data)){
+                       return false;
+               }
+               $filename=$this->data[$this->index];
+               $this->index++;
+               return $filename;
+       }
+
+       public function dir_closedir() {
+               $this->data=false;
+               $this->name='';
+               return true;
+       }
+
+       public function dir_rewinddir() {
+               $this->index=0;
+               return true;
+       }
+}
+stream_wrapper_register("fakedir", "fakeDirStream");
+
index d24eb282c451ba439f09b1b4ef976ed4ad8bd52b..03e159f9bee8d567c180300900e1a60ee63f4cd7 100644 (file)
@@ -298,79 +298,3 @@ class OC_FILES {
                @file_put_contents($SERVERROOT.'/.htaccess', $content); //supress errors in case we don't have permissions for it
        }
 }
-
-function zipAddDir($dir,$zip,$internalDir=''){
-    $dirname=basename($dir);
-    $zip->addEmptyDir($internalDir.$dirname);
-    $internalDir.=$dirname.='/';
-    $files=OC_FILES::getdirectorycontent($dir);
-    foreach($files as $file){
-        $filename=$file['name'];
-        $file=$dir.'/'.$filename;
-        if(OC_FILESYSTEM::is_file($file)){
-                       $tmpFile=OC_FILESYSTEM::toTmpFile($file);
-                       OC_FILES::$tmpFiles[]=$tmpFile;
-            $zip->addFile($tmpFile,$internalDir.$filename);
-        }elseif(OC_FILESYSTEM::is_dir($file)){
-            zipAddDir($file,$zip,$internalDir);
-        }
-    }
-}
-
-if(!function_exists('sys_get_temp_dir')) {
-    function sys_get_temp_dir() {
-        if( $temp=getenv('TMP') )        return $temp;
-        if( $temp=getenv('TEMP') )        return $temp;
-        if( $temp=getenv('TMPDIR') )    return $temp;
-        $temp=tempnam(__FILE__,'');
-        if (file_exists($temp)) {
-          unlink($temp);
-          return dirname($temp);
-        }
-        return null;
-    }
-}
-
-global $FAKEDIRS;
-$FAKEDIRS=array();
-
-class fakeDirStream{
-       private $name;
-       private $data;
-       private $index;
-
-       public function dir_opendir($path,$options){
-               global $FAKEDIRS;
-               $url=parse_url($path);
-               $this->name=substr($path,strlen('fakedir://'));
-               $this->index=0;
-               if(isset($FAKEDIRS[$this->name])){
-                       $this->data=$FAKEDIRS[$this->name];
-               }else{
-                       $this->data=array();
-               }
-               return true;
-       }
-
-       public function dir_readdir(){
-               if($this->index>=count($this->data)){
-                       return false;
-               }
-               $filename=$this->data[$this->index];
-               $this->index++;
-               return $filename;
-       }
-
-       public function dir_closedir() {
-               $this->data=false;
-               $this->name='';
-               return true;
-       }
-
-       public function dir_rewinddir() {
-               $this->index=0;
-               return true;
-       }
-}
-stream_wrapper_register("fakedir", "fakeDirStream");
-?>
diff --git a/lib/filestorage/remote.php b/lib/filestorage/remote.php
new file mode 100644 (file)
index 0000000..74234f4
--- /dev/null
@@ -0,0 +1,350 @@
+<?php
+
+/**
+* ownCloud
+*
+* @author Frank Karlitschek 
+* @copyright 2010 Frank Karlitschek karlitschek@kde.org 
+* 
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either 
+* version 3 of the License, or any later version.
+* 
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*  
+* You should have received a copy of the GNU Affero General Public 
+* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
+* 
+*/
+
+class OC_FILESTORAGE_REMOTE extends OC_FILESTORAGE{
+       private $url;
+       private $username;
+       private $password;
+       private $remote=false;
+       private $statCache;
+       private $statCacheDir=false;
+       private $changed=array();
+       
+       private function cacheDir($dir){
+               if($this->statCacheDir!=$dir or $this->statCacheDir===false){
+                       $this->statCache=$this->remote->getFiles($dir);
+                       $keys=array_keys($this->statCache);
+                       $this->statCacheDir=$dir;
+               }
+       }
+       
+       public function __construct($arguments){
+               $this->url=$arguments['url'];
+               $this->username=$arguments['username'];
+               $this->password=$arguments['password'];
+       }
+       private function connect(){
+               if($this->remote===false){
+                       $this->remote=OC_CONNECT::connect($this->url,$this->username,$this->password);
+               }
+       }
+       public function mkdir($path){
+               $this->connect();
+               $parent=dirname($path);
+               $name=substr($path,strlen($parent)+1);
+               $return=$this->remote->newFile($parent,$name,'dir');
+               if($return){
+                       $this->notifyObservers($path,OC_FILEACTION_CREATE);
+               }
+               return $return;
+       }
+       public function rmdir($path){
+               $this->connect();
+               $parent=dirname($path);
+               $name=substr($path,strlen($parent)+1);
+               $return=$this->remote->delete($parent,$name);
+               if($return){
+                       $this->notifyObservers($path,OC_FILEACTION_DELETE);
+               }
+               return $return;
+       }
+       public function opendir($path){
+               $this->connect();
+               $this->cacheDir($path);
+               $dirs=array_keys($this->statCache);
+               $id=uniqid();
+               global $FAKEDIRS;
+               $FAKEDIRS[$id]=$dirs;
+               if($return=opendir("fakedir://$id")){
+                       $this->notifyObservers($path,OC_FILEACTION_READ);
+               }
+               return $return;
+       }
+       public function is_dir($path){
+               $this->connect();
+               $parent=dirname($path);
+               $name=substr($path,strlen($parent)+1);
+               $this->cacheDir($path);
+               if($path=='' or $path=='/'){
+                       return true;
+               }
+               if(!isset($this->statCache[$name])){
+                       return false;
+               }
+               return ($this->statCache[$name]['type'=='dir']);
+       }
+       public function is_file($path){
+               $this->connect();
+               $parent=dirname($path);
+               $name=substr($path,strlen($parent)+1);
+               $this->cacheDir($parent);
+               if(!isset($this->statCache[$name])){
+                       return false;
+               }
+               return ($this->statCache[$name]['type'!='dir']);
+       }
+       public function stat($path){
+               $this->connect();
+               $parent=dirname($path);
+               $name=substr($path,strlen($parent)+1);
+               $this->cacheDir($parent);
+               if(!isset($this->statCache[$name])){
+                       return $false;
+               }
+               return $this->statCache[$name];
+       }
+       public function filetype($path){
+               $this->connect();
+               $parent=dirname($path);
+               $name=substr($path,strlen($parent)+1);
+               $this->cacheDir($parent);
+               if(!isset($this->statCache[$name])){
+                       return false;
+               }
+               return $this->statCache[$name]['type'];
+       }
+       public function filesize($path){
+               $this->connect();
+               $parent=dirname($path);
+               $name=substr($path,strlen($parent)+1);
+               $this->cacheDir($parent);
+               if(!isset($this->statCache[$name])){
+                       return $false;
+               }
+               return $this->statCache[$name]['size'];
+       }
+       public function is_readable($path){
+               $this->connect();
+               $parent=dirname($path);
+               $name=substr($path,strlen($parent)+1);
+               $this->cacheDir($parent);
+               if(!isset($this->statCache[$name])){
+                       return false;
+               }
+               return $this->statCache[$name]['readable'];
+       }
+       public function is_writeable($path){
+               $this->connect();
+               $parent=dirname($path);
+               $name=substr($path,strlen($parent)+1);
+               $this->cacheDir($parent);
+               if(!isset($this->statCache[$name])){
+                       return false;
+               }
+               return $this->statCache[$name]['writeable'];
+       }
+       public function file_exists($path){
+               $this->connect();
+               $parent=dirname($path);
+               $name=substr($path,strlen($parent)+1);
+               $this->cacheDir($parent);
+               return isset($this->statCache[$name]);
+       }
+       public function readfile($path){
+               $this->connect();
+               $parent=dirname($path);
+               $name=substr($path,strlen($parent)+1);
+               $file=$this->remote->getFile($parent,$name);
+               readfile($file);
+               unlink($file);
+       }
+       public function filectime($path){
+               $this->connect();
+               $parent=dirname($path);
+               $name=substr($path,strlen($parent)+1);
+               $this->cacheDir($parent);
+               if(!isset($this->statCache[$name])){
+                       return false;
+               }
+               return $this->statCache[$name]['ctime'];
+       }
+       public function filemtime($path){
+               $this->connect();
+               $parent=dirname($path);
+               $name=substr($path,strlen($parent)+1);
+               $this->cacheDir($parent);
+               if(!isset($this->statCache[$name])){
+                       return false;
+               }
+               return $this->statCache[$name]['mtime'];
+       }
+       public function fileatime($path){
+               $this->connect();
+               $parent=dirname($path);
+               $name=substr($path,strlen($parent)+1);
+               $this->cacheDir($parent);
+               if(!isset($this->statCache[$name])){
+                       return false;
+               }
+               return $this->statCache[$name]['atime'];
+       }
+       public function file_get_contents($path){
+               $this->connect();
+               $parent=dirname($path);
+               $name=substr($path,strlen($parent)+1);
+               $file=$this->remote->getFile($parent,$name);
+               file_get_contents($file);
+               unlink($file);
+       }
+       public function file_put_contents($path,$data){
+               $this->connect();
+               $parent=dirname($path);
+               $name=substr($path,strlen($parent)+1);
+               $file=$this->remote->getFile($parent,$name);
+               $file=tempnam(sys_get_temp_dir(),'oc_');
+               file_put_contents($file,$data);
+               if($return=$this->remote->sendTmpFile($file,$parent,$name)){
+                       $this->notifyObservers($path,OC_FILEACTION_WRITE);
+               }
+       }
+       public function unlink($path){
+               $this->connect();
+               $parent=dirname($path);
+               $name=substr($path,strlen($parent)+1);
+               if($return=$this->remote->delete($paren,$name)){
+                       $this->notifyObservers($path,OC_FILEACTION_DELETE);
+               }
+               return $return;
+       }
+       public function rename($path1,$path2){
+               $this->connect();
+               $parent1=dirname($path1);
+               $name1=substr($path1,strlen($parent1)+1);
+               $parent2=dirname($path2);
+               $name2=substr($path2,strlen($parent2)+1);
+               if($return=$this->remote->move($parent1,$name1,$parent2,$name2)){
+                       $this->notifyObservers($path1.'->'.$path2,OC_FILEACTION_RENAME);
+               }
+               return $return;
+       }
+       public function copy($path1,$path2){
+               $this->connect();
+               $parent1=dirname($path1);
+               $name1=substr($path1,strlen($parent1)+1);
+               $parent2=dirname($path2);
+               $name2=substr($path2,strlen($parent2)+1);
+               if($return=$this->copy->rename($parent1,$name1,$parent2,$name2)){
+                       $this->notifyObservers($path1.'->'.$path2,OC_FILEACTION_RENAME);
+               }
+               return $return;
+       }
+       public function fopen($path,$mode){
+               $this->connect();
+               $changed=false;
+               $parent=dirname($path);
+               $name=substr($path,strlen($parent)+1);
+               $file=$this->remote->getFile($parent,$name);
+               if($return=fopen($file,$mode)){
+                       switch($mode){
+                               case 'r':
+                                       $this->notifyObservers($path,OC_FILEACTION_READ);
+                                       break;
+                               case 'r+':
+                               case 'w+':
+                               case 'x+':
+                               case 'a+':
+                                       $this->notifyObservers($path,OC_FILEACTION_READ | OC_FILEACTION_WRITE);
+                                       $this->changed[]=array('dir'=>$parent,'file'=>$name,'tmp'=>$file);
+                                       break;
+                               case 'w':
+                               case 'x':
+                               case 'a':
+                                       $this->notifyObservers($path,OC_FILEACTION_WRITE);
+                                       $this->changed[]=array('dir'=>$parent,'file'=>$name,'tmp'=>$file);
+                                       break;
+                       }
+               }
+               return $return;
+       }
+       
+       public function getMimeType($path){
+               $this->connect();
+               $parent=dirname($path);
+               $name=substr($path,strlen($parent)+1);
+               if(substr($name,0,1)=='/'){
+                       $name=substr($name,1);
+               }
+               $this->cacheDir($parent);
+               if(!isset($this->statCache[$name])){
+                       return false;
+               }
+               return $this->statCache[$name]['mime'];
+       }
+       
+       public function toTmpFile($path){
+               $this->connect();
+               $parent=dirname($path);
+               $name=substr($path,strlen($parent)+1);
+               if(substr($name,0,1)=='/'){
+                       $name=substr($name,1);
+               }
+               $filename=$this->remote->getFile($parent,$name);
+               if($filename){
+                       $this->notifyObservers($path,OC_FILEACTION_READ);
+                       return $filename;
+               }else{
+                       return false;
+               }
+       }
+       
+       public function fromTmpFile($tmpFile,$path){
+               $this->connect();
+               $parent=dirname($path);
+               $name=substr($path,strlen($parent)+1);
+               if($this->remote->sendTmpFile($tmpFile,$parent,$name)){
+                       $this->notifyObservers($path,OC_FILEACTION_CREATE);
+                       return true;
+               }else{
+                       return false;
+               }
+       }
+       
+       public function delTree($dir) {
+               $this->connect();
+               $parent=dirname($dir);
+               $name=substr($dir,strlen($parent)+1);
+               $return=$this->remote->delete($parent,$name);
+               if($return=rmdir($dir)){
+                       $this->notifyObservers($dir,OC_FILEACTION_DELETE);
+               }
+               return $return;
+       }
+       
+       public function find($path){
+               return $this->getTree($path);
+       }
+       
+       public function getTree($dir) {
+               $this->connect();
+               if($return=$this->remote->getTree($dir)){
+                       $this->notifyObservers($dir,OC_FILEACTION_READ);
+               }
+               return $return;
+       }
+       
+       public function __destruct(){
+               foreach($this->changed as $changed){
+                       $this->remote->sendTmpFile($changed['tmp'],$changed['dir'],$changed['file']);
+               }
+       }
+}
index b82fe2afebf2a9df7a294ff36d2f5bae063abd3f..d44416cf9cbec5118ca31a22dcfadbe22910b46b 100644 (file)
@@ -588,4 +588,3 @@ class OC_FILESYSTEM{
                
        }
 }
-?>
index ffb25877433fe9c2580a0211cac5cfc7bd47336f..b976705a7cf45865d0c5467fbfe824b871cc71e0 100755 (executable)
@@ -318,5 +318,3 @@ class OC_HELPER {
                return false;
        }
 }
-
-?>
index 764c094c919474798b0857926fbe645883b870b8..d7c280ea65ed238c315add313d889b11b7e793fb 100644 (file)
@@ -149,7 +149,3 @@ class OC_LOG {
                return $filteredLogs;
        }
 }
-
-
-
-?>
index 6d8b3b9abce59548c1ea910dde5ba0989aea138a..2467925719995b5ece271f60de2a0807470dbfd8 100644 (file)
@@ -78,4 +78,3 @@ return array(
        'webm'=>'video/webm',
        'wmv'=>'video/x-ms-asf'
 );
-?>
\ No newline at end of file
index b1be2cb11cf5841d3e7cb3965f303fed46c99bff..c91871377a0a1dd5b10e71a538a9d33ba6efeed6 100644 (file)
@@ -556,5 +556,3 @@ class OC_OCS {
                return OC_PREFERENCES::deleteKey($user,$app,$key);
        }
 }
-
-?>
index cfd529b2ec486fb7bdc4ca26a4ccc1e360bd5de7..1b6280e25872ef0ab12e47846bda34ccbe3c34e2 100644 (file)
@@ -160,4 +160,3 @@ class OC_OCSCLIENT{
 
 
 }
-?>
index 0f4636f683252d3eb608cad08d609f20a9dbb9f1..89598f478d1af03d9274ef716f5a462401442425 100644 (file)
@@ -217,4 +217,3 @@ class OC_PREFERENCES{
                return true;
        }
 }
-?>
index 6358bea46fc42165182c61d5f8fb4b37d459e9c9..1acd48ea5afe69c8acd59844dff7d5922a32d953 100644 (file)
@@ -203,4 +203,4 @@ class OC_REMOTE_CLOUD{
                return $this->apiCall('pull',array('dir'=>$targetDir,'file'=>$targetFile,'token'=>$token,'source'=>$url),true);
        }
 }
\ No newline at end of file
diff --git a/lib/remotestorage.php b/lib/remotestorage.php
deleted file mode 100644 (file)
index ed90cf1..0000000
+++ /dev/null
@@ -1,353 +0,0 @@
-<?php
-
-/**
-* ownCloud
-*
-* @author Frank Karlitschek 
-* @copyright 2010 Frank Karlitschek karlitschek@kde.org 
-* 
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
-* License as published by the Free Software Foundation; either 
-* version 3 of the License, or any later version.
-* 
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
-*  
-* You should have received a copy of the GNU Affero General Public 
-* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
-* 
-*/
-
-
-class OC_FILESTORAGE_REMOTE extends OC_FILESTORAGE{
-       private $url;
-       private $username;
-       private $password;
-       private $remote=false;
-       private $statCache;
-       private $statCacheDir=false;
-       private $changed=array();
-       
-       private function cacheDir($dir){
-               if($this->statCacheDir!=$dir or $this->statCacheDir===false){
-                       $this->statCache=$this->remote->getFiles($dir);
-                       $keys=array_keys($this->statCache);
-                       $this->statCacheDir=$dir;
-               }
-       }
-       
-       public function __construct($arguments){
-               $this->url=$arguments['url'];
-               $this->username=$arguments['username'];
-               $this->password=$arguments['password'];
-       }
-       private function connect(){
-               if($this->remote===false){
-                       $this->remote=OC_CONNECT::connect($this->url,$this->username,$this->password);
-               }
-       }
-       public function mkdir($path){
-               $this->connect();
-               $parent=dirname($path);
-               $name=substr($path,strlen($parent)+1);
-               $return=$this->remote->newFile($parent,$name,'dir');
-               if($return){
-                       $this->notifyObservers($path,OC_FILEACTION_CREATE);
-               }
-               return $return;
-       }
-       public function rmdir($path){
-               $this->connect();
-               $parent=dirname($path);
-               $name=substr($path,strlen($parent)+1);
-               $return=$this->remote->delete($parent,$name);
-               if($return){
-                       $this->notifyObservers($path,OC_FILEACTION_DELETE);
-               }
-               return $return;
-       }
-       public function opendir($path){
-               $this->connect();
-               $this->cacheDir($path);
-               $dirs=array_keys($this->statCache);
-               $id=uniqid();
-               global $FAKEDIRS;
-               $FAKEDIRS[$id]=$dirs;
-               if($return=opendir("fakedir://$id")){
-                       $this->notifyObservers($path,OC_FILEACTION_READ);
-               }
-               return $return;
-       }
-       public function is_dir($path){
-               $this->connect();
-               $parent=dirname($path);
-               $name=substr($path,strlen($parent)+1);
-               $this->cacheDir($path);
-               if($path=='' or $path=='/'){
-                       return true;
-               }
-               if(!isset($this->statCache[$name])){
-                       return false;
-               }
-               return ($this->statCache[$name]['type'=='dir']);
-       }
-       public function is_file($path){
-               $this->connect();
-               $parent=dirname($path);
-               $name=substr($path,strlen($parent)+1);
-               $this->cacheDir($parent);
-               if(!isset($this->statCache[$name])){
-                       return false;
-               }
-               return ($this->statCache[$name]['type'!='dir']);
-       }
-       public function stat($path){
-               $this->connect();
-               $parent=dirname($path);
-               $name=substr($path,strlen($parent)+1);
-               $this->cacheDir($parent);
-               if(!isset($this->statCache[$name])){
-                       return $false;
-               }
-               return $this->statCache[$name];
-       }
-       public function filetype($path){
-               $this->connect();
-               $parent=dirname($path);
-               $name=substr($path,strlen($parent)+1);
-               $this->cacheDir($parent);
-               if(!isset($this->statCache[$name])){
-                       return false;
-               }
-               return $this->statCache[$name]['type'];
-       }
-       public function filesize($path){
-               $this->connect();
-               $parent=dirname($path);
-               $name=substr($path,strlen($parent)+1);
-               $this->cacheDir($parent);
-               if(!isset($this->statCache[$name])){
-                       return $false;
-               }
-               return $this->statCache[$name]['size'];
-       }
-       public function is_readable($path){
-               $this->connect();
-               $parent=dirname($path);
-               $name=substr($path,strlen($parent)+1);
-               $this->cacheDir($parent);
-               if(!isset($this->statCache[$name])){
-                       return false;
-               }
-               return $this->statCache[$name]['readable'];
-       }
-       public function is_writeable($path){
-               $this->connect();
-               $parent=dirname($path);
-               $name=substr($path,strlen($parent)+1);
-               $this->cacheDir($parent);
-               if(!isset($this->statCache[$name])){
-                       return false;
-               }
-               return $this->statCache[$name]['writeable'];
-       }
-       public function file_exists($path){
-               $this->connect();
-               $parent=dirname($path);
-               $name=substr($path,strlen($parent)+1);
-               $this->cacheDir($parent);
-               return isset($this->statCache[$name]);
-       }
-       public function readfile($path){
-               $this->connect();
-               $parent=dirname($path);
-               $name=substr($path,strlen($parent)+1);
-               $file=$this->remote->getFile($parent,$name);
-               readfile($file);
-               unlink($file);
-       }
-       public function filectime($path){
-               $this->connect();
-               $parent=dirname($path);
-               $name=substr($path,strlen($parent)+1);
-               $this->cacheDir($parent);
-               if(!isset($this->statCache[$name])){
-                       return false;
-               }
-               return $this->statCache[$name]['ctime'];
-       }
-       public function filemtime($path){
-               $this->connect();
-               $parent=dirname($path);
-               $name=substr($path,strlen($parent)+1);
-               $this->cacheDir($parent);
-               if(!isset($this->statCache[$name])){
-                       return false;
-               }
-               return $this->statCache[$name]['mtime'];
-       }
-       public function fileatime($path){
-               $this->connect();
-               $parent=dirname($path);
-               $name=substr($path,strlen($parent)+1);
-               $this->cacheDir($parent);
-               if(!isset($this->statCache[$name])){
-                       return false;
-               }
-               return $this->statCache[$name]['atime'];
-       }
-       public function file_get_contents($path){
-               $this->connect();
-               $parent=dirname($path);
-               $name=substr($path,strlen($parent)+1);
-               $file=$this->remote->getFile($parent,$name);
-               file_get_contents($file);
-               unlink($file);
-       }
-       public function file_put_contents($path,$data){
-               $this->connect();
-               $parent=dirname($path);
-               $name=substr($path,strlen($parent)+1);
-               $file=$this->remote->getFile($parent,$name);
-               $file=tempnam(sys_get_temp_dir(),'oc_');
-               file_put_contents($file,$data);
-               if($return=$this->remote->sendTmpFile($file,$parent,$name)){
-                       $this->notifyObservers($path,OC_FILEACTION_WRITE);
-               }
-       }
-       public function unlink($path){
-               $this->connect();
-               $parent=dirname($path);
-               $name=substr($path,strlen($parent)+1);
-               if($return=$this->remote->delete($paren,$name)){
-                       $this->notifyObservers($path,OC_FILEACTION_DELETE);
-               }
-               return $return;
-       }
-       public function rename($path1,$path2){
-               $this->connect();
-               $parent1=dirname($path1);
-               $name1=substr($path1,strlen($parent1)+1);
-               $parent2=dirname($path2);
-               $name2=substr($path2,strlen($parent2)+1);
-               if($return=$this->remote->move($parent1,$name1,$parent2,$name2)){
-                       $this->notifyObservers($path1.'->'.$path2,OC_FILEACTION_RENAME);
-               }
-               return $return;
-       }
-       public function copy($path1,$path2){
-               $this->connect();
-               $parent1=dirname($path1);
-               $name1=substr($path1,strlen($parent1)+1);
-               $parent2=dirname($path2);
-               $name2=substr($path2,strlen($parent2)+1);
-               if($return=$this->copy->rename($parent1,$name1,$parent2,$name2)){
-                       $this->notifyObservers($path1.'->'.$path2,OC_FILEACTION_RENAME);
-               }
-               return $return;
-       }
-       public function fopen($path,$mode){
-               $this->connect();
-               $changed=false;
-               $parent=dirname($path);
-               $name=substr($path,strlen($parent)+1);
-               $file=$this->remote->getFile($parent,$name);
-               if($return=fopen($file,$mode)){
-                       switch($mode){
-                               case 'r':
-                                       $this->notifyObservers($path,OC_FILEACTION_READ);
-                                       break;
-                               case 'r+':
-                               case 'w+':
-                               case 'x+':
-                               case 'a+':
-                                       $this->notifyObservers($path,OC_FILEACTION_READ | OC_FILEACTION_WRITE);
-                                       $this->changed[]=array('dir'=>$parent,'file'=>$name,'tmp'=>$file);
-                                       break;
-                               case 'w':
-                               case 'x':
-                               case 'a':
-                                       $this->notifyObservers($path,OC_FILEACTION_WRITE);
-                                       $this->changed[]=array('dir'=>$parent,'file'=>$name,'tmp'=>$file);
-                                       break;
-                       }
-               }
-               return $return;
-       }
-       
-       public function getMimeType($path){
-               $this->connect();
-               $parent=dirname($path);
-               $name=substr($path,strlen($parent)+1);
-               if(substr($name,0,1)=='/'){
-                       $name=substr($name,1);
-               }
-               $this->cacheDir($parent);
-               if(!isset($this->statCache[$name])){
-                       return false;
-               }
-               return $this->statCache[$name]['mime'];
-       }
-       
-       public function toTmpFile($path){
-               $this->connect();
-               $parent=dirname($path);
-               $name=substr($path,strlen($parent)+1);
-               if(substr($name,0,1)=='/'){
-                       $name=substr($name,1);
-               }
-               $filename=$this->remote->getFile($parent,$name);
-               if($filename){
-                       $this->notifyObservers($path,OC_FILEACTION_READ);
-                       return $filename;
-               }else{
-                       return false;
-               }
-       }
-       
-       public function fromTmpFile($tmpFile,$path){
-               $this->connect();
-               $parent=dirname($path);
-               $name=substr($path,strlen($parent)+1);
-               if($this->remote->sendTmpFile($tmpFile,$parent,$name)){
-                       $this->notifyObservers($path,OC_FILEACTION_CREATE);
-                       return true;
-               }else{
-                       return false;
-               }
-       }
-       
-       public function delTree($dir) {
-               $this->connect();
-               $parent=dirname($dir);
-               $name=substr($dir,strlen($parent)+1);
-               $return=$this->remote->delete($parent,$name);
-               if($return=rmdir($dir)){
-                       $this->notifyObservers($dir,OC_FILEACTION_DELETE);
-               }
-               return $return;
-       }
-       
-       public function find($path){
-               return $this->getTree($path);
-       }
-       
-       public function getTree($dir) {
-               $this->connect();
-               if($return=$this->remote->getTree($dir)){
-                       $this->notifyObservers($dir,OC_FILEACTION_READ);
-               }
-               return $return;
-       }
-       
-       public function __destruct(){
-               foreach($this->changed as $changed){
-                       $this->remote->sendTmpFile($changed['tmp'],$changed['dir'],$changed['file']);
-               }
-       }
-}
-
-?>
index ef82e225f3d8693e04ca0bd671d44cec7bd4e0f7..cb5e5eee78b5fa06469fb714658f32310d161c9c 100644 (file)
@@ -29,7 +29,7 @@ class OC_SEARCH{
        
        /**
         * register a new search provider to be used
-        * @param OC_SearchProvider $provider
+        * @param OC_Search_Provider $provider
         */
        public static function registerProvider($provider){
                self::$providers[]=$provider;
@@ -38,7 +38,7 @@ class OC_SEARCH{
        /**
         * search all provider for $query
         * @param string query
-        * @return array An array of OC_SearchResult's
+        * @return array An array of OC_Search_Result's
         */
        public static function search($query){
                $results=array();
@@ -48,74 +48,3 @@ class OC_SEARCH{
                return $results;
        }
 }
-
-/**
- * provides search functionalty
- */
-abstract class OC_SearchProvider{
-       public function __construct(){
-               OC_SEARCH::registerProvider($this);
-       }
-       
-       /**
-        * search for $query
-        * @param string $query
-        * @return array An array of OC_SearchResult's
-        */
-       abstract function search($query);
-}
-
-/**
- * a result of a search
- */
-class OC_SearchResult{
-       private $name;
-       private $text;
-       private $link;
-       private $type;
-       
-       /**
-        * create a new search result
-        * @param string $name short name for the result
-        * @param string $text some more information about the result
-        * @param string $link link for the result
-        * @param string $type the type of result as human readable string ('File', 'Music', etc)
-        */
-       public function __construct($name,$text,$link,$type){
-               $this->name=$name;
-               $this->text=$text;
-               $this->link=$link;
-               $this->type=$type;
-       }
-
-       public function __get($name){
-               switch($name){
-                       case 'name':
-                               return $this->name;
-                       case 'text':
-                               return $this->text;
-                       case 'link':
-                               return $this->link;
-                       case 'type':
-                               return $this->type;
-               }
-       }
-}
-
-class OC_FileSearchProvider extends OC_SearchProvider{
-       function search($query){
-               $files=OC_FILESYSTEM::search($query);
-               $results=array();
-               foreach($files as $file){
-                       if(OC_FILESYSTEM::is_dir($file)){
-                               $results[]=new OC_SearchResult(basename($file),$file,OC_HELPER::linkTo( 'files', 'index.php?dir='.$file ),'Files');
-                       }else{
-                               $results[]=new OC_SearchResult(basename($file),$file,OC_HELPER::linkTo( 'files', 'download.php?file='.$file ),'Files');
-                       }
-               }
-               return $results;
-       }
-}
-
-new OC_FileSearchProvider();
-?>
\ No newline at end of file
diff --git a/lib/search/provider.php b/lib/search/provider.php
new file mode 100644 (file)
index 0000000..f0e0ba8
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+/**
+ * provides search functionalty
+ */
+abstract class OC_Search_Provider{
+       public function __construct(){
+               OC_SEARCH::registerProvider($this);
+       }
+
+       /**
+        * search for $query
+        * @param string $query
+        * @return array An array of OC_Search_Result's
+        */
+       abstract function search($query);
+}
diff --git a/lib/search/provider/file.php b/lib/search/provider/file.php
new file mode 100644 (file)
index 0000000..892c431
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+
+class OC_Search_Provider_File extends OC_Search_Provider{
+       function search($query){
+               $files=OC_FILESYSTEM::search($query);
+               $results=array();
+               foreach($files as $file){
+                       if(OC_FILESYSTEM::is_dir($file)){
+                               $results[]=new OC_Search_Result(basename($file),$file,OC_HELPER::linkTo( 'files', 'index.php?dir='.$file ),'Files');
+                       }else{
+                               $results[]=new OC_Search_Result(basename($file),$file,OC_HELPER::linkTo( 'files', 'download.php?file='.$file ),'Files');
+                       }
+               }
+               return $results;
+       }
+}
diff --git a/lib/search/result.php b/lib/search/result.php
new file mode 100644 (file)
index 0000000..80a6b49
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+/**
+ * a result of a search
+ */
+class OC_Search_Result{
+       private $name;
+       private $text;
+       private $link;
+       private $type;
+
+       /**
+        * create a new search result
+        * @param string $name short name for the result
+        * @param string $text some more information about the result
+        * @param string $link link for the result
+        * @param string $type the type of result as human readable string ('File', 'Music', etc)
+        */
+       public function __construct($name,$text,$link,$type){
+               $this->name=$name;
+               $this->text=$text;
+               $this->link=$link;
+               $this->type=$type;
+       }
+
+       public function __get($name){
+               switch($name){
+                       case 'name':
+                               return $this->name;
+                       case 'text':
+                               return $this->text;
+                       case 'link':
+                               return $this->link;
+                       case 'type':
+                               return $this->type;
+               }
+       }
+}
index f9bc6fd1bddde9d3b6dc4a5f188e4a8f5cc39acd..bf7166016d4e61f4c7be969cac5998433cc9ae8b 100644 (file)
@@ -1,7 +1,5 @@
 <?php
 
-include_once( 'installer.php' );
-
 $hasSQLite = (is_callable('sqlite_open') or class_exists('SQLite3'));
 $hasMySQL = is_callable('mysql_connect');
 $datadir = OC_CONFIG::getValue('datadir', $SERVERROOT.'/data');
index 99099d49d0f2a843df437c187982c6fb196d5360..edfdf3bda80477f37a07fd13c69ca6e43b4d9ae0 100644 (file)
@@ -365,5 +365,3 @@ class OC_TEMPLATE{
                return $content->printPage();
        }
 }
-
-?>