personal.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. require_once('../lib/base.php');
  8. OC_Util::checkLoggedIn();
  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']-$sharedInfo['size'];
  19. $free=OC_Filesystem::free_space();
  20. $total=$free+$used;
  21. if($total==0) $total=1; // prevent division by zero
  22. $relative=round(($used/$total)*10000)/100;
  23. $email=OC_Preferences::getValue(OC_User::getUser(), 'settings','email','');
  24. $lang=OC_Preferences::getValue( OC_User::getUser(), 'core', 'lang', OC_L10N::findLanguage() );
  25. $languageCodes=OC_L10N::findAvailableLanguages();
  26. sort ($languageCodes);
  27. //put the current language in the front
  28. unset($languageCodes[array_search($lang,$languageCodes)]);
  29. array_unshift($languageCodes,$lang);
  30. $languageNames=include 'languageCodes.php';
  31. $languages=array();
  32. foreach($languageCodes as $lang){
  33. $l=OC_L10N::get('settings',$lang);
  34. if(substr($l->t('__language_name__'),0,1)!='_'){//first check if the language name is in the translation file
  35. $languages[]=array('code'=>$lang,'name'=>$l->t('__language_name__'));
  36. }elseif(isset($languageNames[$lang])){
  37. $languages[]=array('code'=>$lang,'name'=>$languageNames[$lang]);
  38. }else{//fallback to language code
  39. $languages[]=array('code'=>$lang,'name'=>$lang);
  40. }
  41. }
  42. // Return template
  43. $tmpl = new OC_Template( 'settings', 'personal', 'user');
  44. $tmpl->assign('usage',OC_Helper::humanFileSize($used));
  45. $tmpl->assign('total_space',OC_Helper::humanFileSize($total));
  46. $tmpl->assign('usage_relative',$relative);
  47. $tmpl->assign('email',$email);
  48. $tmpl->assign('languages',$languages);
  49. $forms=OC_App::getForms('personal');
  50. $tmpl->assign('forms',array());
  51. foreach($forms as $form){
  52. $tmpl->append('forms',$form);
  53. }
  54. $tmpl->printPage();
  55. ?>