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 {
|
2014-02-06 19:30:58 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $renderas
|
|
|
|
*/
|
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-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-12-09 18:47:51 +04:00
|
|
|
$this->assign( 'appsmanagement_active', strpos(OC_Request::requestUri(), OC_Helper::linkToRoute('settings_apps')) === 0 );
|
2013-09-11 09:11:33 +04:00
|
|
|
$this->assign('enableAvatars', \OC_Config::getValue('enable_avatars', true));
|
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
|
|
|
}
|
2013-08-15 10:49:19 +04:00
|
|
|
if (!empty(OC_Util::$coreScripts)) {
|
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());
|
2013-08-15 10:49:19 +04:00
|
|
|
if (!empty(OC_Util::$coreStyles)) {
|
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
|
|
|
}
|
|
|
|
}
|