summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGeorg Ehrke <dev@georgswebsite.de>2012-03-21 09:42:53 +0100
committerGeorg Ehrke <dev@georgswebsite.de>2012-03-21 09:42:53 +0100
commit8f8d486f35c8f1d290e3db2ba7ae42dcb380d1dd (patch)
treefd4dd90a7f00dc7ffa3549889819bc1e1dbd53d2 /lib
parent9848bc33e5b78aaf2fa07554fdd3c78d34ec0b67 (diff)
parent19bbb61b20e1e9a7c7d4f9ef645ab65fcc453416 (diff)
downloadnextcloud-server-8f8d486f35c8f1d290e3db2ba7ae42dcb380d1dd.tar.gz
nextcloud-server-8f8d486f35c8f1d290e3db2ba7ae42dcb380d1dd.zip
Merge branch 'master' into sabredav_1.6
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php85
-rw-r--r--lib/files.php21
-rw-r--r--lib/helper.php4
-rw-r--r--lib/mimetypes.fixlist.php8
-rw-r--r--lib/template.php255
5 files changed, 203 insertions, 170 deletions
diff --git a/lib/base.php b/lib/base.php
index 9995544f14e..54cc9f2c731 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -114,42 +114,7 @@ class OC{
return($mode);
}
- public static function init(){
- // register autoloader
- spl_autoload_register(array('OC','autoload'));
-
- // set some stuff
- //ob_start();
- error_reporting(E_ALL | E_STRICT);
- if (defined('DEBUG') && DEBUG){
- ini_set('display_errors', 1);
- }
-
- date_default_timezone_set('Europe/Berlin');
- ini_set('arg_separator.output','&amp;');
-
- //set http auth headers for apache+php-cgi work around
- if (isset($_SERVER['HTTP_AUTHORIZATION']) && preg_match('/Basic\s+(.*)$/i', $_SERVER['HTTP_AUTHORIZATION'], $matches))
- {
- list($name, $password) = explode(':', base64_decode($matches[1]));
- $_SERVER['PHP_AUTH_USER'] = strip_tags($name);
- $_SERVER['PHP_AUTH_PW'] = strip_tags($password);
- }
-
- //set http auth headers for apache+php-cgi work around if variable gets renamed by apache
- if (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION']) && preg_match('/Basic\s+(.*)$/i', $_SERVER['REDIRECT_HTTP_AUTHORIZATION'], $matches))
- {
- list($name, $password) = explode(':', base64_decode($matches[1]));
- $_SERVER['PHP_AUTH_USER'] = strip_tags($name);
- $_SERVER['PHP_AUTH_PW'] = strip_tags($password);
- }
-
- // register the stream wrappers
- require_once('streamwrappers.php');
- stream_wrapper_register("fakedir", "OC_FakeDirStream");
- stream_wrapper_register('static', 'OC_StaticStreamWrapper');
- stream_wrapper_register('close', 'OC_CloseStreamWrapper');
-
+ public static function initPaths(){
// calculate the documentroot
OC::$DOCUMENTROOT=realpath($_SERVER['DOCUMENT_ROOT']);
OC::$SERVERROOT=str_replace("\\",'/',substr(__FILE__,0,-13));
@@ -211,14 +176,18 @@ class OC{
get_include_path().PATH_SEPARATOR.
OC::$SERVERROOT
);
+ }
+ public static function checkInstalled() {
// Redirect to installer if not installed
if (!OC_Config::getValue('installed', false) && OC::$SUBURI != '/index.php') {
$url = 'http://'.$_SERVER['SERVER_NAME'].OC::$WEBROOT.'/index.php';
header("Location: $url");
exit();
}
+ }
+ public static function checkSSL() {
// redirect to https site if configured
if( OC_Config::getValue( "forcessl", false )){
ini_set("session.cookie_secure", "on");
@@ -228,7 +197,9 @@ class OC{
exit();
}
}
+ }
+ public static function checkUpgrade() {
if(OC_Config::getValue('installed', false)){
$installedVersion=OC_Config::getValue('version','0.0.0');
$currentVersion=implode('.',OC_Util::getVersion());
@@ -250,6 +221,48 @@ class OC{
OC_App::updateApps();
}
+ }
+
+ public static function init(){
+ // register autoloader
+ spl_autoload_register(array('OC','autoload'));
+
+ // set some stuff
+ //ob_start();
+ error_reporting(E_ALL | E_STRICT);
+ if (defined('DEBUG') && DEBUG){
+ ini_set('display_errors', 1);
+ }
+
+ date_default_timezone_set('Europe/Berlin');
+ ini_set('arg_separator.output','&amp;');
+
+ //set http auth headers for apache+php-cgi work around
+ if (isset($_SERVER['HTTP_AUTHORIZATION']) && preg_match('/Basic\s+(.*)$/i', $_SERVER['HTTP_AUTHORIZATION'], $matches))
+ {
+ list($name, $password) = explode(':', base64_decode($matches[1]));
+ $_SERVER['PHP_AUTH_USER'] = strip_tags($name);
+ $_SERVER['PHP_AUTH_PW'] = strip_tags($password);
+ }
+
+ //set http auth headers for apache+php-cgi work around if variable gets renamed by apache
+ if (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION']) && preg_match('/Basic\s+(.*)$/i', $_SERVER['REDIRECT_HTTP_AUTHORIZATION'], $matches))
+ {
+ list($name, $password) = explode(':', base64_decode($matches[1]));
+ $_SERVER['PHP_AUTH_USER'] = strip_tags($name);
+ $_SERVER['PHP_AUTH_PW'] = strip_tags($password);
+ }
+
+ // register the stream wrappers
+ require_once('streamwrappers.php');
+ stream_wrapper_register("fakedir", "OC_FakeDirStream");
+ stream_wrapper_register('static', 'OC_StaticStreamWrapper');
+ stream_wrapper_register('close', 'OC_CloseStreamWrapper');
+
+ self::initPaths();
+ self::checkInstalled();
+ self::checkSSL();
+ self::checkUpgrade();
ini_set('session.cookie_httponly','1;');
session_start();
diff --git a/lib/files.php b/lib/files.php
index 50223df1d36..662f0b59724 100644
--- a/lib/files.php
+++ b/lib/files.php
@@ -59,7 +59,7 @@ class OC_Files {
}
if(is_array($files)){
- self::checkZipInputSize($dir,$files);
+ self::validateZipDownload($dir,$files);
$executionTime = intval(ini_get('max_execution_time'));
set_time_limit(0);
$zip = new ZipArchive();
@@ -80,7 +80,7 @@ class OC_Files {
$zip->close();
set_time_limit($executionTime);
}elseif(OC_Filesystem::is_dir($dir.'/'.$files)){
- self::checkZipInputSize($dir,$files);
+ self::validateZipDownload($dir,$files);
$executionTime = intval(ini_get('max_execution_time'));
set_time_limit(0);
$zip = new ZipArchive();
@@ -223,7 +223,22 @@ class OC_Files {
* @param dir $dir
* @param files $files
*/
- static function checkZipInputSize($dir, $files) {
+ static function validateZipDownload($dir, $files) {
+ if(!OC_Preferences::getValue('', 'files', 'allowZipDownload', 1)) {
+ $l = new OC_L10N('files');
+ header("HTTP/1.0 409 Conflict");
+ $tmpl = new OC_Template( '', 'error', 'user' );
+ $errors = array(
+ array(
+ 'error' => $l->t('ZIP download is turned off.'),
+ 'hint' => $l->t('Files need to be downloaded one by one.') . '<br/><a href="javascript:history.back()">' . $l->t('Back to Files') . '</a>',
+ )
+ );
+ $tmpl->assign('errors', $errors);
+ $tmpl->printPage();
+ exit;
+ }
+
$zipLimit = OC_Preferences::getValue('', 'files', 'maxZipInputSize', OC_Helper::computerFileSize('800 MB'));
if($zipLimit > 0) {
$totalsize = 0;
diff --git a/lib/helper.php b/lib/helper.php
index 0c6c73aa76b..75942f092cf 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -284,9 +284,7 @@ class OC_Helper {
$isWrapped=(strpos($path,'://')!==false) and (substr($path,0,7)=='file://');
$mimeType='application/octet-stream';
if ($mimeType=='application/octet-stream') {
- if(count(self::$mimetypes)>0){
- self::$mimetypes = include('mimetypes.fixlist.php');
- }
+ self::$mimetypes = include('mimetypes.fixlist.php');
$extention=strtolower(strrchr(basename($path), "."));
$extention=substr($extention,1);//remove leading .
$mimeType=(isset(self::$mimetypes[$extention]))?self::$mimetypes[$extention]:'application/octet-stream';
diff --git a/lib/mimetypes.fixlist.php b/lib/mimetypes.fixlist.php
index 1c6acbc4438..51f12dbcc29 100644
--- a/lib/mimetypes.fixlist.php
+++ b/lib/mimetypes.fixlist.php
@@ -10,5 +10,11 @@ return array(
'pl'=>'text/x-script.perl',
'py'=>'text/x-script.phyton',
'vcf' => 'text/vcard',
- 'vcard' => 'text/vcard'
+ 'vcard' => 'text/vcard',
+ 'doc'=>'application/msword',
+ 'docx'=>'application/msword',
+ 'xls'=>'application/msexcel',
+ 'xlsx'=>'application/msexcel',
+ 'ppt'=>'application/mspowerpoint',
+ 'pptx'=>'application/mspowerpoint'
);
diff --git a/lib/template.php b/lib/template.php
index eea2925975c..5bcf52b9321 100644
--- a/lib/template.php
+++ b/lib/template.php
@@ -140,7 +140,7 @@ class OC_Template{
/**
* @brief Constructor
* @param $app app providing the template
- * @param $file name of the tempalte file (without suffix)
+ * @param $file name of the template file (without suffix)
* @param $renderas = ""; produce a full page
* @returns OC_Template object
*
@@ -151,10 +151,20 @@ class OC_Template{
* "admin".
*/
public function __construct( $app, $name, $renderas = "" ){
- // Read the selected theme from the config file
- $theme=OC_Config::getValue( "theme" );
+ // Set the private data
+ $this->renderas = $renderas;
+ $this->application = $app;
+ $this->vars = array();
+ $this->l10n = new OC_L10N($app);
- // Read the detected formfactor and use the right file name.
+ $this->findTemplate($name);
+ }
+
+ /**
+ * @brief Returns the formfactor extention for current formfactor
+ */
+ protected function getFormFactorExtension()
+ {
$formfactor=$_SESSION['formfactor'];
if($formfactor=='default') {
$fext='';
@@ -167,70 +177,79 @@ class OC_Template{
}else{
$fext='';
}
+ return $fext;
+ }
+ /**
+ * @brief find the template with the given name
+ * @param $name of the template file (without suffix)
+ *
+ * Will select the template file for the selected theme and formfactor.
+ * Checking all the possible locations.
+ */
+ protected function findTemplate($name)
+ {
+ // Read the selected theme from the config file
+ $theme=OC_Config::getValue( "theme" );
+
+ // Read the detected formfactor and use the right file name.
+ $fext = $this->getFormFactorExtension();
+
+ $app = $this->application;
// Check if it is a app template or not.
if( $app != "" ){
// Check if the app is in the app folder or in the root
if( file_exists( OC::$APPSROOT."/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::$APPSROOT."/apps/$app/templates/"."$name$fext.php" ){
- $template = OC::$APPSROOT."/apps/$app/templates/"."$name$fext.php";
- $path = OC::$APPSROOT."/apps/$app/templates/";
- }else{
- $template = OC::$APPSROOT."/apps/$app/templates/"."$name.php";
- $path = OC::$APPSROOT."/apps/$app/templates/";
+ if ($this->checkPathForTemplate(OC::$SERVERROOT."/themes/$theme/apps/$app/templates/", $name, $fext)) {
+ }elseif ($this->checkPathForTemplate(OC::$APPSROOT."/apps/$app/templates/", $name, $fext)) {
}
}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/";
- }elseif( file_exists( OC::$SERVERROOT."/$app/templates/"."$name.php" )){
- $template = OC::$SERVERROOT."/$app/templates/"."$name.php";
- $path = OC::$SERVERROOT."/$app/templates/";
+ if ($this->checkPathForTemplate(OC::$SERVERROOT."/themes/$theme/$app/templates/", $name, $fext)) {
+ }elseif ($this->checkPathForTemplate(OC::$SERVERROOT."/$app/templates/", $name, $fext)) {
}else{
- echo('template not found: template:'.$name.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT);
+ echo('template not found: template:'.$name.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT);
die();
}
- }
+ }
}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/";
+ if ($this->checkPathForTemplate(OC::$SERVERROOT."/themes/$theme/core/templates/", $name, $fext)) {
+ } elseif ($this->checkPathForTemplate(OC::$SERVERROOT."/core/templates/", $name, $fext)) {
}else{
- $template = OC::$SERVERROOT."/core/templates/"."$name.php";
- $path = OC::$SERVERROOT."/core/templates/";
+ echo('template not found: template:'.$name.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT);
+ die();
}
}
+ }
-
- // Set the private data
- $this->renderas = $renderas;
- $this->application = $app;
- $this->template = $template;
- $this->path = $path;
- $this->vars = array();
- $this->l10n = new OC_L10N($app);
+ /**
+ * @brief check Path For Template with and without $fext
+ * @param $path to check
+ * @param $name of the template file (without suffix)
+ * @param $fext formfactor extension
+ * @return bool true when found
+ *
+ * Will set $this->template and $this->path if there is a template at
+ * the specifief $path
+ */
+ protected function checkPathForTemplate($path, $name, $fext)
+ {
+ if ($name =='') return false;
+ $template = null;
+ if( is_file( $path.$name.$fext.'.php' )){
+ $template = $path.$name.$fext.'.php';
+ }elseif( is_file( $path.$name.'.php' )){
+ $template = $path.$name.'.php';
+ }
+ if ($template) {
+ $this->template = $template;
+ $this->path = $path;
+ return true;
+ }
+ return false;
}
/**
@@ -267,7 +286,7 @@ class OC_Template{
$this->vars[$key] = array( $value );
}
}
-
+
/**
* @brief Add a custom element to the header
* @param string tag tag name of the element
@@ -295,11 +314,25 @@ class OC_Template{
}
}
+ /*
+ * @brief append the $file-url if exist at $root
+ * @param $type of collection to use when appending
+ * @param $root path to check
+ * @param $web base for path
+ * @param $file the filename
+ */
+ public function appendIfExist($type, $root, $web, $file) {
+ if (is_file($root.'/'.$file)) {
+ $this->append( $type, $web.'/'.$file);
+ return true;
+ }
+ return false;
+ }
/**
* @brief Proceeds the template
* @returns content
*
- * This function proceeds the template. If $this->renderas is set, it will
+ * This function proceeds the template. If $this->renderas is set, it
* will produce a full page.
*/
public function fetchPage(){
@@ -329,68 +362,44 @@ 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='';
- }
+ $fext = $this->getFormFactorExtension();
// Add the core js files or the js files provided by the selected theme
foreach(OC_Util::$scripts as $script){
// Is it in 3rd party?
- if(is_file(OC::$THIRDPARTYROOT."/$script.js" )){
- $page->append( "jsfiles", OC::$THIRDPARTYWEBROOT."/$script.js" );
+ if($page->appendIfExist('jsfiles', OC::$THIRDPARTYROOT, OC::$THIRDPARTYWEBROOT, $script.'.js')) {
// Is it in apps and overwritten by the theme?
- }elseif(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($page->appendIfExist('jsfiles', OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/apps/$script$fext.js" )) {
+ }elseif($page->appendIfExist('jsfiles', OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/apps/$script.js" )) {
// Is it part of an app?
- }elseif(is_file(OC::$APPSROOT."/apps/$script$fext.js" )){
- $page->append( "jsfiles", OC::$APPSWEBROOT."/apps/$script$fext.js" );
- }elseif(is_file(OC::$APPSROOT."/apps/$script.js" )){
- $page->append( "jsfiles", OC::$APPSWEBROOT."/apps/$script.js" );
+ }elseif($page->appendIfExist('jsfiles', OC::$APPSROOT, OC::$APPSWEBROOT, "apps/$script$fext.js" )) {
+ }elseif($page->appendIfExist('jsfiles', OC::$APPSROOT, OC::$APPSWEBROOT, "apps/$script.js" )) {
// Is it in the owncloud root but overwritten by the theme?
- }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($page->appendIfExist('jsfiles', OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/$script$fext.js" )) {
+ }elseif($page->appendIfExist('jsfiles', OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/$script.js" )) {
+
// Is it in the owncloud root ?
- }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" );
+ }elseif($page->appendIfExist('jsfiles', OC::$SERVERROOT, OC::$WEBROOT, "$script$fext.js" )) {
+ }elseif($page->appendIfExist('jsfiles', OC::$SERVERROOT, OC::$WEBROOT, "$script.js" )) {
// Is in core but overwritten by a theme?
- }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($page->appendIfExist('jsfiles', OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/core/$script$fext.js" )) {
+ }elseif($page->appendIfExist('jsfiles', OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/core/$script.js" )) {
// Is it in core?
- }elseif(is_file(OC::$SERVERROOT."/core/$script$fext.js" )){
- $page->append( "jsfiles", OC::$WEBROOT."/core/$script$fext.js" );
- }elseif(is_file(OC::$SERVERROOT."/core/$script.js" )){
- $page->append( "jsfiles", OC::$WEBROOT."/core/$script.js" );
+ }elseif($page->appendIfExist('jsfiles', OC::$SERVERROOT, OC::$WEBROOT, "core/$script$fext.js" )) {
+ }elseif($page->appendIfExist('jsfiles', OC::$SERVERROOT, OC::$WEBROOT, "core/$script.js" )) {
}else{
- echo('js file not found: script:'.$script.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT);
+ echo('js file not found: script:'.$script.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT);
die();
}
@@ -398,54 +407,46 @@ class OC_Template{
// Add the css files
foreach(OC_Util::$styles as $style){
// is it in 3rdparty?
- if(is_file(OC::$THIRDPARTYROOT."/$style.css" )){
- $page->append( "cssfiles", OC::$THIRDPARTYWEBROOT."/$style.css" );
+ if($page->appendIfExist('cssfiles', OC::$THIRDPARTYROOT, OC::$THIRDPARTYWEBROOT, $style.'.css')) {
+
// or in apps?
- }elseif(is_file(OC::$APPSROOT."/apps/$style$fext.css" )){
- $page->append( "cssfiles", OC::$APPSWEBROOT."/apps/$style$fext.css" );
- }elseif(is_file(OC::$APPSROOT."/apps/$style.css" )){
- $page->append( "cssfiles", OC::$APPSWEBROOT."/apps/$style.css" );
+ }elseif($page->appendIfExist('cssfiles', OC::$APPSROOT, OC::$APPSWEBROOT, "apps/$style$fext.css" )) {
+ }elseif($page->appendIfExist('cssfiles', OC::$APPSROOT, OC::$APPSWEBROOT, "apps/$style.css" )) {
+
// or in the owncloud root?
- }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" );
- // or in core ?
- }elseif(is_file(OC::$SERVERROOT."/core/$style$fext.css" )){
- $page->append( "cssfiles", OC::$WEBROOT."/core/$style$fext.css" );
- }elseif(is_file(OC::$SERVERROOT."/core/$style.css" )){
- $page->append( "cssfiles", OC::$WEBROOT."/core/$style.css" );
+ }elseif($page->appendIfExist('cssfiles', OC::$SERVERROOT, OC::$WEBROOT, "$style$fext.css" )) {
+ }elseif($page->appendIfExist('cssfiles', OC::$SERVERROOT, OC::$WEBROOT, "$style.css" )) {
+
+ // or in core ?
+ }elseif($page->appendIfExist('cssfiles', OC::$SERVERROOT, OC::$WEBROOT, "core/$style$fext.css" )) {
+ }elseif($page->appendIfExist('cssfiles', OC::$SERVERROOT, OC::$WEBROOT, "core/$style.css" )) {
}else{
- echo('css file not found: style:'.$script.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT);
+ echo('css file not found: style:'.$script.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT);
die();
}
}
- // Add the theme css files. you can override the default values here
+ // 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" );
- }
- }
- }
-
+ foreach(OC_Util::$styles as $style){
+ if($page->appendIfExist('cssfiles', OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/apps/$style$fext.css" )) {
+ }elseif($page->appendIfExist('cssfiles', OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/apps/$style.css" )) {
+
+ }elseif($page->appendIfExist('cssfiles', OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/$style$fext.css" )) {
+ }elseif($page->appendIfExist('cssfiles', OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/$style.css" )) {
+
+ }elseif($page->appendIfExist('cssfiles', OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/core/$style$fext.css" )) {
+ }elseif($page->appendIfExist('cssfiles', OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/core/$style.css" )) {
+ }
+ }
+ }
+
// Add custom headers
$page->assign('headers',$this->headers);
foreach(OC_Util::$headers as $header){
$page->append('headers',$header);
}
-
+
// Add css files and js files
$page->assign( "content", $data );
return $page->fetchPage();