/** * @param string $renderAs * @param string $appId application id */ public function __construct($renderAs, $appId = '') { // yes - should be injected .... $this->config = \OC::$server->getConfig(); // Decide which page we show if ($renderAs == 'user') { parent::__construct('core', 'layout.user'); if (in_array(OC_App::getCurrentApp(), ['settings', 'admin', 'help']) !== false) { $this->assign('bodyid', 'body-settings'); } else { $this->assign('bodyid', 'body-user'); } // Update notification if ($this->config->getSystemValue('updatechecker', true) === true && OC_User::isAdminUser(OC_User::getUser())) { $updater = new \OC\Updater(\OC::$server->getHTTPHelper(), \OC::$server->getConfig()); $data = $updater->check(); if (isset($data['version']) && $data['version'] != '' and $data['version'] !== array()) { $this->assign('updateAvailable', true); $this->assign('updateVersion', $data['versionstring']); $this->assign('updateLink', $data['web']); \OCP\Util::addScript('core', 'update-notification'); } else { $this->assign('updateAvailable', false); // No update available or not an admin user } } else { $this->assign('updateAvailable', false); // Update check is disabled } // Add navigation entry $this->assign('application', ''); $this->assign('appid', $appId); $navigation = OC_App::getNavigation(); $this->assign('navigation', $navigation); $settingsNavigation = OC_App::getSettingsNavigation(); $this->assign('settingsnavigation', $settingsNavigation); foreach ($navigation as $entry) { if ($entry['active']) { $this->assign('application', $entry['name']); break; } } foreach ($settingsNavigation as $entry) { if ($entry['active']) { $this->assign('application', $entry['name']); break; } } $userDisplayName = OC_User::getDisplayName(); $this->assign('user_displayname', $userDisplayName); $this->assign('user_uid', OC_User::getUser()); $this->assign('appsmanagement_active', strpos(\OC::$server->getRequest()->getRequestUri(), \OC::$server->getURLGenerator()->linkToRoute('settings.AppSettings.viewApps')) === 0); $this->assign('enableAvatars', $this->config->getSystemValue('enable_avatars', true)); $this->assign('userAvatarSet', \OC_Helper::userAvatarSet(OC_User::getUser())); } else { if ($renderAs == 'error') { parent::__construct('core', 'layout.guest', '', false); $this->assign('bodyid', 'body-login'); } else { if ($renderAs == 'guest') { parent::__construct('core', 'layout.guest'); $this->assign('bodyid', 'body-login'); } else { parent::__construct('core', 'layout.base'); } } } // Send the language to our layouts $this->assign('language', OC_L10N::findLanguage()); if (empty(self::$versionHash)) { $v = OC_App::getAppVersions(); $v['core'] = implode('.', \OC_Util::getVersion()); self::$versionHash = md5(implode(',', $v)); } $useAssetPipeline = self::isAssetPipelineEnabled(); if ($useAssetPipeline) { $this->append('jsfiles', OC_Helper::linkToRoute('js_config', array('v' => self::$versionHash))); $this->generateAssets(); } else { // Add the js files $jsFiles = self::findJavascriptFiles(OC_Util::$scripts); $this->assign('jsfiles', array(), false); if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') { $this->append('jsfiles', OC_Helper::linkToRoute('js_config', array('v' => self::$versionHash))); } foreach ($jsFiles as $info) { $web = $info[1]; $file = $info[2]; $this->append('jsfiles', $web . '/' . $file . '?v=' . self::$versionHash); } // Add the css files $cssFiles = self::findStylesheetFiles(OC_Util::$styles); $this->assign('cssfiles', array()); foreach ($cssFiles as $info) { $web = $info[1]; $file = $info[2]; $this->append('cssfiles', $web . '/' . $file . '?v=' . self::$versionHash); } } }
public function __construct($renderas) { // Decide which page we show if ($renderas == 'user') { parent::__construct('core', 'layout.user'); if (in_array(OC_APP::getCurrentApp(), array('settings', 'admin', 'help')) !== false) { $this->assign('bodyid', 'body-settings', false); } else { $this->assign('bodyid', 'body-user', false); } // Add navigation entry $navigation = OC_App::getNavigation(); $this->assign('navigation', $navigation, false); $this->assign('settingsnavigation', OC_App::getSettingsNavigation(), false); foreach ($navigation as $entry) { if ($entry['active']) { $this->assign('application', $entry['name'], false); break; } } } else { if ($renderas == 'guest') { parent::__construct('core', 'layout.guest'); } else { parent::__construct('core', 'layout.base'); } } $apps_paths = array(); foreach (OC_App::getEnabledApps() as $app) { $apps_paths[$app] = OC_App::getAppWebPath($app); } $this->assign('apps_paths', str_replace('\\/', '/', json_encode($apps_paths)), false); // Ugly unescape slashes waiting for better solution if (OC_Config::getValue('installed', false) && !OC_AppConfig::getValue('core', 'remote_core.css', false)) { OC_AppConfig::setValue('core', 'remote_core.css', '/core/minimizer.php'); OC_AppConfig::setValue('core', 'remote_core.js', '/core/minimizer.php'); } // Add the js files $jsfiles = self::findJavascriptFiles(OC_Util::$scripts); $this->assign('jsfiles', array(), false); if (!empty(OC_Util::$core_scripts)) { $this->append('jsfiles', OC_Helper::linkToRemoteBase('core.js', false)); } foreach ($jsfiles as $info) { $root = $info[0]; $web = $info[1]; $file = $info[2]; $this->append('jsfiles', $web . '/' . $file); } // Add the css files $cssfiles = self::findStylesheetFiles(OC_Util::$styles); $this->assign('cssfiles', array()); if (!empty(OC_Util::$core_styles)) { $this->append('cssfiles', OC_Helper::linkToRemoteBase('core.css', false)); } foreach ($cssfiles as $info) { $root = $info[0]; $web = $info[1]; $file = $info[2]; $paths = explode('/', $file); $in_root = false; foreach (OC::$APPSROOTS as $app_root) { if ($root == $app_root['path']) { $in_root = true; break; } } if ($in_root) { $app = $paths[0]; unset($paths[0]); $path = implode('/', $paths); $this->append('cssfiles', OC_Helper::linkTo($app, $path)); } else { $this->append('cssfiles', $web . '/' . $file); } } }
/** * @param string $renderAs * @param string $appId application id */ public function __construct($renderAs, $appId = '') { // yes - should be injected .... $this->config = \OC::$server->getConfig(); // Decide which page we show if ($renderAs == 'user') { parent::__construct('core', 'layout.user'); if (in_array(\OC_App::getCurrentApp(), ['settings', 'admin', 'help']) !== false) { $this->assign('bodyid', 'body-settings'); } else { $this->assign('bodyid', 'body-user'); } // Code integrity notification $integrityChecker = \OC::$server->getIntegrityCodeChecker(); if (!$integrityChecker->hasPassedCheck()) { \OCP\Util::addScript('core', 'integritycheck-failed-notification'); } // Add navigation entry $this->assign('application', ''); $this->assign('appid', $appId); $navigation = \OC_App::getNavigation(); $this->assign('navigation', $navigation); $settingsNavigation = \OC_App::getSettingsNavigation(); $this->assign('settingsnavigation', $settingsNavigation); foreach ($navigation as $entry) { if ($entry['active']) { $this->assign('application', $entry['name']); break; } } foreach ($settingsNavigation as $entry) { if ($entry['active']) { $this->assign('application', $entry['name']); break; } } $userDisplayName = \OC_User::getDisplayName(); $appsMgmtActive = strpos(\OC::$server->getRequest()->getRequestUri(), \OC::$server->getURLGenerator()->linkToRoute('settings.AppSettings.viewApps')) === 0; if ($appsMgmtActive) { $l = \OC::$server->getL10N('lib'); $this->assign('application', $l->t('Apps')); } $this->assign('user_displayname', $userDisplayName); $this->assign('user_uid', \OC_User::getUser()); $this->assign('appsmanagement_active', $appsMgmtActive); $this->assign('enableAvatars', $this->config->getSystemValue('enable_avatars', true) === true); if (\OC_User::getUser() === false) { $this->assign('userAvatarSet', false); } else { $this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists()); } } else { if ($renderAs == 'error') { parent::__construct('core', 'layout.guest', '', false); $this->assign('bodyid', 'body-login'); } else { if ($renderAs == 'guest') { parent::__construct('core', 'layout.guest'); $this->assign('bodyid', 'body-login'); } else { parent::__construct('core', 'layout.base'); } } } // Send the language to our layouts $this->assign('language', \OC_L10N::findLanguage()); if (\OC::$server->getSystemConfig()->getValue('installed', false)) { if (empty(self::$versionHash)) { $v = \OC_App::getAppVersions(); $v['core'] = implode('.', \OCP\Util::getVersion()); self::$versionHash = md5(implode(',', $v)); } } else { self::$versionHash = md5('not installed'); } $useAssetPipeline = self::isAssetPipelineEnabled(); if ($useAssetPipeline) { $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('js_config', ['v' => self::$versionHash])); $this->generateAssets(); } else { // Add the js files $jsFiles = self::findJavascriptFiles(\OC_Util::$scripts); $this->assign('jsfiles', array()); if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') { $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('js_config', ['v' => self::$versionHash])); } foreach ($jsFiles as $info) { $web = $info[1]; $file = $info[2]; $this->append('jsfiles', $web . '/' . $file . '?v=' . self::$versionHash); } // Add the css files $cssFiles = self::findStylesheetFiles(\OC_Util::$styles); $this->assign('cssfiles', array()); foreach ($cssFiles as $info) { $web = $info[1]; $file = $info[2]; $this->append('cssfiles', $web . '/' . $file . '?v=' . self::$versionHash); } } }
/** * @param string $renderas * @param string $appid application id */ public function __construct($renderas, $appid = '') { // Decide which page we show if ($renderas == 'user') { parent::__construct('core', 'layout.user'); if (in_array(OC_APP::getCurrentApp(), array('settings', 'admin', 'help')) !== false) { $this->assign('bodyid', 'body-settings'); } else { $this->assign('bodyid', 'body-user'); } // 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 } // Add navigation entry $this->assign('application', '', false); $this->assign('appid', $appid); $navigation = OC_App::getNavigation(); $this->assign('navigation', $navigation); $this->assign('settingsnavigation', OC_App::getSettingsNavigation()); foreach ($navigation as $entry) { if ($entry['active']) { $this->assign('application', $entry['name']); break; } } $user_displayname = OC_User::getDisplayName(); $this->assign('user_displayname', $user_displayname); $this->assign('user_uid', OC_User::getUser()); $this->assign('appsmanagement_active', strpos(OC_Request::requestUri(), OC_Helper::linkToRoute('settings_apps')) === 0); $this->assign('enableAvatars', \OC_Config::getValue('enable_avatars', true)); } else { if ($renderas == 'error') { parent::__construct('core', 'layout.guest', '', false); } else { if ($renderas == 'guest') { parent::__construct('core', 'layout.guest'); } else { parent::__construct('core', 'layout.base'); } } } $versionParameter = '?v=' . md5(implode(OC_Util::getVersion())); $useAssetPipeline = $this->isAssetPipelineEnabled(); if ($useAssetPipeline) { $this->append('jsfiles', OC_Helper::linkToRoute('js_config') . $versionParameter); $this->generateAssets(); } else { // Add the js files $jsfiles = self::findJavascriptFiles(OC_Util::$scripts); $this->assign('jsfiles', array(), false); if (OC_Config::getValue('installed', false) && $renderas != 'error') { $this->append('jsfiles', OC_Helper::linkToRoute('js_config') . $versionParameter); } foreach ($jsfiles as $info) { $web = $info[1]; $file = $info[2]; $this->append('jsfiles', $web . '/' . $file . $versionParameter); } // Add the css files $cssfiles = self::findStylesheetFiles(OC_Util::$styles); $this->assign('cssfiles', array()); foreach ($cssfiles as $info) { $web = $info[1]; $file = $info[2]; $this->append('cssfiles', $web . '/' . $file . $versionParameter); } } }
/** * @brief Proceeds the template * @returns content * * This function proceeds the template. If $this->renderas is set, it will * will produce a full page. */ public function fetchPage() { $data = $this->_fetch(); if ($this->renderas) { // Decide which page we show if ($this->renderas == "user") { $page = new OC_Template("core", "layout.user"); $page->assign('searchurl', OC_Helper::linkTo('search', 'index.php')); if (array_search(OC_APP::getCurrentApp(), array('settings', 'admin', 'help')) !== false) { $page->assign('bodyid', 'body-settings'); } else { $page->assign('bodyid', 'body-user'); } // Add navigation entry $page->assign("navigation", OC_App::getNavigation()); $page->assign("settingsnavigation", OC_App::getSettingsNavigation()); } else { $page = new OC_Template("core", "layout.guest"); } // Add the css and js files foreach (OC_Util::$scripts as $script) { if (is_file(OC::$SERVERROOT . "/apps/{$script}.js")) { $page->append("jsfiles", OC::$WEBROOT . "/apps/{$script}.js"); } elseif (is_file(OC::$SERVERROOT . "/{$script}.js")) { $page->append("jsfiles", OC::$WEBROOT . "/{$script}.js"); } else { $page->append("jsfiles", OC::$WEBROOT . "/core/{$script}.js"); } } foreach (OC_Util::$styles as $style) { if (is_file(OC::$SERVERROOT . "/apps/{$style}.css")) { $page->append("cssfiles", OC::$WEBROOT . "/apps/{$style}.css"); } elseif (is_file(OC::$SERVERROOT . "/{$style}.css")) { $page->append("cssfiles", OC::$WEBROOT . "/{$style}.css"); } else { $page->append("cssfiles", OC::$WEBROOT . "/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(); } else { return $data; } }
/** * @brief Proceeds the template * @returns content * * This function proceeds the template. If $this->renderas is set, it * will produce a full page. */ public function fetchPage() { $data = $this->_fetch(); if ($this->renderas) { // Decide which page we show if ($this->renderas == "user") { $page = new OC_Template("core", "layout.user"); $page->assign('searchurl', OC_Helper::linkTo('search', 'index.php')); if (array_search(OC_APP::getCurrentApp(), array('settings', 'admin', 'help')) !== false) { $page->assign('bodyid', 'body-settings'); } else { $page->assign('bodyid', 'body-user'); } // Add navigation entry $navigation = OC_App::getNavigation(); $page->assign("navigation", $navigation); $page->assign("settingsnavigation", OC_App::getSettingsNavigation()); foreach ($navigation as $entry) { if ($entry['active']) { $page->assign('application', $entry['name']); break; } } } 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. $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 ($page->appendIfExist('jsfiles', OC::$THIRDPARTYROOT, OC::$THIRDPARTYWEBROOT, $script . '.js')) { // Is it in apps and overwritten by the theme? } 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 ($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 ($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 ($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 ($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 ($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; die; } } // Add the css files foreach (OC_Util::$styles as $style) { // is it in 3rdparty? if ($page->appendIfExist('cssfiles', OC::$THIRDPARTYROOT, OC::$THIRDPARTYWEBROOT, $style . '.css')) { // or in apps? } 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 ($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; die; } } // Add the theme css files. you can override the default values here if (!empty($theme)) { 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(); } else { return $data; } }
public function __construct($renderas) { // Decide which page we show if ($renderas == 'user') { parent::__construct('core', 'layout.user'); if (in_array(OC_APP::getCurrentApp(), array('settings', 'admin', 'help')) !== false) { $this->assign('bodyid', 'body-settings'); } else { $this->assign('bodyid', 'body-user'); } // Add navigation entry $this->assign('application', '', false); $navigation = OC_App::getNavigation(); $this->assign('navigation', $navigation); $this->assign('settingsnavigation', OC_App::getSettingsNavigation()); foreach ($navigation as $entry) { if ($entry['active']) { $this->assign('application', $entry['name']); break; } } $user_displayname = OC_User::getDisplayName(); $this->assign('user_displayname', $user_displayname); $this->assign('user_uid', OC_User::getUser()); } else { if ($renderas == 'guest' || $renderas == 'error') { parent::__construct('core', 'layout.guest'); } else { parent::__construct('core', 'layout.base'); } } $versionParameter = '?v=' . md5(implode(OC_Util::getVersion())); // Add the js files $jsfiles = self::findJavascriptFiles(OC_Util::$scripts); $this->assign('jsfiles', array(), false); if (OC_Config::getValue('installed', false) && $renderas != 'error') { $this->append('jsfiles', OC_Helper::linkToRoute('js_config') . $versionParameter); } if (!empty(OC_Util::$core_scripts)) { $this->append('jsfiles', OC_Helper::linkToRemoteBase('core.js', false) . $versionParameter); } foreach ($jsfiles as $info) { $root = $info[0]; $web = $info[1]; $file = $info[2]; $this->append('jsfiles', $web . '/' . $file . $versionParameter); } // Add the css files $cssfiles = self::findStylesheetFiles(OC_Util::$styles); $this->assign('cssfiles', array()); if (!empty(OC_Util::$core_styles)) { $this->append('cssfiles', OC_Helper::linkToRemoteBase('core.css', false) . $versionParameter); } foreach ($cssfiles as $info) { $root = $info[0]; $web = $info[1]; $file = $info[2]; $paths = explode('/', $file); $in_root = false; foreach (OC::$APPSROOTS as $app_root) { if ($root == $app_root['path']) { $in_root = true; break; } } if ($in_root) { $app = $paths[0]; unset($paths[0]); $path = implode('/', $paths); $this->append('cssfiles', OC_Helper::linkTo($app, $path) . $versionParameter); } else { $this->append('cssfiles', $web . '/' . $file . $versionParameter); } } }