2012-06-18 13:04:35 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl>
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class OC_TemplateLayout extends OC_Template {
|
2012-09-07 13:22:01 +00:00
|
|
|
public function __construct( $renderas ) {
|
2012-06-18 13:04:35 +00:00
|
|
|
// Decide which page we show
|
2012-06-21 19:19:39 +00:00
|
|
|
|
2012-09-07 13:22:01 +00:00
|
|
|
if( $renderas == 'user' ) {
|
2012-06-18 13:04:35 +00:00
|
|
|
parent::__construct( 'core', 'layout.user' );
|
2012-11-04 10:10:46 +00:00
|
|
|
if(in_array(OC_APP::getCurrentApp(), array('settings','admin', 'help'))!==false) {
|
2013-02-27 21:55:39 +00:00
|
|
|
$this->assign('bodyid', 'body-settings');
|
2012-06-18 13:04:35 +00:00
|
|
|
}else{
|
2013-02-27 21:55:39 +00:00
|
|
|
$this->assign('bodyid', 'body-user');
|
2012-06-18 13:04:35 +00:00
|
|
|
}
|
|
|
|
|
2013-04-24 16:47:38 +00:00
|
|
|
// Update notification
|
|
|
|
if(OC_Config::getValue('updatechecker', true) === true) {
|
|
|
|
$data=OC_Updater::check();
|
|
|
|
if(isset($data['version']) && $data['version'] != '' and $data['version'] !== Array() && OC_User::isAdminUser(OC_User::getUser())) {
|
|
|
|
$this->assign('updateAvailable', true);
|
|
|
|
$this->assign('updateVersion', $data['versionstring']);
|
|
|
|
$this->assign('updateLink', $data['web']);
|
|
|
|
} else {
|
|
|
|
$this->assign('updateAvailable', false); // No update available or not an admin user
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$this->assign('updateAvailable', false); // Update check is disabled
|
|
|
|
}
|
|
|
|
|
2012-06-18 13:04:35 +00:00
|
|
|
// Add navigation entry
|
2013-02-07 17:07:27 +00:00
|
|
|
$this->assign( 'application', '', false );
|
2012-06-18 13:04:35 +00:00
|
|
|
$navigation = OC_App::getNavigation();
|
2013-02-27 21:55:39 +00:00
|
|
|
$this->assign( 'navigation', $navigation);
|
|
|
|
$this->assign( 'settingsnavigation', OC_App::getSettingsNavigation());
|
2012-06-18 13:04:35 +00:00
|
|
|
foreach($navigation as $entry) {
|
|
|
|
if ($entry['active']) {
|
2013-02-27 21:55:39 +00:00
|
|
|
$this->assign( 'application', $entry['name'] );
|
2012-06-18 13:04:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-02-07 17:07:27 +00:00
|
|
|
$user_displayname = OC_User::getDisplayName();
|
|
|
|
$this->assign( 'user_displayname', $user_displayname );
|
2013-03-02 15:09:36 +00:00
|
|
|
$this->assign( 'user_uid', OC_User::getUser() );
|
2013-02-22 20:39:44 +00:00
|
|
|
} else if ($renderas == 'guest' || $renderas == 'error') {
|
2012-08-29 15:54:31 +00:00
|
|
|
parent::__construct('core', 'layout.guest');
|
|
|
|
} else {
|
|
|
|
parent::__construct('core', 'layout.base');
|
2012-06-18 13:04:35 +00:00
|
|
|
}
|
2013-04-04 21:33:05 +00:00
|
|
|
$versionParameter = '?v=' . md5(implode(OC_Util::getVersion()));
|
2012-06-18 13:35:04 +00:00
|
|
|
// Add the js files
|
|
|
|
$jsfiles = self::findJavascriptFiles(OC_Util::$scripts);
|
2012-06-18 13:04:35 +00:00
|
|
|
$this->assign('jsfiles', array(), false);
|
2013-02-22 20:39:44 +00:00
|
|
|
if (OC_Config::getValue('installed', false) && $renderas!='error') {
|
2013-05-11 19:07:05 +00:00
|
|
|
$this->append( 'jsfiles', OC_Helper::linkToRoute('js_config') . $versionParameter);
|
2013-02-07 07:09:53 +00:00
|
|
|
}
|
2012-09-07 14:42:46 +00:00
|
|
|
if (!empty(OC_Util::$core_scripts)) {
|
2013-03-19 11:35:31 +00:00
|
|
|
$this->append( 'jsfiles', OC_Helper::linkToRemoteBase('core.js', false) . $versionParameter);
|
2012-09-07 14:42:46 +00:00
|
|
|
}
|
2012-06-18 13:04:35 +00:00
|
|
|
foreach($jsfiles as $info) {
|
|
|
|
$root = $info[0];
|
|
|
|
$web = $info[1];
|
|
|
|
$file = $info[2];
|
2013-03-19 11:35:31 +00:00
|
|
|
$this->append( 'jsfiles', $web.'/'.$file . $versionParameter);
|
2012-06-18 13:04:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add the css files
|
2012-06-18 13:35:04 +00:00
|
|
|
$cssfiles = self::findStylesheetFiles(OC_Util::$styles);
|
2012-06-18 13:04:35 +00:00
|
|
|
$this->assign('cssfiles', array());
|
2012-09-07 14:42:46 +00:00
|
|
|
if (!empty(OC_Util::$core_styles)) {
|
2013-03-19 11:35:31 +00:00
|
|
|
$this->append( 'cssfiles', OC_Helper::linkToRemoteBase('core.css', false) . $versionParameter);
|
2012-09-07 14:42:46 +00:00
|
|
|
}
|
2012-06-18 13:04:35 +00:00
|
|
|
foreach($cssfiles as $info) {
|
|
|
|
$root = $info[0];
|
|
|
|
$web = $info[1];
|
|
|
|
$file = $info[2];
|
2012-06-21 19:19:39 +00:00
|
|
|
|
2013-04-19 09:08:26 +00:00
|
|
|
$this->append( 'cssfiles', $web.'/'.$file . $versionParameter);
|
2012-06-18 13:04:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-07 13:22:01 +00:00
|
|
|
static public function findStylesheetFiles($styles) {
|
2012-06-18 13:04:35 +00:00
|
|
|
// Read the selected theme from the config file
|
2013-04-24 11:45:40 +00:00
|
|
|
$theme = OC_Util::getTheme();
|
2012-06-18 13:04:35 +00:00
|
|
|
|
|
|
|
// Read the detected formfactor and use the right file name.
|
|
|
|
$fext = self::getFormFactorExtension();
|
|
|
|
|
2013-03-16 22:02:51 +00:00
|
|
|
$locator = new \OC\Template\CSSResourceLocator( $theme, $fext,
|
|
|
|
array( OC::$SERVERROOT => OC::$WEBROOT ),
|
|
|
|
array( OC::$THIRDPARTYROOT => OC::$THIRDPARTYWEBROOT ));
|
|
|
|
$locator->find($styles);
|
|
|
|
return $locator->getResources();
|
2012-06-18 13:04:35 +00:00
|
|
|
}
|
|
|
|
|
2012-09-07 13:22:01 +00:00
|
|
|
static public function findJavascriptFiles($scripts) {
|
2012-06-18 13:04:35 +00:00
|
|
|
// Read the selected theme from the config file
|
2013-04-24 11:45:40 +00:00
|
|
|
$theme = OC_Util::getTheme();
|
2012-06-18 13:04:35 +00:00
|
|
|
|
|
|
|
// Read the detected formfactor and use the right file name.
|
|
|
|
$fext = self::getFormFactorExtension();
|
|
|
|
|
2013-03-16 22:02:51 +00:00
|
|
|
$locator = new \OC\Template\JSResourceLocator( $theme, $fext,
|
|
|
|
array( OC::$SERVERROOT => OC::$WEBROOT ),
|
|
|
|
array( OC::$THIRDPARTYROOT => OC::$THIRDPARTYWEBROOT ));
|
|
|
|
$locator->find($scripts);
|
|
|
|
return $locator->getResources();
|
2012-06-18 13:04:35 +00:00
|
|
|
}
|
|
|
|
}
|