Merge branch 'master' into sabredav_1.6
This commit is contained in:
commit
8f8d486f35
12 changed files with 248 additions and 187 deletions
|
@ -77,5 +77,7 @@ $(document).ready(function(){
|
|||
if(typeof FileActions !== 'undefined'){
|
||||
FileActions.register('text/vcard','importaddressbook', '', Contacts_Import.importdialog);
|
||||
FileActions.setDefault('text/vcard','importaddressbook');
|
||||
FileActions.register('text/x-vcard','importaddressbook', '', Contacts_Import.importdialog);
|
||||
FileActions.setDefault('text/x-vcard','importaddressbook');
|
||||
};
|
||||
});
|
|
@ -5,7 +5,7 @@
|
|||
left: 12.5em;
|
||||
}
|
||||
#editorwrapper{
|
||||
position: absoloute;
|
||||
position: absolute;
|
||||
height: 0;
|
||||
width: 0;
|
||||
top: 41px;
|
||||
|
|
|
@ -37,10 +37,12 @@ if($_POST) {
|
|||
$maxZipInputSize=$_POST['maxZipInputSize'];
|
||||
OC_Preferences::setValue('', 'files', 'maxZipInputSize', OC_Helper::computerFileSize($maxZipInputSize));
|
||||
}
|
||||
OC_Preferences::setValue('', 'files', 'allowZipDownload', isset($_POST['allowZipDownload']));
|
||||
}else{
|
||||
$upload_max_filesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize'));
|
||||
$post_max_size = OC_Helper::computerFileSize(ini_get('post_max_size'));
|
||||
$maxUploadFilesize = min($upload_max_filesize, $post_max_size);
|
||||
$allowZipDownload = intval(OC_Preferences::getValue('', 'files', 'allowZipDownload', 1));
|
||||
$maxZipInputSize = OC_Helper::humanfilesize(OC_Preferences::getValue('', 'files', 'maxZipInputSize', OC_Helper::computerFileSize('800 MB')));
|
||||
}
|
||||
|
||||
|
@ -49,5 +51,6 @@ OC_App::setActiveNavigationEntry( "files_administration" );
|
|||
$tmpl = new OC_Template( 'files', 'admin' );
|
||||
$tmpl->assign( 'htaccessWorking', $htaccessWorking );
|
||||
$tmpl->assign( 'uploadMaxFilesize', $maxUploadFilesize);
|
||||
$tmpl->assign( 'allowZipDownload', $allowZipDownload);
|
||||
$tmpl->assign( 'maxZipInputSize', $maxZipInputSize);
|
||||
return $tmpl->fetchPage();
|
|
@ -1,15 +1,23 @@
|
|||
function switchPublicFolder()
|
||||
function switchPublicFolder()
|
||||
{
|
||||
var publicEnable = $('#publicEnable').is(':checked');
|
||||
var sharingaimGroup = $('input:radio[name=sharingaim]'); //find all radiobuttons of that group
|
||||
$.each(sharingaimGroup, function(index, sharingaimItem) {
|
||||
sharingaimItem.disabled = !publicEnable; //set all buttons to the correct state
|
||||
});
|
||||
var publicEnable = $('#publicEnable').is(':checked');
|
||||
var sharingaimGroup = $('input:radio[name=sharingaim]'); //find all radiobuttons of that group
|
||||
$.each(sharingaimGroup, function(index, sharingaimItem) {
|
||||
sharingaimItem.disabled = !publicEnable; //set all buttons to the correct state
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
switchPublicFolder(); // Execute the function after loading DOM tree
|
||||
$('#publicEnable').click(function(){
|
||||
switchPublicFolder(); // To get rid of onClick()
|
||||
});
|
||||
switchPublicFolder(); // Execute the function after loading DOM tree
|
||||
$('#publicEnable').click(function(){
|
||||
switchPublicFolder(); // To get rid of onClick()
|
||||
});
|
||||
|
||||
$('#allowZipDownload').bind('change', function() {
|
||||
if($('#allowZipDownload').attr('checked')) {
|
||||
$('#maxZipInputSize').removeAttr('disabled');
|
||||
} else {
|
||||
$('#maxZipInputSize').attr('disabled', 'disabled');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -106,7 +106,7 @@ FileActions={
|
|||
element.hide();
|
||||
parent.parent().children().last().append(element);
|
||||
}
|
||||
$('#fileList .action').css('-o-transition-property','none');//temporarly disable
|
||||
$('#fileList .action').css('-o-transition-property','none');//temporarly disable
|
||||
$('#fileList .action').fadeIn(200,function(){
|
||||
$('#fileList .action').css('-o-transition-property','opacity');
|
||||
});
|
||||
|
@ -128,8 +128,15 @@ FileActions={
|
|||
}
|
||||
}
|
||||
|
||||
FileActions.register('all','Download',function(){return OC.imagePath('core','actions/download')},function(filename){
|
||||
window.location='ajax/download.php?files='+encodeURIComponent(filename)+'&dir='+encodeURIComponent($('#dir').val());
|
||||
$(document).ready(function(){
|
||||
if($('#allowZipDownload').val() == 1){
|
||||
var downloadScope = 'all';
|
||||
} else {
|
||||
var downloadScope = 'file';
|
||||
}
|
||||
FileActions.register(downloadScope,'Download',function(){return OC.imagePath('core','actions/download')},function(filename){
|
||||
window.location='ajax/download.php?files='+encodeURIComponent(filename)+'&dir='+encodeURIComponent($('#dir').val());
|
||||
});
|
||||
});
|
||||
|
||||
FileActions.register('all','Delete',function(){return OC.imagePath('core','actions/delete')},function(filename){
|
||||
|
@ -144,4 +151,4 @@ FileActions.register('dir','Open','',function(filename){
|
|||
window.location='index.php?dir='+encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+encodeURIComponent(filename);
|
||||
});
|
||||
|
||||
FileActions.setDefault('dir','Open');
|
||||
FileActions.setDefault('dir','Open');
|
||||
|
|
|
@ -6,7 +6,10 @@
|
|||
<?php if($_['htaccessWorking']):?>
|
||||
<label for="maxUploadSize"><?php echo $l->t( 'Maximum upload size' ); ?> </label><input name='maxUploadSize' id="maxUploadSize" value='<?php echo $_['uploadMaxFilesize'] ?>'/><br/>
|
||||
<?php endif;?>
|
||||
<label for="maxZipInputSize"><?php echo $l->t( 'Maximum input size for zip files (affects folder- and multi-file download)' ); ?> </label><input name="maxZipInputSize" id="maxZipInputSize" value='<?php echo $_['maxZipInputSize'] ?>'/><br/>
|
||||
<input type="checkbox" name="allowZipDownload" id="allowZipDownload" value="1" title="<?php echo $l->t( 'Needed for multi-file and folder downloads.' ); ?>"<?php if ($_['allowZipDownload']) echo ' checked="checked"'; ?> /> <label for="allowZipDownload"><?php echo $l->t( 'Enable ZIP-download' ); ?></label> <br/>
|
||||
<fieldset class="personalblock">
|
||||
<label for="maxZipInputSize"><?php echo $l->t( 'Maximum input size for ZIP files:' ); ?> </label><input name="maxZipInputSize" id="maxZipInputSize" value='<?php echo $_['maxZipInputSize'] ?>' title="<?php echo $l->t( '0 is unlimited' ); ?>"<?php if (!$_['allowZipDownload']) echo ' disabled="disabled"'; ?> /><br/>
|
||||
</fieldset>
|
||||
<input type="submit" value="Save"/>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
|
|
@ -40,7 +40,9 @@
|
|||
<?php if(!isset($_['readonly']) || !$_['readonly']) { ?><input type="checkbox" id="select_all" /><?php } ?>
|
||||
<span class='name'><?php echo $l->t( 'Name' ); ?></span>
|
||||
<span class='selectedActions'>
|
||||
<a href="" title="<?php echo $l->t('Download')?>" class="download"><img class='svg' alt="Download" src="<?php echo image_path("core", "actions/download.svg"); ?>" /></a>
|
||||
<?php if(OC_Preferences::getValue('', 'files', 'allowZipDownload', 1)) : ?>
|
||||
<a href="" title="<?php echo $l->t('Download')?>" class="download"><img class='svg' alt="Download" src="<?php echo image_path("core", "actions/download.svg"); ?>" /></a>
|
||||
<?php endif; ?>
|
||||
<a href="" title="Share" class="share"><img class='svg' alt="Share" src="<?php echo image_path("core", "actions/share.svg"); ?>" /></a>
|
||||
</span>
|
||||
</th>
|
||||
|
@ -66,3 +68,6 @@
|
|||
<?php echo $l->t('Current scanning');?> <span id='scan-current'></spann>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- config hints for javascript -->
|
||||
<input type="hidden" name="allowZipDownload" id="allowZipDownload" value="<?php echo OC_Preferences::getValue('', 'files', 'allowZipDownload', 1); ?>" />
|
85
lib/base.php
85
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','&');
|
||||
|
||||
//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','&');
|
||||
|
||||
//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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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'
|
||||
);
|
||||
|
|
255
lib/template.php
255
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();
|
||||
|
|
Loading…
Reference in a new issue