summaryrefslogtreecommitdiffstats
path: root/apps/files/lib/Controller
diff options
context:
space:
mode:
authorfnuesse <felix.nuesse@t-online.de>2018-06-16 22:44:18 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-07-12 16:49:37 +0200
commitfc4baed6e5e862492ac1e2f12a408971d8ee6a26 (patch)
tree4e7be115ef44fedcb145a2a5141b9c947e63447f /apps/files/lib/Controller
parent72ace9697c0951b3379a88c3cb639e1c9abe0170 (diff)
downloadnextcloud-server-fc4baed6e5e862492ac1e2f12a408971d8ee6a26.tar.gz
nextcloud-server-fc4baed6e5e862492ac1e2f12a408971d8ee6a26.zip
Added toggleable QuickAccess
Signed-off-by: fnuesse <felix.nuesse@t-online.de> Deleted wrongly commited File Signed-off-by: fnuesse <felix.nuesse@t-online.de> Added quickaccess-state persistence Signed-off-by: fnuesse <felix.nuesse@t-online.de> Started implementing sorting-algorithm for proper alphabetical display Signed-off-by: fnuesse <felix.nuesse@t-online.de> Finished Sorting of Quickaccess elements Signed-off-by: fnuesse <felix.nuesse@t-online.de> Implemented persistence for reverse-list and sorting-strategy Signed-off-by: fnuesse <felix.nuesse@t-online.de> Implemented initial sorting for reverse-list and sorting-strategy Signed-off-by: fnuesse <felix.nuesse@t-online.de> Refactored Code Signed-off-by: fnuesse <felix.nuesse@t-online.de> Refactored Code Signed-off-by: fnuesse <felix.nuesse@t-online.de> Refactored Code Signed-off-by: fnuesse <felix.nuesse@t-online.de>
Diffstat (limited to 'apps/files/lib/Controller')
-rw-r--r--apps/files/lib/Controller/ApiController.php54
-rw-r--r--apps/files/lib/Controller/ViewController.php91
2 files changed, 97 insertions, 48 deletions
diff --git a/apps/files/lib/Controller/ApiController.php b/apps/files/lib/Controller/ApiController.php
index b1af121ed6e..53a8e1b55ee 100644
--- a/apps/files/lib/Controller/ApiController.php
+++ b/apps/files/lib/Controller/ApiController.php
@@ -45,6 +45,7 @@ use OCP\IPreview;
use OCP\Share\IManager;
use OC\Files\Node\Node;
use OCP\IUserSession;
+use Sabre\VObject\Property\Boolean;
/**
* Class ApiController
@@ -270,27 +271,64 @@ class ApiController extends Controller {
*
* @NoAdminRequired
*
- * @param int $value
+ * @param bool $show
+ *
* @return Response
*/
- public function showQuickAccess() {
- $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'show_Quick_Access', 1);
+ public function showQuickAccess($show) {
+ $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'show_Quick_Access', (int) $show);
return new Response();
}
/**
- * Toggle default for showing/hiding QuickAccess folder
+ * quickaccess-sorting-strategy
*
* @NoAdminRequired
*
- * @param int $value
+ * @param string $strategy
* @return Response
*/
- public function hideQuickAccess() {
- $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'show_Quick_Access', 0);
+ public function setSortingStrategy($strategy) {
+ $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_sorting_strategy', (String) $strategy);
return new Response();
- }
+ }
+ /**
+ * Get reverse-state for quickaccess-list
+ *
+ * @NoAdminRequired
+ *
+ * @return String
+ */
+ public function getSortingStrategy() {
+ return $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_sorting_strategy', 'date');
+ }
+ /**
+ * Toggle for reverse quickaccess-list
+ *
+ * @NoAdminRequired
+ *
+ * @param bool $reverse
+ * @return Response
+ */
+ public function setReverseQuickaccess($reverse) {
+ $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_reverse_list', (int) $reverse);
+ return new Response();
+ }
+
+ /**
+ * Get reverse-state for quickaccess-list
+ *
+ * @NoAdminRequired
+ *
+ * @return bool
+ */
+ public function getReverseQuickaccess() {
+ if($this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_reverse_list', false)){
+ return true;
+ }
+ return false;
+ }
}
diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php
index 54602839eb0..11a42fb5291 100644
--- a/apps/files/lib/Controller/ViewController.php
+++ b/apps/files/lib/Controller/ViewController.php
@@ -159,58 +159,73 @@ class ViewController extends Controller {
// FIXME: Make non static
$storageInfo = $this->getStorageInfo();
+ $user = $this->userSession->getUser()->getUID();
+
+ $sorting=$this->config->getUserValue($user,$this->appName,'quickaccess_sorting_strategy','date');
+ $reverseListSetting=$this->config->getUserValue($user,$this->appName,'quickaccess_reverse_list','false');
+ if($this->config->getUserValue($user,$this->appName,'show_Quick_Access',true)){
+ $expanded='true';
+ }else{
+ $expanded='false';
+ }
\OCA\Files\App::getNavigationManager()->add(
[
'id' => 'favorites',
'appname' => 'files',
'script' => 'simplelist.php',
+ 'enableQuickaccess' => $expanded,
+ 'quickaccessSortingStrategy' => $sorting,
+ 'quickaccessSortingReverse' => $reverseListSetting,
'order' => 5,
'name' => $this->l10n->t('Favorites')
]
);
-
-
- $user = $this->userSession->getUser()->getUID();
-
$tagger=\OC::$server->getTagManager();
-
$helper= new \OCA\Files\Activity\Helper($tagger);
$favElements = $helper->getFavoriteFilePaths($this->userSession->getUser()->getUID());
- $favItems = $favElements['items'];
-
- $key='show_Quick_Access';
-
- if($this->config->getUserValue($user,$this->appName,$key,true) && sizeof($favElements['folders'])>0){
- /*$nav->assign('showQuickAccess', 1);
- \OCA\Files\App::getNavigationManager()->add(
- [
- 'id' => 'Spacer',
- 'classes' => 'app-navigation-caption',
- 'order' => 6,
- 'name' => $this->l10n->t('Quick-Access')
- ]
- );*/
-
- $i=0;
- foreach($favElements['folders'] as $elem){
-
- \OCA\Files\App::getNavigationManager()->add(
- [
- 'id' => substr( $elem, strrpos($elem,'/')+1, strlen($elem)),
- 'href' => \OC::$WEBROOT.'/index.php/apps/files/?dir='.$elem,
- 'order' => 7+$i,
- 'classes' => 'app-navigation-subelement',
- 'name' => substr( $elem, strrpos($elem,'/')+1, strlen($elem)),
- 'icon' => 'files'
- ]
- );
- $i++;
- }
- }
+ $FavoritesFolderCount=sizeof($favElements['folders']);
+ if($FavoritesFolderCount>0){
+
+ $NavBarPositionPosition=6;
+ $currentCount=0;
+ foreach($favElements['folders'] as $elem){
+
+ $id=substr( $elem, strrpos($elem,'/')+1, strlen($elem));
+ $link=\OC::$WEBROOT.'/index.php/apps/files/?dir='.$elem;
+
+ $SortingValue=++$currentCount;
+ if($currentCount!=$FavoritesFolderCount){
+ \OCA\Files\App::getNavigationManager()->add(
+ [
+ 'id' => $id,
+ 'href' => $link,
+ 'order' => $NavBarPositionPosition,
+ 'folderPosition' => $SortingValue,
+ 'name' => $id,
+ 'icon' => 'files',
+ 'quickaccesselement' => 'true'
+ ]
+ );
+ }else{
+ \OCA\Files\App::getNavigationManager()->add(
+ [
+ 'id' => $id,
+ 'href' => $link,
+ 'order' => $NavBarPositionPosition,
+ 'folderPosition' => $SortingValue,
+ 'name' => $id,
+ 'icon' => 'files',
+ 'quickaccesselement' => 'last'
+ ]
+ );
+ }
+ $NavBarPositionPosition++;
+ }
+ }
$navItems = \OCA\Files\App::getNavigationManager()->getAll();
@@ -218,10 +233,6 @@ class ViewController extends Controller {
return $item1['order'] - $item2['order'];
});
-
-
-
-
$nav->assign('navigationItems', $navItems);
$nav->assign('usage', \OC_Helper::humanFileSize($storageInfo['used']));