diff --git a/apps/media/lib_media.php b/apps/media/lib_media.php
index 9c3d0622360..6fde2ab7487 100644
--- a/apps/media/lib_media.php
+++ b/apps/media/lib_media.php
@@ -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;
}
diff --git a/lib/app.php b/lib/app.php
index b6c2512e79a..fad0714c3f4 100644
--- a/lib/app.php
+++ b/lib/app.php
@@ -408,4 +408,3 @@ class OC_APP{
}
}
}
-?>
\ No newline at end of file
diff --git a/lib/appconfig.php b/lib/appconfig.php
index 4fef7542f40..b4735a309bc 100644
--- a/lib/appconfig.php
+++ b/lib/appconfig.php
@@ -158,4 +158,3 @@ class OC_APPCONFIG{
return true;
}
}
-?>
diff --git a/lib/base.php b/lib/base.php
index 4e1b9bd0064..236b5d926a4 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -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
';
+ if($remote->isLoggedIn()){
+ echo 'logged in, session working
';
+ echo 'trying to get remote files...';
+ $files=$remote->getFiles('');
+ if($files){
+ echo count($files).' files found:
';
+ foreach($files as $file){
+ echo "{$file['type']} {$file['name']}: {$file['size']} bytes
";
+ }
+ 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
Error: $newSize bytes received, $size expected.";
+ echo '
Recieved file:
';
+ readfile($file);
+ unlink($file);
+ return;
+ }
+ OC_FILESYSTEM::fromTmpFile($file,'/remoteFile');
+ echo 'done
';
+ echo 'sending file "burning_avatar.png"...';
+ $res=$remote->sendFile('','burning_avatar.png','','burning_avatar.png');
+ if($res){
+ echo 'done
';
+ }else{
+ echo 'fail
';
+ }
+ }else{
+ echo 'fail
';
+ }
+ }else{
+ echo 'fail
';
+ }
+ }else{
+ echo 'no longer logged in, session fail
';
+ }
+ }else{
+ echo 'fail
';
+ }
+ $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();
diff --git a/lib/config.php b/lib/config.php
index cd18ddd499c..ea3647858ed 100644
--- a/lib/config.php
+++ b/lib/config.php
@@ -182,4 +182,3 @@ class OC_CONFIG{
return true;
}
}
-?>
diff --git a/lib/connect.php b/lib/connect.php
index 57017cf9bb4..c02b999ffc2 100644
--- a/lib/connect.php
+++ b/lib/connect.php
@@ -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
';
- if($remote->isLoggedIn()){
- echo 'logged in, session working
';
- echo 'trying to get remote files...';
- $files=$remote->getFiles('');
- if($files){
- echo count($files).' files found:
';
- foreach($files as $file){
- echo "{$file['type']} {$file['name']}: {$file['size']} bytes
";
- }
- 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
Error: $newSize bytes received, $size expected.";
- echo '
Recieved file:
';
- readfile($file);
- unlink($file);
- return;
- }
- OC_FILESYSTEM::fromTmpFile($file,'/remoteFile');
- echo 'done
';
- echo 'sending file "burning_avatar.png"...';
- $res=$remote->sendFile('','burning_avatar.png','','burning_avatar.png');
- if($res){
- echo 'done
';
- }else{
- echo 'fail
';
- }
- }else{
- echo 'fail
';
- }
- }else{
- echo 'fail
';
- }
- }else{
- echo 'no longer logged in, session fail
';
- }
- }else{
- echo 'fail
';
- }
- $remote->disconnect();
- die();
-}
-
-
-?>
diff --git a/lib/connector/sabre/locks.php b/lib/connector/sabre/locks.php
index 88bab509898..9f0b983a5cc 100644
--- a/lib/connector/sabre/locks.php
+++ b/lib/connector/sabre/locks.php
@@ -149,4 +149,3 @@ class OC_Connector_Sabre_Locks extends Sabre_DAV_Locks_Backend_Abstract {
}
}
-
diff --git a/lib/connector/sabre/node.php b/lib/connector/sabre/node.php
index 03d5e90012e..0edd9b78161 100644
--- a/lib/connector/sabre/node.php
+++ b/lib/connector/sabre/node.php
@@ -155,4 +155,3 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
return $props;
}
}
-
diff --git a/lib/db.php b/lib/db.php
index 8d7c76756c1..f5f877176e9 100644
--- a/lib/db.php
+++ b/lib/db.php
@@ -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
index 00000000000..fa3e64da62c
--- /dev/null
+++ b/lib/fakedirstream.php
@@ -0,0 +1,45 @@
+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/files.php b/lib/files.php
index d24eb282c45..03e159f9bee 100644
--- a/lib/files.php
+++ b/lib/files.php
@@ -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/remotestorage.php b/lib/filestorage/remote.php
similarity index 99%
rename from lib/remotestorage.php
rename to lib/filestorage/remote.php
index ed90cf1fdaf..74234f4d8db 100644
--- a/lib/remotestorage.php
+++ b/lib/filestorage/remote.php
@@ -21,7 +21,6 @@
*
*/
-
class OC_FILESTORAGE_REMOTE extends OC_FILESTORAGE{
private $url;
private $username;
@@ -349,5 +348,3 @@ class OC_FILESTORAGE_REMOTE extends OC_FILESTORAGE{
}
}
}
-
-?>
diff --git a/lib/filesystem.php b/lib/filesystem.php
index b82fe2afebf..d44416cf9cb 100644
--- a/lib/filesystem.php
+++ b/lib/filesystem.php
@@ -588,4 +588,3 @@ class OC_FILESYSTEM{
}
}
-?>
diff --git a/lib/helper.php b/lib/helper.php
index ffb25877433..b976705a7cf 100755
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -318,5 +318,3 @@ class OC_HELPER {
return false;
}
}
-
-?>
diff --git a/lib/log.php b/lib/log.php
index 764c094c919..d7c280ea65e 100644
--- a/lib/log.php
+++ b/lib/log.php
@@ -149,7 +149,3 @@ class OC_LOG {
return $filteredLogs;
}
}
-
-
-
-?>
diff --git a/lib/mimetypes.list.php b/lib/mimetypes.list.php
index 6d8b3b9abce..24679257199 100644
--- a/lib/mimetypes.list.php
+++ b/lib/mimetypes.list.php
@@ -78,4 +78,3 @@ return array(
'webm'=>'video/webm',
'wmv'=>'video/x-ms-asf'
);
-?>
\ No newline at end of file
diff --git a/lib/ocs.php b/lib/ocs.php
index b1be2cb11cf..c91871377a0 100644
--- a/lib/ocs.php
+++ b/lib/ocs.php
@@ -556,5 +556,3 @@ class OC_OCS {
return OC_PREFERENCES::deleteKey($user,$app,$key);
}
}
-
-?>
diff --git a/lib/ocsclient.php b/lib/ocsclient.php
index cfd529b2ec4..1b6280e2587 100644
--- a/lib/ocsclient.php
+++ b/lib/ocsclient.php
@@ -160,4 +160,3 @@ class OC_OCSCLIENT{
}
-?>
diff --git a/lib/preferences.php b/lib/preferences.php
index 0f4636f6832..89598f478d1 100644
--- a/lib/preferences.php
+++ b/lib/preferences.php
@@ -217,4 +217,3 @@ class OC_PREFERENCES{
return true;
}
}
-?>
diff --git a/lib/remote/cloud.php b/lib/remote/cloud.php
index 6358bea46fc..1acd48ea5af 100644
--- a/lib/remote/cloud.php
+++ b/lib/remote/cloud.php
@@ -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/search.php b/lib/search.php
index ef82e225f3d..cb5e5eee78b 100644
--- a/lib/search.php
+++ b/lib/search.php
@@ -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
index 00000000000..f0e0ba85249
--- /dev/null
+++ b/lib/search/provider.php
@@ -0,0 +1,16 @@
+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;
+ }
+ }
+}
diff --git a/lib/setup.php b/lib/setup.php
index f9bc6fd1bdd..bf7166016d4 100644
--- a/lib/setup.php
+++ b/lib/setup.php
@@ -1,7 +1,5 @@
printPage();
}
}
-
-?>