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.
This commit is contained in:
parent
9ccb3279dd
commit
88ebb15f1d
|
@ -83,16 +83,37 @@ if (OC_App::isEnabled('files_encryption')) {
|
||||||
$encryptionInitStatus = $session->getInitialized();
|
$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 = new OCP\Template('files', 'appnavigation', '');
|
||||||
|
|
||||||
$nav->assign('trash', $trashEnabled);
|
$navItems = \OCA\Files\App::getNavigationManager()->getAll();
|
||||||
$nav->assign('trashEmpty', $trashEmpty);
|
$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', 'fileactions');
|
||||||
OCP\Util::addscript('files', 'files');
|
OCP\Util::addscript('files', 'files');
|
||||||
|
@ -100,8 +121,6 @@ OCP\Util::addscript('files', 'keyboardshortcuts');
|
||||||
$tmpl = new OCP\Template('files', 'index', 'user');
|
$tmpl = new OCP\Template('files', 'index', 'user');
|
||||||
$tmpl->assign('dir', $dir);
|
$tmpl->assign('dir', $dir);
|
||||||
$tmpl->assign('permissions', $permissions);
|
$tmpl->assign('permissions', $permissions);
|
||||||
$tmpl->assign('trash', $trashEnabled);
|
|
||||||
$tmpl->assign('trashEmpty', $trashEmpty);
|
|
||||||
$tmpl->assign('uploadMaxFilesize', $maxUploadFilesize); // minimium of freeSpace and uploadLimit
|
$tmpl->assign('uploadMaxFilesize', $maxUploadFilesize); // minimium of freeSpace and uploadLimit
|
||||||
$tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize));
|
$tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize));
|
||||||
$tmpl->assign('freeSpace', $freeSpace);
|
$tmpl->assign('freeSpace', $freeSpace);
|
||||||
|
@ -116,5 +135,6 @@ $tmpl->assign("allowShareWithLink", $config->getAppValue('core', 'shareapi_allow
|
||||||
$tmpl->assign("encryptionInitStatus", $encryptionInitStatus);
|
$tmpl->assign("encryptionInitStatus", $encryptionInitStatus);
|
||||||
$tmpl->assign('disableSharing', false);
|
$tmpl->assign('disableSharing', false);
|
||||||
$tmpl->assign('appNavigation', $nav);
|
$tmpl->assign('appNavigation', $nav);
|
||||||
|
$tmpl->assign('appContents', $contentItems);
|
||||||
|
|
||||||
$tmpl->printPage();
|
$tmpl->printPage();
|
||||||
|
|
|
@ -30,6 +30,11 @@ class App {
|
||||||
*/
|
*/
|
||||||
private $l10n;
|
private $l10n;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \OCP\INavigationManager
|
||||||
|
*/
|
||||||
|
private static $navigationManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \OC\Files\View
|
* @var \OC\Files\View
|
||||||
*/
|
*/
|
||||||
|
@ -40,6 +45,18 @@ class App {
|
||||||
$this->l10n = $l10n;
|
$this->l10n = $l10n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
* rename a file
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<div id="app-navigation">
|
<div id="app-navigation">
|
||||||
<ul>
|
<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>
|
<li class="sep"></li>
|
||||||
<?php if ($_['trash'] ): ?>
|
<?php foreach ($_['navigationItems'] as $item) { ?>
|
||||||
<li class="trash"><a href="<?php p(OC_Helper::linkTo('files_trashbin', 'index.php')) ?>"><?php p($l->t('Deleted files'));?></a></li>
|
<li class="nav-<?php p($item['appname']) ?>"><a href="<?php p(isset($item['href']) ? $item['href'] : '#') ?>"><?php p($item['name']);?></a></li>
|
||||||
<?php endif; ?>
|
<?php } ?>
|
||||||
</ul>
|
</ul>
|
||||||
<div id="app-settings">
|
<div id="app-settings">
|
||||||
<div id="app-settings-header">
|
<div id="app-settings-header">
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php /** @var $l OC_L10N */ ?>
|
<?php /** @var $l OC_L10N */ ?>
|
||||||
<?php $_['appNavigation']->printPage(); ?>
|
<?php $_['appNavigation']->printPage(); ?>
|
||||||
<div id="app-content">
|
<div id="app-content">
|
||||||
|
<div id="app-content-files">
|
||||||
<div id="controls">
|
<div id="controls">
|
||||||
<div class="actions creatable hidden">
|
<div class="actions creatable hidden">
|
||||||
<?php if(!isset($_['dirToken'])):?>
|
<?php if(!isset($_['dirToken'])):?>
|
||||||
|
@ -110,7 +111,12 @@
|
||||||
<?php p($l->t('Current scanning'));?> <span id='scan-current'></span>
|
<?php p($l->t('Current scanning'));?> <span id='scan-current'></span>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</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 -->
|
</div><!-- closing app-content -->
|
||||||
|
|
||||||
<!-- config hints for javascript -->
|
<!-- config hints for javascript -->
|
||||||
|
|
|
@ -1,7 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
|
$l = OC_L10N::get('files_trashbin');
|
||||||
//OC::$CLASSPATH['OCA\Files_Trashbin\Hooks'] = 'files_trashbin/lib/hooks.php';
|
|
||||||
//OC::$CLASSPATH['OCA\Files_Trashbin\Trashbin'] = 'files_trashbin/lib/trash.php';
|
|
||||||
|
|
||||||
// register hooks
|
// register hooks
|
||||||
\OCA\Files_Trashbin\Trashbin::registerHooks();
|
\OCA\Files_Trashbin\Trashbin::registerHooks();
|
||||||
|
|
||||||
|
\OCA\Files\App::getNavigationManager()->add(
|
||||||
|
array(
|
||||||
|
"appname" => 'files_trashbin',
|
||||||
|
"script" => 'index.php',
|
||||||
|
"order" => 1,
|
||||||
|
"name" => $l->t('Deleted files')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
|
@ -3,45 +3,12 @@
|
||||||
// Check if we are a user
|
// Check if we are a user
|
||||||
OCP\User::checkLoggedIn();
|
OCP\User::checkLoggedIn();
|
||||||
|
|
||||||
OCP\App::setActiveNavigationEntry('files_index');
|
|
||||||
|
|
||||||
OCP\Util::addScript('files_trashbin', 'disableDefaultActions');
|
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::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_trashbin', 'filelist');
|
||||||
OCP\Util::addscript('files', 'files');
|
|
||||||
OCP\Util::addScript('files_trashbin', 'trash');
|
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();
|
$tmpl->printPage();
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
<?php /** @var $l OC_L10N */ ?>
|
<?php /** @var $l OC_L10N */ ?>
|
||||||
<?php $_['appNavigation']->printPage(); ?>
|
|
||||||
<div id="app-content">
|
|
||||||
<div id="controls">
|
<div id="controls">
|
||||||
<div id="file_action_panel"></div>
|
<div id="file_action_panel"></div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -8,10 +6,6 @@
|
||||||
|
|
||||||
<div id="emptycontent" class="hidden"><?php p($l->t('Nothing in here. Your trash bin is empty!'))?></div>
|
<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">
|
<table id="filestable">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -46,4 +40,3 @@
|
||||||
<tfoot>
|
<tfoot>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
|
||||||
|
|
Loading…
Reference in New Issue