aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--admin/apps.php33
-rw-r--r--admin/templates/apps.php35
-rw-r--r--lib/base.php12
-rw-r--r--lib/ocsclient.php42
4 files changed, 82 insertions, 40 deletions
diff --git a/admin/apps.php b/admin/apps.php
index dc7b51bb820..b433fe0875b 100644
--- a/admin/apps.php
+++ b/admin/apps.php
@@ -28,23 +28,42 @@ if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin'
exit();
}
-
// Load the files we need
//OC_UTIL::addStyle( "", "files" );
//OC_UTIL::addScript( "", "files" );
+if(isset($_GET['id'])) $id=$_GET['id']; else $id=0;
+if(isset($_GET['cat'])) $cat=$_GET['cat']; else $cat=0;
+
$categories=OC_OCSCLIENT::getCategories();
-$apps=OC_OCSCLIENT::getApplications($categories);
+if($id==0) {
+
+ if($cat==0){
+ $apps=OC_OCSCLIENT::getApplications($categories);
+ }else{
+ $apps=OC_OCSCLIENT::getApplications($cat);
+ }
+
+ // return template
+ $tmpl = new OC_TEMPLATE( "admin", "apps", "admin" );
-// return template
-$tmpl = new OC_TEMPLATE( "admin", "apps", "admin" );
+ $tmpl->assign( "categories", $categories );
+ $tmpl->assign( "apps", $apps );
+ $tmpl->printPage();
+ unset($tmpl);
-$tmpl->assign( "categories", $categories );
-$tmpl->assign( "apps", $apps );
-$tmpl->printPage();
+}else{
+ $app=OC_OCSCLIENT::getApplication($id);
+
+ $tmpl = new OC_TEMPLATE( "admin", "app", "admin" );
+ $tmpl->assign( "app", $app );
+ $tmpl->printPage();
+ unset($tmpl);
+
+}
?>
diff --git a/admin/templates/apps.php b/admin/templates/apps.php
index f1fdafc27cc..2f584775815 100644
--- a/admin/templates/apps.php
+++ b/admin/templates/apps.php
@@ -1,50 +1,29 @@
<?php
/*
- * Template for files
+ * Template for Apps
*/
?>
-<h1>Files</h1>
+<h1>Apps Repository</h1>
-<div class="controls">
- <p class="actions">
- <a href="" title="" class="upload">Upload</a><a href="" title="" class="new-dir">New folder</a><a href="" title="" class="download">Download</a><a href="" title="" class="share">Share</a><a href="" title="" class="delete">Delete</a>
- </p>
-</div>
-
-<p class="nav">
- <a href="<?php echo link_to("files", "index.php?dir=/"); ?>"><img src="<?php echo image_path("", "actions/go-home.png"); ?>" alt="Root" /></a>
- <?php foreach($_["breadcrumb"] as $crumb): ?>
- <a href="<?php echo link_to("files", "index.php?dir=".$crumb["dir"]); ?>"><?php echo $crumb["name"]; ?></a>
- <?php endforeach; ?>
-</p>
<table cellspacing="0">
<thead>
<tr>
- <th><input type="checkbox" id="select_all" /></th>
+ <th></th>
<th>Name</th>
- <th>Size</th>
<th>Modified</th>
<th></th>
</tr>
</thead>
<tbody>
- <?php foreach($_["files"] as $file): ?>
+ <?php foreach($_["apps"] as $app): ?>
<tr>
- <td class="selection"><input type="checkbox" /></td>
- <td class="filename"><a style="background-image:url(<?php if($file["type"] == "dir") echo mimetype_icon("dir"); else echo mimetype_icon($file["mime"]); ?>)" href="<?php if($file["type"] == "dir") echo link_to("files", "index.php?dir=".$file["directory"]."/".$file["name"]); else echo link_to("files", "download.php?file=".$file["directory"]."/".$file["name"]); ?>" title=""><?php echo $file["name"]; ?></a></td>
- <td class="filesize"><?php echo human_file_size($file["size"]); ?></td>
- <td class="date"><?php if($file["type"] != "dir") echo $file["date"]; ?></td>
+ <td width="1"><?php if($app["preview"] <> "") { echo('<a href=""><img border="0" src="'.$app["preview"].'" /></a>'); } ?> </a></td>
+ <td class="filename"><a href="" title=""><?php echo $app["name"]; ?></a></td>
+ <td class="date"><?php echo OC_UTIL::formatdate($app["changed"]); ?></td>
<td class="fileaction"><a href="" title=""><img src="images/drop-arrow.png" alt="+" /></a></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
-<div id="file_menu">
- <ul>
- <li><a href="" title="">Download</a></li>
- <li><a href="" title="">Share</a></li>
- <li><a href="" title="">Delete</a></li>
- </ul>
-</div>
diff --git a/lib/base.php b/lib/base.php
index 05ff4040b9d..9fc9d57f7ae 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -221,6 +221,18 @@ class OC_UTIL {
self::$styles[] = "$application/css/$file";
}
+ /**
+ * formats a timestamp in the "right" way
+ *
+ * @param timestamp $timestamp
+ */
+ public static function formatDate( $timestamp ){
+ $timeformat='F j, Y, H:i';
+ return date($timeformat,$timestamp);
+ }
+
+
+
/**
* check if the current server configuration is suitable for ownCloud
* @return array arrays with error messages and hints
diff --git a/lib/ocsclient.php b/lib/ocsclient.php
index 0546ef39897..d9ce11d537e 100644
--- a/lib/ocsclient.php
+++ b/lib/ocsclient.php
@@ -35,8 +35,20 @@ class OC_OCSCLIENT{
* This function returns a list of all the application categories on the OCS server
*/
public static function getCategories(){
-
- return true;
+ $url='http://api.opendesktop.org/v1/content/categories';
+
+ $cats=array();
+ $xml=file_get_contents($url);
+ $data=simplexml_load_string($xml);
+
+ $tmp=$data->data->category;
+ for($i = 0; $i < count($tmp); $i++) {
+ $cat=array();
+ $cat['id']=$tmp[$i]->id;
+ $cat['name']=$tmp[$i]->name;
+ $cats[]=$cat;
+ }
+ return $cats;
}
/**
@@ -45,9 +57,29 @@ class OC_OCSCLIENT{
*
* This function returns a list of all the applications on the OCS server
*/
- public static function getApplications(){
-
- return true;
+ public static function getApplications($categories){
+ $categoriesstring=implode('x',$categories);
+ $url='http://api.opendesktop.org/v1/content/data?categories='.$ocscategories['ids'].'&sortmode=new&page=0&pagesize=10';
+
+ $apps=array();
+ $xml=file_get_contents($url);
+ $data=simplexml_load_string($xml);
+
+ $tmp=$data->data->content;
+ for($i = 0; $i < count($tmp); $i++) {
+ $app=array();
+ $app['id']=$tmp[$i]->id;
+ $app['name']=$tmp[$i]->name;
+ $app['type']=$tmp[$i]->type;
+ $app['personid']=$tmp[$i]->personid;
+ $app['detailpage']=$tmp[$i]->detailpage;
+ $app['preview']=$tmp[$i]->smallpreviewpic1;
+ $app['changed']=strtotime($tmp[$i]->changed);
+ $app['description']=$tmp[$i]->description;
+
+ $apps[]=$app;
+ }
+ return $apps;
}
}