aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--]config/config.sample.php1
-rw-r--r--lib/template.php158
2 files changed, 138 insertions, 21 deletions
diff --git a/config/config.sample.php b/config/config.sample.php
index a40ce073bf6..cd525358713 100644..100755
--- a/config/config.sample.php
+++ b/config/config.sample.php
@@ -12,6 +12,7 @@ $CONFIG = array(
"dbtableprefix" => "",
"forcessl" => false,
"enablebackup" => false,
+"theme" => "",
// "datadirectory" => ""
);
?>
diff --git a/lib/template.php b/lib/template.php
index 881d2a27b1e..84302fd1385 100644
--- a/lib/template.php
+++ b/lib/template.php
@@ -151,21 +151,75 @@ class OC_Template{
* "admin".
*/
public function __construct( $app, $name, $renderas = "" ){
- // Get the right template folder
- $template = OC::$SERVERROOT."/core/templates/";
+ // Read the selected theme from the config file
+ $theme=OC_Config::getValue( "theme" );
+
+ // Read the detected formfactor and use the right file name.
+ $formfactor=$_SESSION['formfactor'];
+ if($formfactor=='default') {
+ $fext='';
+ }elseif($formfactor=='mobile') {
+ $fext='.mobile';
+ }elseif($formfactor=='tablet') {
+ $fext='.tablet';
+ }elseif($formfactor=='standalone') {
+ $fext='.standalone';
+ }else{
+ $fext='';
+ }
+
+ // Check if it is a app template or not.
if( $app != "" ){
- // Check if the app is in the app folder
+ // Check if the app is in the app folder or in the root
if( file_exists( OC::$SERVERROOT."/apps/$app/templates/" )){
- $template = OC::$SERVERROOT."/apps/$app/templates/";
+ // Check if the template is overwritten by the selected theme
+ if( file_exists( OC::$SERVERROOT."/themes/$theme/apps/$app/templates/"."$name$fext.php" )){
+ $template = OC::$SERVERROOT."/themes/$theme/apps/$app/templates/"."$name$fext.php";
+ $path = OC::$SERVERROOT."/themes/$theme/apps/$app/templates/";
+ }elseif( file_exists( OC::$SERVERROOT."/themes/$theme/apps/$app/templates/"."$name.php" )){
+ $template = OC::$SERVERROOT."/themes/$theme/apps/$app/templates/"."$name.php";
+ $path = OC::$SERVERROOT."/themes/$theme/apps/$app/templates/";
+ }elseif( OC::$SERVERROOT."/apps/$app/templates/"."$name$fext.php" ){
+ $template = OC::$SERVERROOT."/apps/$app/templates/"."$name$fext.php";
+ $path = OC::$SERVERROOT."/apps/$app/templates/";
+ }else{
+ $template = OC::$SERVERROOT."/apps/$app/templates/"."$name.php";
+ $path = OC::$SERVERROOT."/apps/$app/templates/";
+ }
+ }else{
+ // Check if the template is overwritten by the selected theme
+ if( file_exists( OC::$SERVERROOT."/themes/$theme/$app/templates/"."$name$fext.php" )){
+ $template = OC::$SERVERROOT."/themes/$theme/$app/templates/"."$name$fext.php";
+ $path = OC::$SERVERROOT."/themes/$theme/$app/templates/";
+ }elseif( file_exists( OC::$SERVERROOT."/themes/$theme/$app/templates/"."$name.php" )){
+ $template = OC::$SERVERROOT."/themes/$theme/$app/templates/"."$name.php";
+ $path = OC::$SERVERROOT."/themes/$theme/$app/templates/";
+ }elseif( file_exists( OC::$SERVERROOT."/$app/templates/"."$name$fext.php" )){
+ $template = OC::$SERVERROOT."/$app/templates/"."$name$fext.php";
+ $path = OC::$SERVERROOT."/$app/templates/";
+ }else{
+ $template = OC::$SERVERROOT."/$app/templates/"."$name.php";
+ $path = OC::$SERVERROOT."/$app/templates/";
+ }
+
}
- else{
- $template = OC::$SERVERROOT."/$app/templates/";
+ }else{
+ // Check if the template is overwritten by the selected theme
+ if( file_exists( OC::$SERVERROOT."/themes/$theme/core/templates/"."$name$fext.php" )){
+ $template = OC::$SERVERROOT."/themes/$theme/core/templates/"."$name$fext.php";
+ $path = OC::$SERVERROOT."/themes/$theme/core/templates/";
+ }elseif( file_exists( OC::$SERVERROOT."/themes/$theme/core/templates/"."$name.php" )){
+ $template = OC::$SERVERROOT."/themes/$theme/core/templates/"."$name.php";
+ $path = OC::$SERVERROOT."/themes/$theme/core/templates/";
+ }elseif( file_exists( OC::$SERVERROOT."/core/templates/"."$name$fext.php" )){
+ $template = OC::$SERVERROOT."/core/templates/"."$name$fext.php";
+ $path = OC::$SERVERROOT."/core/templates/";
+ }else{
+ $template = OC::$SERVERROOT."/core/templates/"."$name.php";
+ $path = OC::$SERVERROOT."/core/templates/";
}
}
- // Templates have the ending .php
- $path = $template;
- $template .= "$name.php";
// Set the private data
$this->renderas = $renderas;
@@ -265,31 +319,93 @@ class OC_Template{
}else{
$page = new OC_Template( "core", "layout.guest" );
}
+
+ // Read the selected theme from the config file
+ $theme=OC_Config::getValue( "theme" );
+
+ // Read the detected formfactor and use the right file name.
+ $formfactor=$_SESSION['formfactor'];
+ if($formfactor=='default') {
+ $fext='';
+ }elseif($formfactor=='mobile') {
+ $fext='.mobile';
+ }elseif($formfactor=='tablet') {
+ $fext='.tablet';
+ }elseif($formfactor=='standalone') {
+ $fext='.standalone';
+ }else{
+ $fext='';
+ }
- // Add the css and js files
+ // Add the core js files or the js files provided by the selected theme
foreach(OC_Util::$scripts as $script){
- if(is_file(OC::$SERVERROOT."/apps/$script.js" )){
+ if(is_file(OC::$SERVERROOT."/themes/$theme/apps/$script$fext.js" )){
+ $page->append( "jsfiles", OC::$WEBROOT."/themes/$theme/apps/$script$fext.js" );
+ }elseif(is_file(OC::$SERVERROOT."/themes/$theme/apps/$script.js" )){
+ $page->append( "jsfiles", OC::$WEBROOT."/themes/$theme/apps/$script.js" );
+
+ }elseif(is_file(OC::$SERVERROOT."/apps/$script$fext.js" )){
+ $page->append( "jsfiles", OC::$WEBROOT."/apps/$script$fext.js" );
+ }elseif(is_file(OC::$SERVERROOT."/apps/$script.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/apps/$script.js" );
- }
- elseif(is_file(OC::$SERVERROOT."/$script.js" )){
+
+ }elseif(is_file(OC::$SERVERROOT."/themes/$theme/$script$fext.js" )){
+ $page->append( "jsfiles", OC::$WEBROOT."/themes/$theme/$script$fext.js" );
+ }elseif(is_file(OC::$SERVERROOT."/themes/$theme/$script.js" )){
+ $page->append( "jsfiles", OC::$WEBROOT."/themes/$theme/$script.js" );
+
+ }elseif(is_file(OC::$SERVERROOT."/$script$fext.js" )){
+ $page->append( "jsfiles", OC::$WEBROOT."/$script$fext.js" );
+ }elseif(is_file(OC::$SERVERROOT."/$script.js" )){
$page->append( "jsfiles", OC::$WEBROOT."/$script.js" );
- }
- else{
+
+ }elseif(is_file(OC::$SERVERROOT."/themes/$theme/core/$script$fext.js" )){
+ $page->append( "jsfiles", OC::$WEBROOT."/themes/$theme/core/$script$fext.js" );
+ }elseif(is_file(OC::$SERVERROOT."/themes/$theme/core/$script.js" )){
+ $page->append( "jsfiles", OC::$WEBROOT."/themes/$theme/core/$script.js" );
+
+ }elseif(is_file(OC::$SERVERROOT."/core/$script$fext.js" )){
+ $page->append( "jsfiles", OC::$WEBROOT."/core/$script$fext.js" );
+ }else{
$page->append( "jsfiles", OC::$WEBROOT."/core/$script.js" );
+
}
}
+ // Add the css files
foreach(OC_Util::$styles as $style){
- if(is_file(OC::$SERVERROOT."/apps/$style.css" )){
+ if(is_file(OC::$SERVERROOT."/apps/$style$fext.css" )){
+ $page->append( "cssfiles", OC::$WEBROOT."/apps/$style$fext.css" );
+ }elseif(is_file(OC::$SERVERROOT."/apps/$style.css" )){
$page->append( "cssfiles", OC::$WEBROOT."/apps/$style.css" );
- }
- elseif(is_file(OC::$SERVERROOT."/$style.css" )){
+ }elseif(is_file(OC::$SERVERROOT."/$style$fext.css" )){
+ $page->append( "cssfiles", OC::$WEBROOT."/$style$fext.css" );
+ }elseif(is_file(OC::$SERVERROOT."/$style.css" )){
$page->append( "cssfiles", OC::$WEBROOT."/$style.css" );
- }
- else{
+ }elseif(is_file(OC::$SERVERROOT."/core/$style$fext.css" )){
+ $page->append( "cssfiles", OC::$WEBROOT."/core/$style$fext.css" );
+ }else{
$page->append( "cssfiles", OC::$WEBROOT."/core/$style.css" );
}
}
-
+ // Add the theme css files. you can override the default values here
+ if(!empty($theme)) {
+ foreach(OC_Util::$styles as $style){
+ if(is_file(OC::$SERVERROOT."/themes/$theme/apps/$style$fext.css" )){
+ $page->append( "cssfiles", OC::$WEBROOT."/themes/$theme/apps/$style$fext.css" );
+ }elseif(is_file(OC::$SERVERROOT."/themes/$theme/apps/$style.css" )){
+ $page->append( "cssfiles", OC::$WEBROOT."/themes/$theme/apps/$style.css" );
+ }elseif(is_file(OC::$SERVERROOT."/themes/$theme/$style$fext.css" )){
+ $page->append( "cssfiles", OC::$WEBROOT."/themes/$theme/$style$fext.css" );
+ }elseif(is_file(OC::$SERVERROOT."/themes/$theme/$style.css" )){
+ $page->append( "cssfiles", OC::$WEBROOT."/themes/$theme/$style.css" );
+ }elseif(is_file(OC::$SERVERROOT."/themes/$theme/core/$style$fext.css" )){
+ $page->append( "cssfiles", OC::$WEBROOT."/themes/$theme/core/$style$fext.css" );
+ }elseif(is_file(OC::$SERVERROOT."/themes/$theme/core/$style.css" )){
+ $page->append( "cssfiles", OC::$WEBROOT."/themes/$theme/core/$style.css" );
+ }
+ }
+ }
+
// Add custom headers
$page->assign('headers',$this->headers);
foreach(OC_Util::$headers as $header){