External JSON for the Apps

This commit is contained in:
Lukas Reschke 2013-01-21 22:18:42 +01:00
parent 30274ee33e
commit d2383338de
4 changed files with 30 additions and 7 deletions

View File

@ -42,6 +42,7 @@ function app_sort( $a, $b ) {
} }
$combinedApps = OC_App::listAllApps();
usort( $combinedApps, 'app_sort' ); usort( $combinedApps, 'app_sort' );
$tmpl = new OC_Template( "settings", "apps", "user" ); $tmpl = new OC_Template( "settings", "apps", "user" );

View File

@ -0,0 +1,24 @@
<?php
/**
* Copyright (c) 2013 Lukas Reschke <lukas@statuscode.ch>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
// Check if admin user
OC_Util::checkAdminUser();
// Set the content type to JSON
header('Content-type: application/json');
// Disallow caching
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
$combinedApps = OC_App::listAllApps();
foreach($combinedApps as $app) {
echo("appData_".$app['id']."=".json_encode($app));
echo("\n");
}

View File

@ -53,6 +53,8 @@ $this->create('settings_ajax_disableapp', '/settings/ajax/disableapp.php')
->actionInclude('settings/ajax/disableapp.php'); ->actionInclude('settings/ajax/disableapp.php');
$this->create('settings_ajax_navigationdetect', '/settings/ajax/navigationdetect.php') $this->create('settings_ajax_navigationdetect', '/settings/ajax/navigationdetect.php')
->actionInclude('settings/ajax/navigationdetect.php'); ->actionInclude('settings/ajax/navigationdetect.php');
$this->create('apps_custom', '/settings/js/apps-custom.js')
->actionInclude('settings/js/apps-custom.php');
// admin // admin
$this->create('settings_ajax_getlog', '/settings/ajax/getlog.php') $this->create('settings_ajax_getlog', '/settings/ajax/getlog.php')
->actionInclude('settings/ajax/getlog.php'); ->actionInclude('settings/ajax/getlog.php');

View File

@ -3,9 +3,8 @@
* This file is licensed under the Affero General Public License version 3 or later. * This file is licensed under the Affero General Public License version 3 or later.
* See the COPYING-README file. * See the COPYING-README file.
*/?> */?>
<script type='text/javascript'> <script type="text/javascript" src="<?php echo OC_Helper::linkToRoute('apps_custom');?>"></script>
var appid = '<?php echo $_['appid']; ?>';
</script>
<div id="controls"> <div id="controls">
<a class="button" target="_blank" href="http://owncloud.org/dev/apps/getting-started/"><?php echo $l->t('Add your App');?></a> <a class="button" target="_blank" href="http://owncloud.org/dev/apps/getting-started/"><?php echo $l->t('Add your App');?></a>
<a class="button" target="_blank" href="http://apps.owncloud.com"><?php echo $l->t('More Apps');?></a> <a class="button" target="_blank" href="http://apps.owncloud.com"><?php echo $l->t('More Apps');?></a>
@ -15,9 +14,6 @@
<li <?php if($app['active']) echo 'class="active"'?> data-id="<?php echo $app['id'] ?>" <?php if ( isset( $app['ocs_id'] ) ) { echo "data-id-ocs=\"{$app['ocs_id']}\""; } ?> <li <?php if($app['active']) echo 'class="active"'?> data-id="<?php echo $app['id'] ?>" <?php if ( isset( $app['ocs_id'] ) ) { echo "data-id-ocs=\"{$app['ocs_id']}\""; } ?>
data-type="<?php echo $app['internal'] ? 'internal' : 'external' ?>" data-installed="1"> data-type="<?php echo $app['internal'] ? 'internal' : 'external' ?>" data-installed="1">
<a class="app<?php if(!$app['internal']) echo ' externalapp' ?>" href="?appid=<?php echo $app['id'] ?>"><?php echo htmlentities($app['name']) ?></a> <a class="app<?php if(!$app['internal']) echo ' externalapp' ?>" href="?appid=<?php echo $app['id'] ?>"><?php echo htmlentities($app['name']) ?></a>
<script>
appData_<?php echo $app['id'] ?>=<?php OC_JSON::encodedPrint($app, false) ?>;
</script>
<?php if(!$app['internal']) echo '<small class="externalapp list">3rd party</small>' ?> <?php if(!$app['internal']) echo '<small class="externalapp list">3rd party</small>' ?>
</li> </li>
<?php endforeach;?> <?php endforeach;?>