You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

161 lines
5.5 KiB

16 years ago
16 years ago
16 years ago
16 years ago
  1. <?php
  2. /**
  3. * @author Björn Schießle <schiessle@owncloud.com>
  4. * @author Frank Karlitschek <frank@owncloud.org>
  5. * @author Jakob Sack <mail@jakobsack.de>
  6. * @author Jan-Christoph Borchardt <hey@jancborchardt.net>
  7. * @author Joas Schilling <nickvergessen@owncloud.com>
  8. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  9. * @author Morris Jobke <hey@morrisjobke.de>
  10. * @author Robin Appelman <icewind@owncloud.com>
  11. * @author Roman Geber <rgeber@owncloudapps.com>
  12. * @author Thomas Müller <thomas.mueller@tmit.eu>
  13. * @author Vincent Petry <pvince81@owncloud.com>
  14. *
  15. * @copyright Copyright (c) 2015, ownCloud, Inc.
  16. * @license AGPL-3.0
  17. *
  18. * This code is free software: you can redistribute it and/or modify
  19. * it under the terms of the GNU Affero General Public License, version 3,
  20. * as published by the Free Software Foundation.
  21. *
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU Affero General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU Affero General Public License, version 3,
  28. * along with this program. If not, see <http://www.gnu.org/licenses/>
  29. *
  30. */
  31. // Check if we are a user
  32. OCP\User::checkLoggedIn();
  33. // Load the files we need
  34. OCP\Util::addStyle('files', 'files');
  35. OCP\Util::addStyle('files', 'upload');
  36. OCP\Util::addStyle('files', 'mobile');
  37. OCP\Util::addscript('files', 'app');
  38. OCP\Util::addscript('files', 'file-upload');
  39. OCP\Util::addscript('files', 'newfilemenu');
  40. OCP\Util::addscript('files', 'jquery.iframe-transport');
  41. OCP\Util::addscript('files', 'jquery.fileupload');
  42. OCP\Util::addscript('files', 'jquery-visibility');
  43. OCP\Util::addscript('files', 'fileinfomodel');
  44. OCP\Util::addscript('files', 'filesummary');
  45. OCP\Util::addscript('files', 'breadcrumb');
  46. OCP\Util::addscript('files', 'filelist');
  47. OCP\Util::addscript('files', 'search');
  48. \OCP\Util::addScript('files', 'favoritesfilelist');
  49. \OCP\Util::addScript('files', 'tagsplugin');
  50. \OCP\Util::addScript('files', 'favoritesplugin');
  51. \OCP\Util::addScript('files', 'detailfileinfoview');
  52. \OCP\Util::addScript('files', 'detailtabview');
  53. \OCP\Util::addScript('files', 'mainfileinfodetailview');
  54. \OCP\Util::addScript('files', 'detailsview');
  55. \OCP\Util::addStyle('files', 'detailsView');
  56. \OC_Util::addVendorScript('core', 'handlebars/handlebars');
  57. OCP\App::setActiveNavigationEntry('files_index');
  58. $l = \OC::$server->getL10N('files');
  59. $isIE8 = false;
  60. preg_match('/MSIE (.*?);/', $_SERVER['HTTP_USER_AGENT'], $matches);
  61. if (count($matches) > 0 && $matches[1] <= 9) {
  62. $isIE8 = true;
  63. }
  64. // if IE8 and "?dir=path&view=someview" was specified, reformat the URL to use a hash like "#?dir=path&view=someview"
  65. if ($isIE8 && (isset($_GET['dir']) || isset($_GET['view']))) {
  66. $hash = '#?';
  67. $dir = isset($_GET['dir']) ? $_GET['dir'] : '/';
  68. $view = isset($_GET['view']) ? $_GET['view'] : 'files';
  69. $hash = '#?dir=' . \OCP\Util::encodePath($dir);
  70. if ($view !== 'files') {
  71. $hash .= '&view=' . urlencode($view);
  72. }
  73. header('Location: ' . OCP\Util::linkTo('files', 'index.php') . $hash);
  74. exit();
  75. }
  76. $user = OC_User::getUser();
  77. $config = \OC::$server->getConfig();
  78. // mostly for the home storage's free space
  79. $dirInfo = \OC\Files\Filesystem::getFileInfo('/', false);
  80. $storageInfo=OC_Helper::getStorageInfo('/', $dirInfo);
  81. $nav = new OCP\Template('files', 'appnavigation', '');
  82. function sortNavigationItems($item1, $item2) {
  83. return $item1['order'] - $item2['order'];
  84. }
  85. \OCA\Files\App::getNavigationManager()->add(
  86. array(
  87. 'id' => 'favorites',
  88. 'appname' => 'files',
  89. 'script' => 'simplelist.php',
  90. 'order' => 5,
  91. 'name' => $l->t('Favorites')
  92. )
  93. );
  94. $navItems = \OCA\Files\App::getNavigationManager()->getAll();
  95. usort($navItems, 'sortNavigationItems');
  96. $nav->assign('navigationItems', $navItems);
  97. $contentItems = array();
  98. function renderScript($appName, $scriptName) {
  99. $content = '';
  100. $appPath = OC_App::getAppPath($appName);
  101. $scriptPath = $appPath . '/' . $scriptName;
  102. if (file_exists($scriptPath)) {
  103. // TODO: sanitize path / script name ?
  104. ob_start();
  105. include $scriptPath;
  106. $content = ob_get_contents();
  107. @ob_end_clean();
  108. }
  109. return $content;
  110. }
  111. // render the container content for every navigation item
  112. foreach ($navItems as $item) {
  113. $content = '';
  114. if (isset($item['script'])) {
  115. $content = renderScript($item['appname'], $item['script']);
  116. }
  117. $contentItem = array();
  118. $contentItem['id'] = $item['id'];
  119. $contentItem['content'] = $content;
  120. $contentItems[] = $contentItem;
  121. }
  122. OCP\Util::addscript('files', 'fileactions');
  123. OCP\Util::addscript('files', 'fileactionsmenu');
  124. OCP\Util::addscript('files', 'files');
  125. OCP\Util::addscript('files', 'navigation');
  126. OCP\Util::addscript('files', 'keyboardshortcuts');
  127. \OC::$server->getEventDispatcher()->dispatch('OCA\Files::loadAdditionalScripts');
  128. $tmpl = new OCP\Template('files', 'index', 'user');
  129. $tmpl->assign('usedSpacePercent', (int)$storageInfo['relative']);
  130. $tmpl->assign('owner', $storageInfo['owner']);
  131. $tmpl->assign('ownerDisplayName', $storageInfo['ownerDisplayName']);
  132. $tmpl->assign('isPublic', false);
  133. $tmpl->assign("mailNotificationEnabled", $config->getAppValue('core', 'shareapi_allow_mail_notification', 'no'));
  134. $tmpl->assign("mailPublicNotificationEnabled", $config->getAppValue('core', 'shareapi_allow_public_notification', 'no'));
  135. $tmpl->assign("allowShareWithLink", $config->getAppValue('core', 'shareapi_allow_links', 'yes'));
  136. $tmpl->assign('appNavigation', $nav);
  137. $tmpl->assign('appContents', $contentItems);
  138. $tmpl->printPage();