2012-06-18 17:04:35 +04: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 17:22:01 +04:00
|
|
|
public function __construct( $renderas ) {
|
2012-06-18 17:04:35 +04:00
|
|
|
// Decide which page we show
|
2012-06-21 23:19:39 +04:00
|
|
|
|
2012-09-07 17:22:01 +04:00
|
|
|
if( $renderas == 'user' ) {
|
2012-06-18 17:04:35 +04:00
|
|
|
parent::__construct( 'core', 'layout.user' );
|
2012-11-04 14:10:46 +04:00
|
|
|
if(in_array(OC_APP::getCurrentApp(), array('settings','admin', 'help'))!==false) {
|
2013-02-28 01:55:39 +04:00
|
|
|
$this->assign('bodyid', 'body-settings');
|
2012-06-18 17:04:35 +04:00
|
|
|
}else{
|
2013-02-28 01:55:39 +04:00
|
|
|
$this->assign('bodyid', 'body-user');
|
2012-06-18 17:04:35 +04:00
|
|
|
}
|
|
|
|
|
2013-07-26 14:20:11 +04:00
|
|
|
// display avatars if they are enabled
|
|
|
|
if (OC_Config::getValue('avatar') === 'gravatar' || OC_Config::getValue('avatar') === 'local') {
|
|
|
|
$this->assign('avatar', '<img src="'.OC_Avatar::get(OC_User::getUser(), 32).'">');
|
|
|
|
}
|
|
|
|
|
2013-04-24 20:47:38 +04: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 17:04:35 +04:00
|
|
|
// Add navigation entry
|
2013-02-07 21:07:27 +04:00
|
|
|
$this->assign( 'application', '', false );
|
2012-06-18 17:04:35 +04:00
|
|
|
$navigation = OC_App::getNavigation();
|
2013-02-28 01:55:39 +04:00
|
|
|
$this->assign( 'navigation', $navigation);
|
|
|
|
$this->assign( 'settingsnavigation', OC_App::getSettingsNavigation());
|
2012-06-18 17:04:35 +04:00
|
|
|
foreach($navigation as $entry) {
|
|
|
|
if ($entry['active']) {
|
2013-02-28 01:55:39 +04:00
|
|
|
$this->assign( 'application', $entry['name'] );
|
2012-06-18 17:04:35 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-02-07 21:07:27 +04:00
|
|
|
$user_displayname = OC_User::getDisplayName();
|
|
|
|
$this->assign( 'user_displayname', $user_displayname );
|
2013-03-02 19:09:36 +04:00
|
|
|
$this->assign( 'user_uid', OC_User::getUser() );
|
2013-02-23 00:39:44 +04:00
|
|
|
} else if ($renderas == 'guest' || $renderas == 'error') {
|
2012-08-29 19:54:31 +04:00
|
|
|
parent::__construct('core', 'layout.guest');
|
|
|
|
} else {
|
|
|
|
parent::__construct('core', 'layout.base');
|
2012-06-18 17:04:35 +04:00
|
|
|
}
|
2013-04-05 01:33:05 +04:00
|
|
|
$versionParameter = '?v=' . md5(implode(OC_Util::getVersion()));
|
2012-06-18 17:35:04 +04:00
|
|
|
// Add the js files
|
|
|
|
$jsfiles = self::findJavascriptFiles(OC_Util::$scripts);
|
2012-06-18 17:04:35 +04:00
|
|
|
$this->assign('jsfiles', array(), false);
|
2013-02-23 00:39:44 +04:00
|
|
|
if (OC_Config::getValue('installed', false) && $renderas!='error') {
|
2013-05-11 23:07:05 +04:00
|
|
|
$this->append( 'jsfiles', OC_Helper::linkToRoute('js_config') . $versionParameter);
|
2013-02-07 11:09:53 +04:00
|
|
|
}
|
2012-09-07 18:42:46 +04:00
|
|
|
if (!empty(OC_Util::$core_scripts)) {
|
2013-03-19 15:35:31 +04:00
|
|
|
$this->append( 'jsfiles', OC_Helper::linkToRemoteBase('core.js', false) . $versionParameter);
|
2012-09-07 18:42:46 +04:00
|
|
|
}
|
2012-06-18 17:04:35 +04:00
|
|
|
foreach($jsfiles as $info) {
|
|
|
|
$root = $info[0];
|
|
|
|
$web = $info[1];
|
|
|
|
$file = $info[2];
|
2013-03-19 15:35:31 +04:00
|
|
|
$this->append( 'jsfiles', $web.'/'.$file . $versionParameter);
|
2012-06-18 17:04:35 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add the css files
|
2012-06-18 17:35:04 +04:00
|
|
|
$cssfiles = self::findStylesheetFiles(OC_Util::$styles);
|
2012-06-18 17:04:35 +04:00
|
|
|
$this->assign('cssfiles', array());
|
2012-09-07 18:42:46 +04:00
|
|
|
if (!empty(OC_Util::$core_styles)) {
|
2013-03-19 15:35:31 +04:00
|
|
|
$this->append( 'cssfiles', OC_Helper::linkToRemoteBase('core.css', false) . $versionParameter);
|
2012-09-07 18:42:46 +04:00
|
|
|
}
|
2012-06-18 17:04:35 +04:00
|
|
|
foreach($cssfiles as $info) {
|
|
|
|
$root = $info[0];
|
|
|
|
$web = $info[1];
|
|
|
|
$file = $info[2];
|
2012-06-21 23:19:39 +04:00
|
|
|
|
2013-04-19 13:08:26 +04:00
|
|
|
$this->append( 'cssfiles', $web.'/'.$file . $versionParameter);
|
2012-06-18 17:04:35 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-07 17:22:01 +04:00
|
|
|
static public function findStylesheetFiles($styles) {
|
2012-06-18 17:04:35 +04:00
|
|
|
// Read the selected theme from the config file
|
2013-04-24 15:45:40 +04:00
|
|
|
$theme = OC_Util::getTheme();
|
2012-06-18 17:04:35 +04:00
|
|
|
|
|
|
|
// Read the detected formfactor and use the right file name.
|
|
|
|
$fext = self::getFormFactorExtension();
|
|
|
|
|
2013-03-17 02:02:51 +04: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 17:04:35 +04:00
|
|
|
}
|
|
|
|
|
2012-09-07 17:22:01 +04:00
|
|
|
static public function findJavascriptFiles($scripts) {
|
2012-06-18 17:04:35 +04:00
|
|
|
// Read the selected theme from the config file
|
2013-04-24 15:45:40 +04:00
|
|
|
$theme = OC_Util::getTheme();
|
2012-06-18 17:04:35 +04:00
|
|
|
|
|
|
|
// Read the detected formfactor and use the right file name.
|
|
|
|
$fext = self::getFormFactorExtension();
|
|
|
|
|
2013-03-17 02:02:51 +04: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 17:04:35 +04:00
|
|
|
}
|
|
|
|
}
|