work in new app management
This commit is contained in:
parent
9059b55979
commit
cdf91b6b3e
|
@ -31,76 +31,21 @@ if( !OC_User::isLoggedIn() || !OC_Group::inGroup( OC_User::getUser(), 'admin' ))
|
||||||
OC_Util::addStyle( "admin", "apps" );
|
OC_Util::addStyle( "admin", "apps" );
|
||||||
OC_Util::addScript( "admin", "apps" );
|
OC_Util::addScript( "admin", "apps" );
|
||||||
|
|
||||||
|
$registeredApps=OC_App::getAllApps();
|
||||||
if(isset($_GET['id'])) $id=$_GET['id']; else $id=0;
|
$apps=array();
|
||||||
if(isset($_GET['cat'])) $cat=$_GET['cat']; else $cat=0;
|
foreach($registeredApps as $app){
|
||||||
if(isset($_GET['installed'])) $installed=true; else $installed=false;
|
$info=OC_App::getAppInfo($app);
|
||||||
|
$active=(OC_Appconfig::getValue($app,'enabled','no')=='yes')?true:false;
|
||||||
if($installed){
|
$info['active']=$active;
|
||||||
global $SERVERROOT;
|
$apps[]=$info;
|
||||||
OC_Installer::installShippedApps(false);
|
|
||||||
$apps = OC_Appconfig::getApps();
|
|
||||||
$records = array();
|
|
||||||
|
|
||||||
OC_App::setActiveNavigationEntry( "core_apps" );
|
|
||||||
foreach($apps as $app){
|
|
||||||
$info=OC_App::getAppInfo("$SERVERROOT/apps/$app/appinfo/info.xml");
|
|
||||||
$record = array( 'id' => $app,
|
|
||||||
'name' => $info['name'],
|
|
||||||
'version' => $info['version'],
|
|
||||||
'author' => $info['author'],
|
|
||||||
'enabled' => OC_App::isEnabled( $app ));
|
|
||||||
$records[]=$record;
|
|
||||||
}
|
|
||||||
|
|
||||||
$tmpl = new OC_Template( "admin", "appsinst", "user" );
|
|
||||||
$tmpl->assign( "apps", $records );
|
|
||||||
$tmpl->printPage();
|
|
||||||
unset($tmpl);
|
|
||||||
exit();
|
|
||||||
}else{
|
|
||||||
$categories=OC_OCSClient::getCategories();
|
|
||||||
if($categories==NULL){
|
|
||||||
OC_App::setActiveNavigationEntry( "core_apps" );
|
|
||||||
|
|
||||||
$tmpl = new OC_Template( "admin", "app_noconn", "user" );
|
|
||||||
$tmpl->printPage();
|
|
||||||
unset($tmpl);
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if($id==0) {
|
|
||||||
OC_App::setActiveNavigationEntry( "core_apps_get" );
|
|
||||||
|
|
||||||
if($cat==0){
|
|
||||||
$numcats=array();
|
|
||||||
foreach($categories as $key=>$value) $numcats[]=$key;
|
|
||||||
$apps=OC_OCSClient::getApplications($numcats);
|
|
||||||
}else{
|
|
||||||
$apps=OC_OCSClient::getApplications($cat);
|
|
||||||
}
|
|
||||||
|
|
||||||
// return template
|
|
||||||
$tmpl = new OC_Template( "admin", "apps", "user" );
|
|
||||||
|
|
||||||
$tmpl->assign( "categories", $categories );
|
|
||||||
$tmpl->assign( "apps", $apps );
|
|
||||||
$tmpl->printPage();
|
|
||||||
unset($tmpl);
|
|
||||||
|
|
||||||
}else{
|
|
||||||
OC_App::setActiveNavigationEntry( "core_apps" );
|
|
||||||
|
|
||||||
$app=OC_OCSClient::getApplication($id);
|
|
||||||
|
|
||||||
$tmpl = new OC_Template( "admin", "app", "user" );
|
|
||||||
$tmpl->assign( "categories", $categories );
|
|
||||||
$tmpl->assign( "app", $app );
|
|
||||||
$tmpl->printPage();
|
|
||||||
unset($tmpl);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$categories=OC_OCSClient::getCategories();
|
||||||
|
// print_r($categories);
|
||||||
|
|
||||||
|
$tmpl = new OC_Template( "admin", "apps", "user" );
|
||||||
|
$tmpl->assign('apps',$apps);
|
||||||
|
|
||||||
|
$tmpl->printPage();
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,14 +1,3 @@
|
||||||
/* APPS TABLE */
|
li{color:#888}
|
||||||
table td.date { width:5em; padding:.5em 1em; text-align:left; }
|
li.active{color:#000}
|
||||||
table td.version, table td.enabled, table td.disabled { padding:.5em 1em; text-align:left; }
|
span.version{margin-left:3em;color:#ddd}
|
||||||
.preview { padding:3px; text-align:left; }
|
|
||||||
table td.date { width:11em; color:#555; }
|
|
||||||
table td.selection, table th.selection, table td.fileaction { width:2em; text-align:left; }
|
|
||||||
table td.name a { padding:6px; text-decoration:none; color:#555; }
|
|
||||||
.type { text-decoration:none; color:#888; font-size:.8em; }
|
|
||||||
.description { text-decoration:none; color:#666; font-size:.9em; }
|
|
||||||
|
|
||||||
#content ul#apps { width:40em; list-style:none; }
|
|
||||||
#content ul#apps li { display:block; padding:.2em; clear:right; }
|
|
||||||
#content ul#apps em { color:#555; }
|
|
||||||
#content ul#apps input { float:right; }
|
|
||||||
|
|
|
@ -1,17 +1,38 @@
|
||||||
$("input[x-use='appenablebutton']").live( "click", function(){
|
$(document).ready(function(){
|
||||||
appid = $(this).parent().data("uid");
|
$('#leftcontent li').each(function(index,li){
|
||||||
|
var app=$.parseJSON($(this).children('span').text());
|
||||||
//alert("dsfsdfsdf");
|
$(li).data('app',app);
|
||||||
if($(this).val() == "enabled"){
|
});
|
||||||
$(this).attr("value","disabled");
|
$('#leftcontent li').click(function(){
|
||||||
$(this).removeClass( "enabled" );
|
var app=$(this).data('app');
|
||||||
$(this).addClass( "disabled" );
|
$('#rightcontent p').show();
|
||||||
$.post( "ajax/disableapp.php", 'appid='+appid);
|
$('#rightcontent span.name').text(app.name);
|
||||||
}
|
$('#rightcontent span.version').text(app.version);
|
||||||
else if($(this).val() == "disabled"){
|
$('#rightcontent p.description').text(app.description);
|
||||||
$(this).attr("value","enabled");
|
$('#rightcontent span.author').text(app.author);
|
||||||
$(this).removeClass( "disabled" );
|
$('#rightcontent span.licence').text(app.licence);
|
||||||
$(this).addClass( "enabled" );
|
|
||||||
$.post( "ajax/enableapp.php", 'appid='+appid);
|
$('#rightcontent input.enable').show();
|
||||||
}
|
$('#rightcontent input.enable').val((app.active)?t('admin','Disable'):t('admin','Enable'));
|
||||||
});
|
$('#rightcontent input.enable').data('appid',app.id);
|
||||||
|
$('#rightcontent input.enable').data('active',app.active);
|
||||||
|
});
|
||||||
|
$('#rightcontent input.enable').click(function(){
|
||||||
|
var app=$(this).data('appid');
|
||||||
|
var active=$(this).data('active');
|
||||||
|
if(app){
|
||||||
|
if(active){
|
||||||
|
$.post(OC.filePath('admin','ajax','disableapp.php'),{appid:app});
|
||||||
|
$('#leftcontent li[data-id="'+app+'"]').removeClass('active');
|
||||||
|
}else{
|
||||||
|
$.post(OC.filePath('admin','ajax','enableapp.php'),{appid:app});
|
||||||
|
$('#leftcontent li[data-id="'+app+'"]').addClass('active');
|
||||||
|
}
|
||||||
|
active=!active;
|
||||||
|
$(this).data('active',active);
|
||||||
|
$(this).val((active)?t('admin','Disable'):t('admin','Enable'));
|
||||||
|
var appData=$('#leftcontent li[data-id="'+app+'"]');
|
||||||
|
appData.active=active;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
<?php $app=$_['app']; ?>
|
|
||||||
<h1><?php echo $app["name"]; ?></h1>
|
|
||||||
<?php echo('<span class="type">'.$app['typename'].'</span>'); ?><br />
|
|
||||||
<span class="date"><?php echo $l->l('datetime', $app["changed"]); ?></span><br />
|
|
||||||
|
|
||||||
|
|
||||||
<table cellspacing="6" border="0" width="100%">
|
|
||||||
<tr>
|
|
||||||
<td width="1" valign="top">
|
|
||||||
<?php if($app["preview1"]<>"") { echo('<img class="preview" border="0" src="'.$app["preview1"].'" /><br />'); } ?>
|
|
||||||
<?php if($app["preview2"]<>"") { echo('<img class="preview" border="0" src="'.$app["preview2"].'" /><br />'); } ?>
|
|
||||||
<?php if($app["preview3"]<>"") { echo('<img class="preview" border="0" src="'.$app["preview3"].'" /><br />'); } ?>
|
|
||||||
</td>
|
|
||||||
<td class="description" valign="top">
|
|
||||||
<?php echo $app["description"]; ?>
|
|
||||||
<br />
|
|
||||||
<?php echo('<a class="description" target="_blank" href="'.$app["detailpage"].'">'.$l->t( 'read more' ).'</a><br />'); ?>
|
|
||||||
</td>
|
|
||||||
<td width="1" valign="top"><a class="prettybutton" href=""><?php echo $l->t( 'Install' ); ?></a></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
<h2><?php echo $l->t( 'Cannot connect to apps repository' ); ?></h2>
|
|
|
@ -1,19 +1,17 @@
|
||||||
<table cellspacing="0">
|
<ul id="leftcontent">
|
||||||
<thead>
|
<?php foreach($_['apps'] as $app):?>
|
||||||
<tr>
|
<li <?php if($app['active']) echo 'class="active"'?> data-id="<?php echo $app['id'] ?>">
|
||||||
<th></th>
|
<?php echo $app['name'] ?>
|
||||||
<th><?php echo $l->t( 'Name' ); ?></th>
|
<span class="hidden">
|
||||||
<th><?php echo $l->t( 'Modified' ); ?></th>
|
<?php echo json_encode($app) ?>
|
||||||
</tr>
|
</span>
|
||||||
</thead>
|
</li>
|
||||||
<tbody>
|
<?php endforeach;?>
|
||||||
<?php foreach($_["apps"] as $app): ?>
|
</ul>
|
||||||
<tr>
|
<div id="rightcontent">
|
||||||
<td width="1"><?php if($app["preview"] <> "") { echo('<a href="'.OC_Helper::linkTo( "admin", "apps.php" ).'?id='.$app['id'].'"><img class="preview" border="0" src="'.$app["preview"].'" /></a>'); } ?> </a></td>
|
<h3><span class="name"><?php echo $l->t('Select an App');?></span><span class="version"></span></h3>
|
||||||
<td class="name"><a href="<?php echo(OC_Helper::linkTo( "admin", "apps.php" ).'?id='.$app['id']); ?>" title=""><?php echo $app["name"]; ?></a><br /><?php echo('<span class="type">'.$app['typename'].'</span>'); ?></td>
|
<p class="description"></p>
|
||||||
<td class="date"><?php echo $l->l('datetime', $app["changed"]); ?></td>
|
<p class="hidden"><?php echo $l->t('By: ');?><span class="author"></span></p>
|
||||||
</tr>
|
<p class="hidden"><?php echo $l->t('Licence: ');?><span class="licence"></span></p>
|
||||||
<?php endforeach; ?>
|
<input class="enable hidden" type="submit"></input>
|
||||||
</tbody>
|
</div>
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
<ul id="apps">
|
|
||||||
<?php foreach($_["apps"] as $app): ?>
|
|
||||||
<li data-uid="<?php echo($app['id']); ?>"><strong><?php echo($app['name']); ?></strong> <?php echo($app['version']); ?> <em>by <?php echo($app['author']); ?></em>
|
|
||||||
<input x-use="appenablebutton" type="submit" value="<?php echo $l->t( $app['enabled'] ? 'enabled' : 'disabled' ); ?>" class="appbutton <?php echo( $app['enabled'] ? 'enabled' : 'disabled' ); ?>" />
|
|
||||||
</li>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</ul>
|
|
|
@ -4,6 +4,6 @@
|
||||||
<name>Text viewer</name>
|
<name>Text viewer</name>
|
||||||
<version>0.3</version>
|
<version>0.3</version>
|
||||||
<licence>AGPL</licence>
|
<licence>AGPL</licence>
|
||||||
<author>Icewind</author>
|
<author>Robin Appelman</author>
|
||||||
<require>2</require>
|
<require>2</require>
|
||||||
</info>
|
</info>
|
||||||
|
|
|
@ -104,3 +104,4 @@ legend { padding:.2em; font-size:1.2em; }
|
||||||
#quota_indicator div { background-color:#76A9EA; border-radius:10px; -webkit-border-radius:10px; -moz-border-radius:10px; }
|
#quota_indicator div { background-color:#76A9EA; border-radius:10px; -webkit-border-radius:10px; -moz-border-radius:10px; }
|
||||||
|
|
||||||
li.error { list-style:none; width:640px; margin:4em auto; padding:1em 1em 1em 4em; background-color:#fee; background-image:url('../img/task-attention.png'); background-position:0.8em 0.8em; background-repeat:no-repeat; border:1px solid #ccc; -moz-border-radius:10px; -webkit-border-radius:10px; border-radius:10px; }
|
li.error { list-style:none; width:640px; margin:4em auto; padding:1em 1em 1em 4em; background-color:#fee; background-image:url('../img/task-attention.png'); background-position:0.8em 0.8em; background-repeat:no-repeat; border:1px solid #ccc; -moz-border-radius:10px; -webkit-border-radius:10px; border-radius:10px; }
|
||||||
|
.hidden{display:none}
|
17
lib/app.php
17
lib/app.php
|
@ -136,7 +136,6 @@ class OC_App{
|
||||||
* This function returns all data it got via register().
|
* This function returns all data it got via register().
|
||||||
*/
|
*/
|
||||||
public static function get(){
|
public static function get(){
|
||||||
// TODO: write function
|
|
||||||
return OC_App::$apps;
|
return OC_App::$apps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,7 +241,7 @@ class OC_App{
|
||||||
if(is_file($appid)){
|
if(is_file($appid)){
|
||||||
$file=$appid;
|
$file=$appid;
|
||||||
}else{
|
}else{
|
||||||
$file='apps/'.$appid.'/appinfo/info.xml';
|
$file=OC::$SERVERROOT.'/apps/'.$appid.'/appinfo/info.xml';
|
||||||
if(!is_file($file)){
|
if(!is_file($file)){
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
@ -332,4 +331,18 @@ class OC_App{
|
||||||
public static function registerPersonal($app,$page){
|
public static function registerPersonal($app,$page){
|
||||||
self::$personalForms[]='apps/'.$app.'/'.$page.'.php';
|
self::$personalForms[]='apps/'.$app.'/'.$page.'.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get a list of all apps in the apps folder
|
||||||
|
*/
|
||||||
|
public static function getAllApps(){
|
||||||
|
$apps=array();
|
||||||
|
$dh=opendir(OC::$SERVERROOT.'/apps');
|
||||||
|
while($file=readdir($dh)){
|
||||||
|
if(is_file(OC::$SERVERROOT.'/apps/'.$file.'/appinfo/app.php')){
|
||||||
|
$apps[]=$file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $apps;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,8 @@ if(substr($scriptName,-1)=='/'){
|
||||||
}
|
}
|
||||||
$WEBROOT=substr($scriptName,0,strlen($scriptName)-strlen($SUBURI));
|
$WEBROOT=substr($scriptName,0,strlen($scriptName)-strlen($SUBURI));
|
||||||
|
|
||||||
|
OC::$SERVERROOT=$SERVERROOT;
|
||||||
|
OC::$WEBROOT=$WEBROOT;
|
||||||
|
|
||||||
if($WEBROOT!='' and $WEBROOT[0]!=='/'){
|
if($WEBROOT!='' and $WEBROOT[0]!=='/'){
|
||||||
$WEBROOT='/'.$WEBROOT;
|
$WEBROOT='/'.$WEBROOT;
|
||||||
|
|
Loading…
Reference in New Issue