예제 #1
0
 /**
  * @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;
     }
 }