Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

templatelayout.php 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <?php
  2. /**
  3. * Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. class OC_TemplateLayout extends OC_Template {
  9. public function __construct( $renderas ) {
  10. // Decide which page we show
  11. if( $renderas == 'user' ) {
  12. parent::__construct( 'core', 'layout.user' );
  13. if(in_array(OC_APP::getCurrentApp(), array('settings','admin', 'help'))!==false) {
  14. $this->assign('bodyid', 'body-settings', false);
  15. }else{
  16. $this->assign('bodyid', 'body-user', false);
  17. }
  18. // Add navigation entry
  19. $navigation = OC_App::getNavigation();
  20. $this->assign( 'navigation', $navigation, false);
  21. $this->assign( 'settingsnavigation', OC_App::getSettingsNavigation(), false);
  22. foreach($navigation as $entry) {
  23. if ($entry['active']) {
  24. $this->assign( 'application', $entry['name'], false );
  25. break;
  26. }
  27. }
  28. } else if ($renderas == 'guest') {
  29. parent::__construct('core', 'layout.guest');
  30. } else {
  31. parent::__construct('core', 'layout.base');
  32. }
  33. // Add the js files
  34. $jsfiles = self::findJavascriptFiles(OC_Util::$scripts);
  35. $this->assign('jsfiles', array(), false);
  36. if (!empty(OC_Util::$core_scripts)) {
  37. $this->append( 'jsfiles', OC_Helper::linkToRemoteBase('core.js', false));
  38. }
  39. foreach($jsfiles as $info) {
  40. $root = $info[0];
  41. $web = $info[1];
  42. $file = $info[2];
  43. $this->append( 'jsfiles', $web.'/'.$file);
  44. }
  45. // Add the css files
  46. $cssfiles = self::findStylesheetFiles(OC_Util::$styles);
  47. $this->assign('cssfiles', array());
  48. if (!empty(OC_Util::$core_styles)) {
  49. $this->append( 'cssfiles', OC_Helper::linkToRemoteBase('core.css', false));
  50. }
  51. foreach($cssfiles as $info) {
  52. $root = $info[0];
  53. $web = $info[1];
  54. $file = $info[2];
  55. $paths = explode('/', $file);
  56. $in_root = false;
  57. foreach(OC::$APPSROOTS as $app_root) {
  58. if($root == $app_root['path']) {
  59. $in_root = true;
  60. break;
  61. }
  62. }
  63. if($in_root ) {
  64. $app = $paths[0];
  65. unset($paths[0]);
  66. $path = implode('/', $paths);
  67. $this->append( 'cssfiles', OC_Helper::linkTo($app, $path));
  68. }
  69. else {
  70. $this->append( 'cssfiles', $web.'/'.$file);
  71. }
  72. }
  73. }
  74. /*
  75. * @brief append the $file-url if exist at $root
  76. * @param $files array to append file info to
  77. * @param $root path to check
  78. * @param $web base for path
  79. * @param $file the filename
  80. */
  81. static public function appendIfExist(&$files, $root, $webroot, $file) {
  82. if (is_file($root.'/'.$file)) {
  83. $files[] = array($root, $webroot, $file);
  84. return true;
  85. }
  86. return false;
  87. }
  88. static public function findStylesheetFiles($styles) {
  89. // Read the selected theme from the config file
  90. $theme=OC_Config::getValue( 'theme' );
  91. // Read the detected formfactor and use the right file name.
  92. $fext = self::getFormFactorExtension();
  93. $files = array();
  94. foreach($styles as $style) {
  95. // is it in 3rdparty?
  96. if(self::appendIfExist($files, OC::$THIRDPARTYROOT, OC::$THIRDPARTYWEBROOT, $style.'.css')) {
  97. // or in the owncloud root?
  98. }elseif(self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "$style$fext.css" )) {
  99. }elseif(self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "$style.css" )) {
  100. // or in core ?
  101. }elseif(self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "core/$style$fext.css" )) {
  102. }elseif(self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "core/$style.css" )) {
  103. }else{
  104. $append = false;
  105. // or in apps?
  106. foreach( OC::$APPSROOTS as $apps_dir)
  107. {
  108. if(self::appendIfExist($files, $apps_dir['path'], $apps_dir['url'], "$style$fext.css")) {
  109. $append = true;
  110. break;
  111. }
  112. elseif(self::appendIfExist($files, $apps_dir['path'], $apps_dir['url'], "$style.css")) {
  113. $append = true;
  114. break;
  115. }
  116. }
  117. if(! $append) {
  118. echo('css file not found: style:'.$style.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT);
  119. die();
  120. }
  121. }
  122. }
  123. // Add the theme css files. you can override the default values here
  124. if(!empty($theme)) {
  125. foreach($styles as $style) {
  126. if(self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/apps/$style$fext.css" )) {
  127. }elseif(self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/apps/$style.css" )) {
  128. }elseif(self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/$style$fext.css" )) {
  129. }elseif(self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/$style.css" )) {
  130. }elseif(self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/core/$style$fext.css" )) {
  131. }elseif(self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/core/$style.css" )) {
  132. }
  133. }
  134. }
  135. return $files;
  136. }
  137. static public function findJavascriptFiles($scripts) {
  138. // Read the selected theme from the config file
  139. $theme=OC_Config::getValue( 'theme' );
  140. // Read the detected formfactor and use the right file name.
  141. $fext = self::getFormFactorExtension();
  142. $files = array();
  143. foreach($scripts as $script) {
  144. // Is it in 3rd party?
  145. if(self::appendIfExist($files, OC::$THIRDPARTYROOT, OC::$THIRDPARTYWEBROOT, $script.'.js')) {
  146. // Is it in apps and overwritten by the theme?
  147. }elseif(self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/apps/$script$fext.js" )) {
  148. }elseif(self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/apps/$script.js" )) {
  149. // Is it in the owncloud root but overwritten by the theme?
  150. }elseif(self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/$script$fext.js" )) {
  151. }elseif(self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/$script.js" )) {
  152. // Is it in the owncloud root ?
  153. }elseif(self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "$script$fext.js" )) {
  154. }elseif(self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "$script.js" )) {
  155. // Is in core but overwritten by a theme?
  156. }elseif(self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/core/$script$fext.js" )) {
  157. }elseif(self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/core/$script.js" )) {
  158. // Is it in core?
  159. }elseif(self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "core/$script$fext.js" )) {
  160. }elseif(self::appendIfExist($files, OC::$SERVERROOT, OC::$WEBROOT, "core/$script.js" )) {
  161. }else{
  162. // Is it part of an app?
  163. $append = false;
  164. foreach( OC::$APPSROOTS as $apps_dir) {
  165. if(self::appendIfExist($files, $apps_dir['path'], OC::$WEBROOT.$apps_dir['url'], "$script$fext.js")) {
  166. $append = true;
  167. break;
  168. }
  169. elseif(self::appendIfExist($files, $apps_dir['path'], OC::$WEBROOT.$apps_dir['url'], "$script.js")) {
  170. $append = true;
  171. break;
  172. }
  173. }
  174. if(! $append) {
  175. echo('js file not found: script:'.$script.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT);
  176. die();
  177. }
  178. }
  179. }
  180. return $files;
  181. }
  182. }