From cdf91b6b3e0f6d9fc435497b9dcc051ff24d6c7e Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 10 Aug 2011 12:20:43 +0200 Subject: [PATCH] work in new app management --- admin/apps.php | 85 +++++--------------------- admin/css/apps.css | 17 +----- admin/js/apps.js | 55 +++++++++++------ admin/templates/app.php | 22 ------- admin/templates/app_noconn.php | 1 - admin/templates/apps.php | 36 ++++++----- admin/templates/appsinst.php | 7 --- apps/files_textviewer/appinfo/info.xml | 2 +- core/css/styles.css | 1 + lib/app.php | 17 +++++- lib/base.php | 3 +- 11 files changed, 92 insertions(+), 154 deletions(-) delete mode 100644 admin/templates/app.php delete mode 100644 admin/templates/app_noconn.php delete mode 100644 admin/templates/appsinst.php diff --git a/admin/apps.php b/admin/apps.php index de11dccc3d..83a48b6524 100644 --- a/admin/apps.php +++ b/admin/apps.php @@ -31,76 +31,21 @@ if( !OC_User::isLoggedIn() || !OC_Group::inGroup( OC_User::getUser(), 'admin' )) OC_Util::addStyle( "admin", "apps" ); OC_Util::addScript( "admin", "apps" ); - -if(isset($_GET['id'])) $id=$_GET['id']; else $id=0; -if(isset($_GET['cat'])) $cat=$_GET['cat']; else $cat=0; -if(isset($_GET['installed'])) $installed=true; else $installed=false; - -if($installed){ - global $SERVERROOT; - 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); - - } +$registeredApps=OC_App::getAllApps(); +$apps=array(); +foreach($registeredApps as $app){ + $info=OC_App::getAppInfo($app); + $active=(OC_Appconfig::getValue($app,'enabled','no')=='yes')?true:false; + $info['active']=$active; + $apps[]=$info; } +$categories=OC_OCSClient::getCategories(); +// print_r($categories); + +$tmpl = new OC_Template( "admin", "apps", "user" ); +$tmpl->assign('apps',$apps); + +$tmpl->printPage(); + ?> diff --git a/admin/css/apps.css b/admin/css/apps.css index 92ab64df55..6106ff3f7e 100644 --- a/admin/css/apps.css +++ b/admin/css/apps.css @@ -1,14 +1,3 @@ -/* APPS TABLE */ -table td.date { width:5em; padding:.5em 1em; text-align:left; } -table td.version, table td.enabled, table td.disabled { padding:.5em 1em; text-align:left; } -.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; } +li{color:#888} +li.active{color:#000} +span.version{margin-left:3em;color:#ddd} diff --git a/admin/js/apps.js b/admin/js/apps.js index 4def5ed555..069681e1cd 100644 --- a/admin/js/apps.js +++ b/admin/js/apps.js @@ -1,17 +1,38 @@ -$("input[x-use='appenablebutton']").live( "click", function(){ - appid = $(this).parent().data("uid"); - - //alert("dsfsdfsdf"); - if($(this).val() == "enabled"){ - $(this).attr("value","disabled"); - $(this).removeClass( "enabled" ); - $(this).addClass( "disabled" ); - $.post( "ajax/disableapp.php", 'appid='+appid); - } - else if($(this).val() == "disabled"){ - $(this).attr("value","enabled"); - $(this).removeClass( "disabled" ); - $(this).addClass( "enabled" ); - $.post( "ajax/enableapp.php", 'appid='+appid); - } -}); \ No newline at end of file +$(document).ready(function(){ + $('#leftcontent li').each(function(index,li){ + var app=$.parseJSON($(this).children('span').text()); + $(li).data('app',app); + }); + $('#leftcontent li').click(function(){ + var app=$(this).data('app'); + $('#rightcontent p').show(); + $('#rightcontent span.name').text(app.name); + $('#rightcontent span.version').text(app.version); + $('#rightcontent p.description').text(app.description); + $('#rightcontent span.author').text(app.author); + $('#rightcontent span.licence').text(app.licence); + + $('#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; + } + }); +}); diff --git a/admin/templates/app.php b/admin/templates/app.php deleted file mode 100644 index 06896121d0..0000000000 --- a/admin/templates/app.php +++ /dev/null @@ -1,22 +0,0 @@ - -

-'.$app['typename'].''); ?>
-l('datetime', $app["changed"]); ?>
- - - - - - - - -
- "") { echo('
'); } ?> - "") { echo('
'); } ?> - "") { echo('
'); } ?> -
- -
- '.$l->t( 'read more' ).'
'); ?> -
t( 'Install' ); ?>
- diff --git a/admin/templates/app_noconn.php b/admin/templates/app_noconn.php deleted file mode 100644 index f22d365628..0000000000 --- a/admin/templates/app_noconn.php +++ /dev/null @@ -1 +0,0 @@ -

t( 'Cannot connect to apps repository' ); ?>

diff --git a/admin/templates/apps.php b/admin/templates/apps.php index 732326f659..a7f0a4a79e 100644 --- a/admin/templates/apps.php +++ b/admin/templates/apps.php @@ -1,19 +1,17 @@ - - - - - - - - - - - - - - - - - -
t( 'Name' ); ?>t( 'Modified' ); ?>
"") { echo(''); } ?> " title="">
'.$app['typename'].''); ?>
l('datetime', $app["changed"]); ?>
- + +
+

t('Select an App');?>

+

+ + + +
diff --git a/admin/templates/appsinst.php b/admin/templates/appsinst.php deleted file mode 100644 index 035a75c9e8..0000000000 --- a/admin/templates/appsinst.php +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/apps/files_textviewer/appinfo/info.xml b/apps/files_textviewer/appinfo/info.xml index 112a416c35..209b414034 100644 --- a/apps/files_textviewer/appinfo/info.xml +++ b/apps/files_textviewer/appinfo/info.xml @@ -4,6 +4,6 @@ Text viewer 0.3 AGPL - Icewind + Robin Appelman 2 diff --git a/core/css/styles.css b/core/css/styles.css index da64adbd14..2b94dbe5e2 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -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; } 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} \ No newline at end of file diff --git a/lib/app.php b/lib/app.php index 411c08cbe5..9c7b7e75dc 100644 --- a/lib/app.php +++ b/lib/app.php @@ -136,7 +136,6 @@ class OC_App{ * This function returns all data it got via register(). */ public static function get(){ - // TODO: write function return OC_App::$apps; } @@ -242,7 +241,7 @@ class OC_App{ if(is_file($appid)){ $file=$appid; }else{ - $file='apps/'.$appid.'/appinfo/info.xml'; + $file=OC::$SERVERROOT.'/apps/'.$appid.'/appinfo/info.xml'; if(!is_file($file)){ return array(); } @@ -332,4 +331,18 @@ class OC_App{ public static function registerPersonal($app,$page){ 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; + } } diff --git a/lib/base.php b/lib/base.php index f59e375e76..93b8e0b584 100644 --- a/lib/base.php +++ b/lib/base.php @@ -90,7 +90,8 @@ if(substr($scriptName,-1)=='/'){ } $WEBROOT=substr($scriptName,0,strlen($scriptName)-strlen($SUBURI)); - +OC::$SERVERROOT=$SERVERROOT; +OC::$WEBROOT=$WEBROOT; if($WEBROOT!='' and $WEBROOT[0]!=='/'){ $WEBROOT='/'.$WEBROOT;