personal.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * Copyright (c) 2011, Robin Appelman <icewind1991@gmail.com>
  4. * This file is licensed under the Affero General Public License version 3 or later.
  5. * See the COPYING-README file.
  6. */
  7. OC_Util::checkLoggedIn();
  8. OC_App::loadApps();
  9. // Highlight navigation entry
  10. OC_Util::addScript( 'settings', 'personal' );
  11. OC_Util::addStyle( 'settings', 'settings' );
  12. OC_Util::addScript( '3rdparty', 'chosen/chosen.jquery.min' );
  13. OC_Util::addStyle( '3rdparty', 'chosen' );
  14. OC_App::setActiveNavigationEntry( 'personal' );
  15. // calculate the disc space
  16. $rootInfo=OC_FileCache::get('');
  17. $sharedInfo=OC_FileCache::get('/Shared');
  18. $used=$rootInfo['size'];
  19. if($used<0) $used=0;
  20. $free=OC_Filesystem::free_space();
  21. $total=$free+$used;
  22. if($total==0) $total=1; // prevent division by zero
  23. $relative=round(($used/$total)*10000)/100;
  24. $email=OC_Preferences::getValue(OC_User::getUser(), 'settings', 'email', '');
  25. $lang=OC_Preferences::getValue( OC_User::getUser(), 'core', 'lang', OC_L10N::findLanguage() );
  26. $languageCodes=OC_L10N::findAvailableLanguages();
  27. sort ($languageCodes);
  28. //put the current language in the front
  29. unset($languageCodes[array_search($lang, $languageCodes)]);
  30. array_unshift($languageCodes, $lang);
  31. $languageNames=include 'languageCodes.php';
  32. $languages=array();
  33. foreach($languageCodes as $lang) {
  34. $l=OC_L10N::get('settings', $lang);
  35. if(substr($l->t('__language_name__'), 0, 1)!='_') {//first check if the language name is in the translation file
  36. $languages[]=array('code'=>$lang, 'name'=>$l->t('__language_name__'));
  37. }elseif(isset($languageNames[$lang])) {
  38. $languages[]=array('code'=>$lang, 'name'=>$languageNames[$lang]);
  39. }else{//fallback to language code
  40. $languages[]=array('code'=>$lang, 'name'=>$lang);
  41. }
  42. }
  43. // Return template
  44. $tmpl = new OC_Template( 'settings', 'personal', 'user');
  45. $tmpl->assign('usage', OC_Helper::humanFileSize($used));
  46. $tmpl->assign('total_space', OC_Helper::humanFileSize($total));
  47. $tmpl->assign('usage_relative', $relative);
  48. $tmpl->assign('email', $email);
  49. $tmpl->assign('languages', $languages);
  50. $forms=OC_App::getForms('personal');
  51. $tmpl->assign('forms', array());
  52. foreach($forms as $form) {
  53. $tmpl->append('forms', $form);
  54. }
  55. $tmpl->printPage();