示例#1
0
 /**
  * @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);
         }
     }
 }
示例#2
0
 /**
  * Process the template
  * @return boolean|string
  *
  * This function process the template. If $this->renderAs is set, it
  * will produce a full page.
  */
 public function fetchPage()
 {
     $data = parent::fetchPage();
     if ($this->renderAs) {
         $page = new OC_TemplateLayout($this->renderAs, $this->app);
         // Add custom headers
         $headers = '';
         foreach (OC_Util::$headers as $header) {
             $headers .= '<' . \OCP\Util::sanitizeHTML($header['tag']);
             foreach ($header['attributes'] as $name => $value) {
                 $headers .= ' ' . \OCP\Util::sanitizeHTML($name) . '="' . \OCP\Util::sanitizeHTML($value) . '"';
             }
             if ($header['text'] !== null) {
                 $headers .= '>' . \OCP\Util::sanitizeHTML($header['text']) . '</' . \OCP\Util::sanitizeHTML($header['tag']) . '>';
             } else {
                 $headers .= '/>';
             }
         }
         $page->assign('headers', $headers);
         $page->assign('content', $data);
         return $page->fetchPage();
     }
     return $data;
 }
示例#3
0
 /**
  * Process the template
  * @return boolean|string
  *
  * This function process the template. If $this->renderas is set, it
  * will produce a full page.
  */
 public function fetchPage()
 {
     $data = parent::fetchPage();
     if ($this->renderas) {
         $page = new OC_TemplateLayout($this->renderas, $this->app);
         // Add custom headers
         $page->assign('headers', $this->headers, false);
         foreach (OC_Util::$headers as $header) {
             $page->append('headers', $header);
         }
         $page->assign("content", $data, false);
         return $page->fetchPage();
     } else {
         return $data;
     }
 }
示例#4
0
 /**
  * @brief Proceeds the template
  * @return bool
  *
  * 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) {
         $page = new OC_TemplateLayout($this->renderas);
         if ($this->renderas == 'user') {
             $page->assign('requesttoken', $this->vars['requesttoken']);
             $page->assign('requestlifespan', $this->vars['requestlifespan']);
         }
         // Add custom headers
         $page->assign('headers', $this->headers, false);
         foreach (OC_Util::$headers as $header) {
             $page->append('headers', $header);
         }
         $page->assign("content", $data, false);
         return $page->fetchPage();
     } else {
         return $data;
     }
 }
 /**
  * @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 == 'guest' || $renderas == 'error') {
             parent::__construct('core', 'layout.guest');
         } else {
             parent::__construct('core', 'layout.base');
         }
     }
     if (empty(self::$versionHash)) {
         self::$versionHash = md5(implode(',', OC_App::getAppVersions()));
     }
     $useAssetPipeline = $this->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 (OC_Config::getValue('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);
         }
     }
 }
示例#6
0
<?php

session_write_close();
OC_App::loadApps();
if ($service == 'core.css') {
    $minimizer = new OC_Minimizer_CSS();
    $files = OC_TemplateLayout::findStylesheetFiles(OC_Util::$coreStyles);
    $minimizer->output($files, $service);
} else {
    if ($service == 'core.js') {
        $minimizer = new OC_Minimizer_JS();
        $files = OC_TemplateLayout::findJavascriptFiles(OC_Util::$coreScripts);
        $minimizer->output($files, $service);
    }
}