aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-05-08 16:24:24 +0200
committerVincent Petry <pvince81@owncloud.com>2014-05-15 17:51:04 +0200
commit88ebb15f1d91b82022e02903ab73338065e223b9 (patch)
treefab7c807dc21209aa00980701107e26d695dba74
parent9ccb3279dd09b7042ab07c936a4c04127282476f (diff)
downloadnextcloud-server-88ebb15f1d91b82022e02903ab73338065e223b9.tar.gz
nextcloud-server-88ebb15f1d91b82022e02903ab73338065e223b9.zip
Added navigation manager in files app for the sidebar
Apps can now register navigation items into the sidebar of the files app. For every sidebar item there is a container. The container's content is rendered based on the script name given at registration time.
-rw-r--r--apps/files/index.php40
-rw-r--r--apps/files/lib/app.php17
-rw-r--r--apps/files/templates/appnavigation.php8
-rw-r--r--apps/files/templates/index.php8
-rw-r--r--apps/files_trashbin/appinfo/app.php13
-rw-r--r--apps/files_trashbin/index.php37
-rw-r--r--apps/files_trashbin/templates/index.php7
7 files changed, 70 insertions, 60 deletions
diff --git a/apps/files/index.php b/apps/files/index.php
index df207582dd6..ea57a548a22 100644
--- a/apps/files/index.php
+++ b/apps/files/index.php
@@ -83,16 +83,37 @@ if (OC_App::isEnabled('files_encryption')) {
$encryptionInitStatus = $session->getInitialized();
}
-$trashEnabled = \OCP\App::isEnabled('files_trashbin');
-$trashEmpty = true;
-if ($trashEnabled) {
- $trashEmpty = \OCA\Files_Trashbin\Trashbin::isEmpty($user);
-}
-
$nav = new OCP\Template('files', 'appnavigation', '');
-$nav->assign('trash', $trashEnabled);
-$nav->assign('trashEmpty', $trashEmpty);
+$navItems = \OCA\Files\App::getNavigationManager()->getAll();
+$nav->assign('navigationItems', $navItems);
+
+$contentItems = array();
+
+function renderScript($appName, $scriptName) {
+ $content = '';
+ $appPath = OC_App::getAppPath($appName);
+ $scriptPath = $appPath . '/' . $scriptName;
+ if (file_exists($scriptPath)) {
+ // TODO: sanitize path / script name ?
+ ob_start();
+ include $scriptPath;
+ $content = ob_get_contents();
+ @ob_end_clean();
+ }
+ return $content;
+}
+
+foreach ($navItems as $item) {
+ $content = '';
+ if (isset($item['script'])) {
+ $content = renderScript($item['appname'], $item['script']);
+ }
+ $contentItem = array();
+ $contentItem['appname'] = $item['appname'];
+ $contentItem['content'] = $content;
+ $contentItems[] = $contentItem;
+}
OCP\Util::addscript('files', 'fileactions');
OCP\Util::addscript('files', 'files');
@@ -100,8 +121,6 @@ OCP\Util::addscript('files', 'keyboardshortcuts');
$tmpl = new OCP\Template('files', 'index', 'user');
$tmpl->assign('dir', $dir);
$tmpl->assign('permissions', $permissions);
-$tmpl->assign('trash', $trashEnabled);
-$tmpl->assign('trashEmpty', $trashEmpty);
$tmpl->assign('uploadMaxFilesize', $maxUploadFilesize); // minimium of freeSpace and uploadLimit
$tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize));
$tmpl->assign('freeSpace', $freeSpace);
@@ -116,5 +135,6 @@ $tmpl->assign("allowShareWithLink", $config->getAppValue('core', 'shareapi_allow
$tmpl->assign("encryptionInitStatus", $encryptionInitStatus);
$tmpl->assign('disableSharing', false);
$tmpl->assign('appNavigation', $nav);
+$tmpl->assign('appContents', $contentItems);
$tmpl->printPage();
diff --git a/apps/files/lib/app.php b/apps/files/lib/app.php
index ed4aa32c662..e32225d0680 100644
--- a/apps/files/lib/app.php
+++ b/apps/files/lib/app.php
@@ -31,6 +31,11 @@ class App {
private $l10n;
/**
+ * @var \OCP\INavigationManager
+ */
+ private static $navigationManager;
+
+ /**
* @var \OC\Files\View
*/
private $view;
@@ -41,6 +46,18 @@ class App {
}
/**
+ * Returns the app's navigation manager
+ *
+ * @return \OCP\INavigationManager
+ */
+ public static function getNavigationManager() {
+ if (self::$navigationManager === null) {
+ self::$navigationManager = new \OC\NavigationManager();
+ }
+ return self::$navigationManager;
+ }
+
+ /**
* rename a file
*
* @param string $dir
diff --git a/apps/files/templates/appnavigation.php b/apps/files/templates/appnavigation.php
index 22987ec637c..a2fffd4c4b2 100644
--- a/apps/files/templates/appnavigation.php
+++ b/apps/files/templates/appnavigation.php
@@ -1,10 +1,10 @@
<div id="app-navigation">
<ul>
- <li class="allfiles"><a href="<?php p(OC_Helper::linkTo('files', '')) ?>"><?php p($l->t('All Files'));?></a></li>
+ <li class="nav-allfiles"><a href="<?php p(OC_Helper::linkTo('files', '')) ?>"><?php p($l->t('All Files'));?></a></li>
<li class="sep"></li>
- <?php if ($_['trash'] ): ?>
- <li class="trash"><a href="<?php p(OC_Helper::linkTo('files_trashbin', 'index.php')) ?>"><?php p($l->t('Deleted files'));?></a></li>
- <?php endif; ?>
+ <?php foreach ($_['navigationItems'] as $item) { ?>
+ <li class="nav-<?php p($item['appname']) ?>"><a href="<?php p(isset($item['href']) ? $item['href'] : '#') ?>"><?php p($item['name']);?></a></li>
+ <?php } ?>
</ul>
<div id="app-settings">
<div id="app-settings-header">
diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php
index 9ed294e6b6f..335e2b2acd7 100644
--- a/apps/files/templates/index.php
+++ b/apps/files/templates/index.php
@@ -1,6 +1,7 @@
<?php /** @var $l OC_L10N */ ?>
<?php $_['appNavigation']->printPage(); ?>
<div id="app-content">
+<div id="app-content-files">
<div id="controls">
<div class="actions creatable hidden">
<?php if(!isset($_['dirToken'])):?>
@@ -110,7 +111,12 @@
<?php p($l->t('Current scanning'));?> <span id='scan-current'></span>
</p>
</div>
-
+</div><!-- closing app-content-files -->
+ <?php foreach ($_['appContents'] as $content) { ?>
+ <div id="app-content-<?php p($content['appname']) ?>" class="hidden">
+ <?php print_unescaped($content['content']) ?>
+ </div>
+ <?php } ?>
</div><!-- closing app-content -->
<!-- config hints for javascript -->
diff --git a/apps/files_trashbin/appinfo/app.php b/apps/files_trashbin/appinfo/app.php
index d30a601ef56..a045b1f0f51 100644
--- a/apps/files_trashbin/appinfo/app.php
+++ b/apps/files_trashbin/appinfo/app.php
@@ -1,7 +1,14 @@
<?php
-
-//OC::$CLASSPATH['OCA\Files_Trashbin\Hooks'] = 'files_trashbin/lib/hooks.php';
-//OC::$CLASSPATH['OCA\Files_Trashbin\Trashbin'] = 'files_trashbin/lib/trash.php';
+$l = OC_L10N::get('files_trashbin');
// register hooks
\OCA\Files_Trashbin\Trashbin::registerHooks();
+
+\OCA\Files\App::getNavigationManager()->add(
+ array(
+ "appname" => 'files_trashbin',
+ "script" => 'index.php',
+ "order" => 1,
+ "name" => $l->t('Deleted files')
+ )
+);
diff --git a/apps/files_trashbin/index.php b/apps/files_trashbin/index.php
index 16cd5ecd4cd..59258a6cf16 100644
--- a/apps/files_trashbin/index.php
+++ b/apps/files_trashbin/index.php
@@ -3,45 +3,12 @@
// Check if we are a user
OCP\User::checkLoggedIn();
-OCP\App::setActiveNavigationEntry('files_index');
-
OCP\Util::addScript('files_trashbin', 'disableDefaultActions');
-OCP\Util::addScript('files', 'fileactions');
-$tmpl = new OCP\Template('files_trashbin', 'index', 'user');
-OCP\Util::addStyle('files', 'files');
+$tmpl = new OCP\Template('files_trashbin', 'index', '');
+
OCP\Util::addStyle('files_trashbin', 'trash');
-OCP\Util::addScript('files', 'filesummary');
-OCP\Util::addScript('files', 'breadcrumb');
-OCP\Util::addScript('files', 'filelist');
-// filelist overrides
OCP\Util::addScript('files_trashbin', 'filelist');
-OCP\Util::addscript('files', 'files');
OCP\Util::addScript('files_trashbin', 'trash');
-$dir = isset($_GET['dir']) ? stripslashes($_GET['dir']) : '';
-
-$isIE8 = false;
-preg_match('/MSIE (.*?);/', $_SERVER['HTTP_USER_AGENT'], $matches);
-if (count($matches) > 0 && $matches[1] <= 8){
- $isIE8 = true;
-}
-
-// if IE8 and "?dir=path" was specified, reformat the URL to use a hash like "#?dir=path"
-if ($isIE8 && isset($_GET['dir'])){
- if ($dir === ''){
- $dir = '/';
- }
- header('Location: ' . OCP\Util::linkTo('files_trashbin', 'index.php') . '#?dir=' . \OCP\Util::encodePath($dir));
- exit();
-}
-
-$tmpl->assign('dir', $dir);
-$tmpl->assign('disableSharing', true);
-
-$nav = new OCP\Template('files', 'appnavigation', '');
-$nav->assign('trash', true);
-
-$tmpl->assign('appNavigation', $nav);
-
$tmpl->printPage();
diff --git a/apps/files_trashbin/templates/index.php b/apps/files_trashbin/templates/index.php
index 02067385d4e..e90162e4d54 100644
--- a/apps/files_trashbin/templates/index.php
+++ b/apps/files_trashbin/templates/index.php
@@ -1,6 +1,4 @@
<?php /** @var $l OC_L10N */ ?>
-<?php $_['appNavigation']->printPage(); ?>
-<div id="app-content">
<div id="controls">
<div id="file_action_panel"></div>
</div>
@@ -8,10 +6,6 @@
<div id="emptycontent" class="hidden"><?php p($l->t('Nothing in here. Your trash bin is empty!'))?></div>
-<input type="hidden" id="permissions" value="0">
-<input type="hidden" id="disableSharing" data-status="<?php p($_['disableSharing']); ?>">
-<input type="hidden" name="dir" value="<?php p($_['dir']) ?>" id="dir">
-
<table id="filestable">
<thead>
<tr>
@@ -46,4 +40,3 @@
<tfoot>
</tfoot>
</table>
-</div>